我试图在OS X上使用opencv_contrib
构建opencv。我将逐步解释我所做的事情:
opencv_contrib
文件夹放在opencv-3.1.0
文件夹opencv-3.1.0
文件夹/Users/kelvinsp/Downloads/opencv-3.1.0/build/
然后我运行了以下命令:
cmake -DOPENCV_EXTRA_MODULES_PATH=/Users/kelvinsp/Downloads/opencv-3.1.0/opencv_contrib/modules /Users/kelvinsp/Downloads/opencv-3.1.0/
make -j5
sudo make install
然后,在python终端中,我尝试运行命令:import cv2
并收到以下错误:ImportError: No module named cv2
export PYTHONPATH=/usr/local/lib/python2.7/site-packages/:$PYTHONPATH
import cv2
命令正常运行,但是当我运行命令help(cv2.face)
时出现以下错误:AttributeError: 'module' object has no attribute 'face'
答案 0 :(得分:1)
“-D”和“OPENCV_EXTRA_MODULES_PATH = ...”之间必须有空格, 这意味着“cmake -D OPENCV_EXTRA_MODULES_PATH = / Users / kelvinsp / Downloads / opencv-3.1.0 / opencv_contrib / modules /Users/kelvinsp/Downloads/opencv-3.1.0/”, 并检查是否有“face”模块构建