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

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

问题描述

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

我按照此

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

解决方案

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

cv2.pyd 现在会自动移动到站点包.您只需要复制 DLL.

<块引用>

正如

  1. configure,会出现很多以红色突出显示的行.

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

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

  1. 再次按configure,新行将以红色突出显示.
  2. 确保在按下生成之前取消选中 BUILD_opencv_contrib_world.

  1. CMake 的最后一步是按生成.
  2. 在继续之前确保生成完成.

  1. 打开空的构建,你会发现一堆文件.最重要的文件是OpenCV.sln.右键单击此 .sln 文件,然后使用 CMake 中使用的 Visual Studio 2013 打开它.

耐心等待这一步,下一步会花费很多时间.

  1. 按照下图中的顺序构建 3 个文件.将模式更改为Release.这些步骤大约需要 10 到 15 分钟.

  1. 复制所有 .dll 文件 [存在于 opencv-3.1.0-devuildinRelease] 和 cv2.pydcode> 并将它们粘贴到 Pyhton27Libsite-packages 中的 site-packages 目录中.
  2. 验证构建打开 Python 并执行 import cv2.如果没有错误,执行cv2.__version__,你应该得到3.1.0-dev.

如果有任何不清楚的地方,请观看本答案开头提供的教程.

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.

I follow the step in this GitHub.

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

When I type cmake _DOPENCV_EXTRA_MODULES_PATH=C:opencv_contribopencv_contrib/modules C:opencvsources, there is an error.

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

解决方案

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

The cv2.pyd is now automatically moved to site-packages. You just only need to copy the DLLs.

As mentioned by @AleksandrUsarov in the comments section, this method still works for OpenCV 4.1.2, but you need to check OPENCV_ENABLE_NONFREE parameter as well.

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.

The steps to follow are:

  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-devuild and opencv-3.1.0-devsources.
  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. Press configure, a lot of lines highlighted in red will appear.

  1. before these lines appear you will have to specify your compiler. (Also select correct bit version based on your needs, same procedure works for 32-bt and 64-bit)

  1. Choose whatever you want to build, but the most important thing to do is to provide the path of the non-free modules.

  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. The last step with CMake is to press generate.
  2. Make sure generating is done before continuing.

  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.

Be patient as this step and the next will take a lot of time.

  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. Copy all the .dll files [present at opencv-3.1.0-devuildinRelease] and the cv2.pyd and paste them in the site-packages directory in Pyhton27Libsite-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天全站免登陆