1: 获取opencv代码:
cd /opt
git clone https://github.com/Itseez/opencv.git
cd opencv/
git checkout tags/2.4.11
2:编译代码:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DINSTALL_C_EXAMPLES=OFF \
-DOPENCV_EXTRA_MODULES_PATH=~/opt/opencv/modules \
-DPYTHON_EXECUTABLE=/usr/lib64/python2.7 \
-DBUILD_EXAMPLES=ON ..
make
make install
3:安装opencv的Python接口
cd /usr/lib64/python2.7/site-packages/
ln -s /usr/local/lib64/python2.7/site-packages/cv2.so cv2.so
ln -s /usr/local/lib64/python2.7/site-packages/cv.py cv.py
4:报错ImportError: No module named cv2
网友评论