在Ubuntu中设置带Python绑定的OpenCV 2.3
如何在Ubuntu(或者一般的Linux系统)上安装OpenCV(确切来说是2.3.*版本,而不是2.1.*版本),并且要有Python的支持?我看到了一些关于Windows安装的指南,但没有针对Linux的。
我读过并使用了来自willow garage网站的安装说明:
wget downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.3.1/OpenCV-2.3.1a.tar.bz2
tar -xvf OpenCV-2.3.1a.tar.bz2
cd OpenCV-2.3.1/
mkdir release
cd release
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=OFF -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON ..
make
sudo make install
一切看起来都没问题,除了在执行make install
时的输出没有提到Python。
之后我尝试在Python的交互式环境中导入opencv模块:
~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy # so numpy is installed
>>> import cv
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named cv2
我哪里做错了?
1 个回答
12
你安装过Python开发的头文件吗?
sudo apt-get install python-dev
安装好之后重新编译一下。