构建OpenCV:无法获取python包装器

时间:2017-11-21 00:19:17

标签: python windows opencv cmake

我正在尝试编译OpenCV并使其python3包装器正常工作,python已安装并在.../AppData/Local/Programs/Python下的计算机上正常工作,但是当我为VS2017构建cmake项目时,python3模块被列为不可用模块:

OpenCV modules:
--     To be built:                 ...
--     Disabled:                    js world
--     Disabled by dependency:      -
--     Unavailable:          ...    python2 python3 ...

这是构建的cmake日志,这是脚本输出的python配置:

--   Python 3:
--     Interpreter:                 .../AppData/Local/Programs/Python/Python36-32/python.exe (ver 3.6.1)
--     Libraries:                   NO
--     numpy:                       .../AppData/Local/Programs/Python/Python36-32/lib/site-packages/numpy/core/include (ver 1.13.3)
--     packages path:               .../AppData/Local/Programs/Python/Python36-32/Lib/site-packages
--
--   Python (for build):            .../AppData/Local/Programs/Python/Python36-32/python.exe
--     Pylint:                      .../AppData/Local/Programs/Python/Python36-32/Scripts/pylint.exe (ver: 1.7.1, checks: 111)

正如你所看到的,脚本找不到python库,我已经尝试将很多python3变量传递给cmake脚本,例如:

cmake -D OPENCV_EXTRA_MODULES=../opencv_contrib/modules \
-D PYTHON3_INCLUDE_DIR=...\Python\Python36-32\include \
-D PYTHON3_LIBRARY=...\Python\Python36-32\libs\python36.lib ../

我也试过了:

-D PYTHON3_LIBRARIES=...\Python\Python36-32\libs\python36.lib

是脚本显示的变量:

  if(PYTHON3LIBS_VERSION_STRING)
status("    Libraries:"   HAVE_opencv_python3  THEN  "${PYTHON3_LIBRARIES} (ver ${PYTHON3LIBS_VERSION_STRING})"   ELSE NO)
  else()
status("    Libraries:"   HAVE_opencv_python3  THEN  "${PYTHON3_LIBRARIES}"                                      ELSE NO)
  endif()

HAVE_opencv_python3函数中的status变量始终设置为OFF:HAVE_opencv_python3=OFF,这来自CMakeVars.txt文件,我也尝试将其设置为ON } -D HAVE_opencv_python3=ON,但没有效果。

0 个答案:

没有答案