OpenCV在Windows上安装opencv_contrib [英] OpenCV install opencv_contrib on Windows

查看:155
本文介绍了OpenCV在Windows上安装opencv_contrib的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 OpenCV 3.1.0 Python 2.7.11 Windows 10.我想构建额外的模块( opencv_contrib ).

I am using OpenCV 3.1.0 , Python 2.7.11 and Windows 10. I want to build the extra modules (opencv_contrib) into OpenCV.

我遵循此 GitHub 中的步骤.

$ cd <opencv_build_directory>
$ cmake -DOPENCV_EXTRA_MODULES_PATH=<opencv_contrib>/modules <opencv_source_directory>
$ make -j5

当我键入cmake _DOPENCV_EXTRA_MODULES_PATH=C:\opencv_contrib\opencv_contrib/modules C:\opencv\sources时,出现错误.

我正在寻求帮助,我该如何解决.谢谢.

I am looking for help how can I solve it. Thank you.

推荐答案

更新29-5-2017:这也适用于OpenCV 3.2.0-dev.现在使用Visual Studio 2015或2017没有错误.

Update 29-5-2017: This also works with OpenCV 3.2.0-dev. Now using Visual Studio 2015 or 2017 gives no errors.

cv2.pyd现在自动移至站点程序包.您只需要复制DLL.

我做了一个有关如何从头开始编译和构建自己的OpenCV 3.1.0-dev的教程.它简单而有条理,与我合作非常好.如果您有时间重新编译OpenCV,请查看教程.

I have made a tutorial on how to compile and build your own OpenCV 3.1.0-dev from scratch. It is simple and organized and works with me very well. If you have time to recompile OpenCV check out the tutorial.

要执行的步骤是:

  1. 安装Visual Studio 2013
  2. 安装 CMake
  3. github
  4. 下载opencv和opencv_contrib
  5. 创建目录opencv-3.1.0-dev,并在此目录中创建其他两个目录,一个称为build,另一个称为sources. paths将是opencv-3.1.0-dev\buildopencv-3.1.0-dev\sources.
  6. 解压缩opencv-master.zipopencv_contrib-master.zip
  7. 在步骤4中创建的sources目录中,粘贴opencvopencv_contrib目录
  8. 打开CMake并提供两条路径,一条用于构建目录,另一条用于源目录
  1. Install Visual Studio 2013
  2. Install CMake
  3. Download both opencv and opencv_contrib from github
  4. Create a directory opencv-3.1.0-dev and in this directory create other two directories one called build and the other called sources. The paths will be opencv-3.1.0-dev\build and opencv-3.1.0-dev\sources.
  5. Unzip opencv-master.zipand opencv_contrib-master.zip
  6. In the sources directory created in step 4, paste opencv and opencv_contrib directories
  7. Open CMake and provide two paths, one for the build directory and the other for the sources directory

  1. configure (配置),将显示很多以红色突出显示的行.
  1. Press configure, a lot of lines highlighted in red will appear.

  1. 在出现这些行之前,您必须指定编译器. (还可以根据您的需要选择正确的位版本,相同的步骤适用于32-bt和64-bit)

  1. 选择任何您想构建的东西,但是最重要的是提供非自由模块的路径.

    再次
  1. 配置,新行将以红色突出显示.
  2. 在按生成"之前,请确保取消选中BUILD_opencv_contrib_world.
  1. Press configure again and new lines will be highlighted in red.
  2. Make sure to uncheck BUILD_opencv_contrib_world before pressing generate.

  1. 使用CMake的最后一步是按生成.
  2. 在继续之前确保generating is done.
  1. The last step with CMake is to press generate.
  2. Make sure generating is done before continuing.

  1. 打开为空的内部版本,您会发现一堆文件.最重要的文件是OpenCV.sln.右键单击此.sln文件,然后使用CMake中使用的Visual Studio 2013将其打开.
  1. open the build that was empty and you will find a bunch of files. The most important file is OpenCV.sln. Right click on this .sln file and open it with the visual studio 2013 used in CMake.

此步骤要耐心等待,下一步需要很多时间.

  1. 按照下图的顺序构建3个文件.将模式更改为Release.这些步骤大约需要10到15分钟.
  1. Build the 3 files with the order in the following image. Change the mode into Release. These step take about 10 to 15 minutes.

  1. 复制[在opencv-3.1.0-dev\build\bin\Release处的所有.dll文件"和cv2.pyd,并将它们粘贴到Pyhton27\Lib\site-packagessite-packages目录中.
  2. 要验证构建,请打开Python并执行import cv2.如果没有错误,请执行cv2.__version__,您将得到3.1.0-dev.
  1. Copy all the .dll files [present at opencv-3.1.0-dev\build\bin\Release] and the cv2.pyd and paste them in the site-packages directory in Pyhton27\Lib\site-packages.
  2. To verify the build open Python and execute import cv2. If no errors, execute cv2.__version__, and you should get 3.1.0-dev.

如果不清楚,请观看此答案开头提供的教程.

If anything is not clear please watch the tutorial provided at the beginning of this answer.

这篇关于OpenCV在Windows上安装opencv_contrib的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆