centos opencv + python 配置

该博客详细介绍了如何在CentOS系统中从源代码安装OpenCV,并配置与Python的整合。步骤包括安装CMake、GCC、Python-devel和Numpy,以创建Python扩展。同时,需要GTK支持GUI功能,以及Camera和Media的支持。还提到了更新图像格式库的选项,最后通过yum安装opencv、opencv-python和opencv-devel,并提供了一个简单的test.py测试脚本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

opencv + python 配置

1 Installing OpenCV from source

1.1 We need CMake to configure the installation, GCC for compilation, Python-devel and Numpy for creating Python extensions etc.

yum install cmake
yum install python-devel numpy
yum install gcc gcc-c++

1.2 Next we need GTK support for GUI features, Camera support (libdc1394, libv4l), Media Support (ffmpeg, gstreamer)

yum install gtk2-devel
yum install libdc1394-devel
yum install libv4l-devel
yum install ffmpeg-devel
yum install gstreamer-plugins-base-devel

1.3 OpenCV comes with supporting files for image formats like PNG, JPEG, JPEG2000, TIFF, WebP etc. But it may be a little old. If you want to get latest libraries, you can install development files for these formats.

yum install libpng-devel
yum install libjpeg-turbo-devel
yum install jasper-devel
yum install openexr-devel
yum install libtiff-devel
yum install libwebp-devel

1.4 install OpenCV

  • yum install opencv
  • yum install opencv-python
  • yum install opencv-devel (opencv 开发包,含有头文件, for c++)

1.5 test.py

import cv2
import numpy as np

img = np.zeros((512, 512, 3), np.uint8)
cv2.line(img, (0,0), (511, 511), (255, 0, 0), 5)
cv2.imshow('img',img)
cv2.waitKey(1000)
cv2.destroyAllWindows()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值