【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)

文章目录

  • 0. 前言
  • 1. 下载地址
  • 2. 使用CMake生成OpenCV源码
  • 3. 编译OpenCV.sln
  • 4. 将新的extra modules配置到项目中

0. 前言

之前把opencv更新到3.4.5,最近打算使用SURF和SIFT,发现找不到对应的模块。
在新版本里面,这几个特征点检测的方法放在 xfeatures2d 模块中,但是官网上下载的OpenCV标准包里面是不包含这个模块的。从官方的文档查询可以看到,这个模块已经被放到 Extra modules 中了。
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第1张图片
这就需要额外编译 opencv_contrib
·····
·····
·····
如果不想看后面,可以直接下载我编译好的install之后的结果:
百度云:https://pan.baidu.com/s/1fbRU7jOidtMyflMsQChTdg 提取码:fxtp
CSDN资源:https://download.csdn.net/download/qinchang1/11705108
·
下载这个之后,可以直接跳到本文第四节
·····
·····
·····

1. 下载地址

opencv_contrib下载地址: https://github.com/opencv/opencv_contrib/tags
PS: opencv_contrib的版本要和opencv版本一致!
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第2张图片
cmake-gui 下载地址: http://www.cmake.org/cmake/resources/software.html
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第3张图片

2. 使用CMake生成OpenCV源码

opencv_contrib 解压之后文件如下,记住这个路径。
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第4张图片
打开CMake
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第5张图片
输入opencv文件夹下的sources文件路径,给个输出地址,然后再点击“Configure
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第6张图片
选择VS版本,还有X64!!!
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第7张图片
第一次Configure之后会有很多红色的,表示有错误,再点一次Configure
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第8张图片
再点一次之后就变成白色的了。
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第9张图片
生成之后,在中间列表中找到“OPENCV_EXTRA_MODULES_PATH”,把之前opencv_contrib解压文件夹下的modules路径加入进去。
并且勾选“OPENCV_ENABLE_NONFREE”!这个一定要勾选,不然的话等会你用代码的时候就会报错。
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第10张图片
之后点击 Configure,又是点2次,第一次会有红色,第二次就变白了。
在这里插入图片描述
如果不报错的话,再点一次Generate
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第11张图片
第二次生成完成。
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第12张图片
如果出现缺少什么XXX的话,需要自己额外去下,然后放进对应modules里面。

3. 编译OpenCV.sln

点击"Open Project"。
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第13张图片
或者进入刚才生成的文件夹下,点开OpenCV.sln。
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第14张图片
之后重新生成解决方案。
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第15张图片
我的结果如下:
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第16张图片
如下图顺序点击仅生成 INSTALL
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第17张图片
成功之后如下显示。
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第18张图片
之后会生成一个install文件夹,里面的内容就相当于包含了extra modules的opencv
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第19张图片
编译好opencv_contrib install文件下载:
百度云:https://pan.baidu.com/s/1fbRU7jOidtMyflMsQChTdg 提取码:fxtp
CSDN资源:https://download.csdn.net/download/qinchang1/11705108

4. 将新的extra modules配置到项目中

环境变量中添加刚才生成的install文件中的bin文件路径
D:\opencv_contrib\install\bin
(改成自己的\opencv_contrib路径)

【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第20张图片
用户变量中添加:
D:\opencv_contrib\install\x64\vc14\bin
(改成自己的\opencv_contrib路径)
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第21张图片
包含目录输入:
D:\opencv_contrib\install\include
D:\opencv_contrib\install\include\opencv
D:\opencv_contrib\install\include\opencv2

(改成自己的\opencv_contrib路径)
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第22张图片
库目录填入:
D:\opencv_contrib\install\x64\vc14\lib
(改成自己的\opencv_contrib路径)
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第23张图片
添加动态链接库
【OpenCV】OpenCV扩展opencv_contrib x64(Extra modules)_第24张图片
Debug属性中添加:
opencv_aruco345d.lib
opencv_bgsegm345d.lib
opencv_bioinspired345d.lib
opencv_calib3d345d.lib
opencv_ccalib345d.lib
opencv_core345d.lib
opencv_datasets345d.lib
opencv_dnn_objdetect345d.lib
opencv_dnn345d.lib
opencv_dpm345d.lib
opencv_face345d.lib
opencv_features2d345d.lib
opencv_flann345d.lib
opencv_fuzzy345d.lib
opencv_hfs345d.lib
opencv_highgui345d.lib
opencv_img_hash345d.lib
opencv_imgcodecs345d.lib
opencv_imgproc345d.lib
opencv_line_descriptor345d.lib
opencv_ml345d.lib
opencv_objdetect345d.lib
opencv_optflow345d.lib
opencv_phase_unwrapping345d.lib
opencv_photo345d.lib
opencv_plot345d.lib
opencv_reg345d.lib
opencv_rgbd345d.lib
opencv_saliency345d.lib
opencv_shape345d.lib
opencv_stereo345d.lib
opencv_stitching345d.lib
opencv_structured_light345d.lib
opencv_superres345d.lib
opencv_surface_matching345d.lib
opencv_text345d.lib
opencv_tracking345d.lib
opencv_video345d.lib
opencv_videoio345d.lib
opencv_videostab345d.lib
opencv_xfeatures2d345d.lib
opencv_ximgproc345d.lib
opencv_xobjdetect345d.lib
opencv_xphoto345d.lib
·
·
·
Release属性中添加:
opencv_aruco345.lib
opencv_bgsegm345.lib
opencv_bioinspired345.lib
opencv_calib3d345.lib
opencv_ccalib345.lib
opencv_core345.lib
opencv_datasets345.lib
opencv_dnn_objdetect345.lib
opencv_dnn345.lib
opencv_dpm345.lib
opencv_face345.lib
opencv_features2d345.lib
opencv_flann345.lib
opencv_fuzzy345.lib
opencv_hfs345.lib
opencv_highgui345.lib
opencv_img_hash345.lib
opencv_imgcodecs345.lib
opencv_imgproc345.lib
opencv_line_descriptor345.lib
opencv_ml345.lib
opencv_objdetect345.lib
opencv_optflow345.lib
opencv_phase_unwrapping345.lib
opencv_photo345.lib
opencv_plot345.lib
opencv_reg345.lib
opencv_rgbd345.lib
opencv_saliency345.lib
opencv_shape345.lib
opencv_stereo345.lib
opencv_stitching345.lib
opencv_structured_light345.lib
opencv_superres345.lib
opencv_surface_matching345.lib
opencv_text345.lib
opencv_tracking345.lib
opencv_video345.lib
opencv_videoio345.lib
opencv_videostab345.lib
opencv_xfeatures2d345.lib
opencv_ximgproc345.lib
opencv_xobjdetect345.lib
opencv_xphoto345.lib

如有错误,欢迎指正!

你可能感兴趣的:(OpenCV)