Python 3.6.4在Windows 10上安装OpenCV 3.4.0和Opencv contrib

时间:2018-02-02 08:09:25

标签: python windows opencv cmake

我正在使用 OpenCv 3.4.0 Python 3.6.4 Cmake 3.10.2 OpenNI-Windows-x64 -2.2 SensorKinect093-Bin-Win32-v5.1.2.1 Visual Studio 2015 Windows 10 。我想为Python 3.6.4构建cv2.pyd。

我以许多其他方式执行此步骤,例如github和OpenCV install opencv_contrib on Windows

在Cmake中配置之后,它显示了关于python 3的输出:

 Python (for build):            C:/Users/zhong/AppData/Local/Programs/Python/Python36-32/python.exe

Cmake拥有 BUILD_opencv_python3 PYTHON3_INCLUDE_DIR PYTHON3_LIBRARY ,所以我附加了 BUILD_opencv_python3的Bool值并手动填写PYTHON3_INCLUDE_DIR,PYTHON3_LIBRARY的位置。地点如下:

PYTHON3_EXECUTABLE     C:/Users/zhong/AppData/Local/Programs/Python/Python36-32/python.exe
PYTHON3_INCLUDE_DIR    C:/Users/zhong/AppData/Local/Programs/Python/Python36-32/include
PYTHON3_INCLUDE_DIR2      
PYTHON3_LIBRARY        C:/Users/zhong/AppData/Local/Programs/Python/Python36-32/libs/python36.lib
PYTHON3_LIBRARY_DEBUG    
PYTHON3_NUMPY_INCLUDE_DIRS  C:/Users/zhong/AppData/Local/Programs/Python/Python36-32/lib/site-packages/numpy/core/include
PYTHON3_PACKAGES_PATH  C:/Users/zhong/AppData/Local/Programs/Python/Python36-32/Lib/site-packages

之后,Cmake无法找到Python3的库,尽管它具有PYTHON3_LIBRARY的正确位置。关于Cmake中Python3的输出如下:

Python 3:
    Interpreter:                 C:/Users/zhong/AppData/Local/Programs/Python/Python36-32/python.exe (ver 3.6.4)
    Libraries:                   NO
    numpy:                       C:/Users/zhong/AppData/Local/Programs/Python/Python36-32/lib/site-packages/numpy/core/include (ver 1.14.0)
    packages path:               C:/Users/zhong/AppData/Local/Programs/Python/Python36-32/Lib/site-packages

  Python (for build):            C:/Users/zhong/AppData/Local/Programs/Python/Python36-32/python.exe

如何使用Cmake正确配置python 3.6.4?我想使用深度摄像头,所以我必须用OPENNI2编译Opencv。

我正在寻求帮助如何解决?非常感谢你。

2 个答案:

答案 0 :(得分:0)

我放弃 python 3 ,然后安装 python 2.7.14 OpenCV 3.2.0

按照OpenCV install opencv_contrib on Windows中的步骤轻松安装...

我花了太多时间安装,我想OpenCV 3.4.0不支持Python 3.6.4。

答案 1 :(得分:0)

我刚发现此网站包含说明: https://www.scivision.co/install-opencv-python-windows/

我能够使用“ pip install opencv-contrib-python”命令自动下载并安装它。我正在使用Python 3.7(但它也应适用于您列出的版本)并激活了anaconda环境。如果使用anaconda,只需确保在使用的环境中安装了pip并在使用pip install命令之前将其激活即可。