本人其实已经配好了opencv,但是发现有的需要扩展库,于是参考了很多开始配置的漫漫长路
整个过程可参考以下3个结合着看,本文主要记录自己的过程及补充,格式混乱请别介意
1、opencv3.0中contrib模块的添加_strccc的博客-CSDN博客
2、
Opencv4.0.1的环境配置以及源码与扩展模块编译配置(Window X64)_汤姆鱼的博客-CSDN博客
3、Cmake 配置Opencv以及拓展库(4.1.0版本) - 知乎
OpenCV: GitHub - opencv/opencv: Open Source Computer Vision Library
Extra Modules: GitHub - opencv/opencv_contrib: Repository for OpenCV's extra modules
cmake:Download | CMake
安装不再赘述,本人之前已经安装好cmke
(1)FFMPEG: Download failed: 6;"Couldn't resolve host name" (已放于百度网盘,见3(1))
解决:
①下载缺失文件(已放于百度网盘,见第3部分(1)):
mpeg_version.cmake,opencv_videoio_ffmpeg_64.dll,opencv_videoio_ffmpeg.dll。
②下载方式:
打开build(cmake设定的文件夹)文件下的CMakeDownloadLog.txt,找到跟ffmpeg相关的三个链接,打开ghproxy.com 网址,输入三个链接。
③如果ffmpeg_version.cmake文件打开是网页,则直接将网页另存为,另存时文件类型选择全部,同时命名去掉.txt后缀。
④将3个文件放入opencv的**.cache/ffmpeg**文件夹中,对应文件重命名。
参考:
FFMPEG: Download failed: 6;“Couldn‘t resolve host name“_free_luojing的博客-CSDN博客
https://blog.csdn.net/weixin_45275421/article/details/104449460?utm_source=app
directory
解决:将上面的 OPENCV_GENERATE_SETUPVARS 勾框去掉:
(1)CMake Warning at cmake/OpenCVDownload.cmake:202 (message):
xfeatures2d/boostdesc: Download failed: 35;"SSL connect error"
总之提示一堆xfeatures2d相关文件缺失
解决:下载xfeatures2d相关缺失文件,放于百度网盘了
链接:https://pan.baidu.com/s/1zYbEGjwrhKGZ6VXsWjC05A
提取码:1111
--来自百度网盘超级会员V1的分享
(2)data: Download failed: 28;"Timeout was reached"
解决:连接时出现这个问题,断开则问题消失,总之多试几次
对CMakeTargets下的INSTALL,在Debug和Release下分别右键生成
解决:
VIsual Studio编译OpenCV 无法打开python36_d.lib的问题_咯哦哦哦哦的博客-CSDN博客_python36_d.lib
生成成功后生成此文件D:\Program Files (x86)\OpenCV\opencv_compile\install
只有这个install是有用的,可以选择只保留这个,但是我保留了所有文件
D:\Program Files (x86)\OpenCV\opencv_compile\install\x64\vc15\bin
新建vs项目,视图-其他窗口-属性管理器,分别在debug和release下添加属性表
① VC++包含目录:
D:\Program Files (x86)\OpenCV\opencv_compile\install\include
D:\Program Files (x86)\OpenCV\opencv_compile\install\include\opencv2
D:\Program Files (x86)\OpenCV\opencv_compile\install\include\opencv
②VC++库目录:
D:\Program Files (x86)\OpenCV\opencv_compile\install\x64\vc15\lib
③链接器-输入-附加依赖项
可以在\opencv_compile\install\build\x64\vc15\lib下查看
末尾d.lib是debug的,lib是release的(因为前面对CMakeTargets下的INSTALL生成的debug和release都在这里)
如何获取某一文件夹下文件名字参考:python中os.listdir( )函数读取文件夹 - Rogn - 博客园
代码如下(pycharm中运行)
import os
path = "D:\\Program Files (x86)\\OpenCV\\opencv_compile\\install\\x64\\vc14\\lib"
files = os.listdir(path)
for filename in files:
print(filename)
这里直接给出得到的附加依赖项
debug版lib:
opencv_aruco3416d.lib
opencv_bgsegm3416d.lib
opencv_bioinspired3416d.lib
opencv_calib3d3416d.lib
opencv_ccalib3416d.lib
opencv_core3416d.lib
opencv_datasets3416d.lib
opencv_dnn3416d.lib
opencv_dnn_objdetect3416d.lib
opencv_dpm3416d.lib
opencv_face3416d.lib
opencv_features2d3416d.lib
opencv_flann3416d.lib
opencv_fuzzy3416d.lib
opencv_hdf3416d.lib
opencv_hfs3416d.lib
opencv_highgui3416d.lib
opencv_imgcodecs3416d.lib
opencv_imgproc3416d.lib
opencv_img_hash3416d.lib
opencv_line_descriptor3416d.lib
opencv_ml3416d.lib
opencv_objdetect3416d.lib
opencv_optflow3416d.lib
opencv_phase_unwrapping3416d.lib
opencv_photo3416d.lib
opencv_plot3416d.lib
opencv_reg3416d.lib
opencv_rgbd3416d.lib
opencv_saliency3416d.lib
opencv_shape3416d.lib
opencv_stereo3416d.lib
opencv_stitching3416d.lib
opencv_structured_light3416d.lib
opencv_superres3416d.lib
opencv_surface_matching3416d.lib
opencv_text3416d.lib
opencv_tracking3416d.lib
opencv_video3416d.lib
opencv_videoio3416d.lib
opencv_videostab3416d.lib
opencv_viz3416d.lib
opencv_xfeatures2d3416d.lib
opencv_ximgproc3416d.lib
opencv_xobjdetect3416d.lib
opencv_xphoto3416d.lib
release版lib:
opencv_aruco3416.lib
opencv_bgsegm3416.lib
opencv_bioinspired3416.lib
opencv_calib3d3416.lib
opencv_ccalib3416.lib
opencv_core3416.lib
opencv_datasets3416.lib
opencv_dnn3416.lib
opencv_dnn_objdetect3416.lib
opencv_dpm3416.lib
opencv_face3416.lib
opencv_features2d3416.lib
opencv_flann3416.lib
opencv_fuzzy3416.lib
opencv_hdf3416.lib
opencv_hfs3416.lib
opencv_highgui3416.lib
opencv_imgcodecs3416.lib
opencv_imgproc3416.lib
opencv_img_hash3416.lib
opencv_line_descriptor3416.lib
opencv_ml3416.lib
opencv_objdetect3416.lib
opencv_optflow3416.lib
opencv_phase_unwrapping3416.lib
opencv_photo3416.lib
opencv_plot3416.lib
opencv_reg3416.lib
opencv_rgbd3416.lib
opencv_saliency3416.lib
opencv_shape3416.lib
opencv_stereo3416.lib
opencv_stitching3416.lib
opencv_structured_light3416.lib
opencv_superres3416.lib
opencv_surface_matching3416.lib
opencv_text3416.lib
opencv_tracking3416.lib
opencv_video3416.lib
opencv_videoio3416.lib
opencv_videostab3416.lib
opencv_viz3416.lib
opencv_xfeatures2d3416.lib
opencv_ximgproc3416.lib
opencv_xobjdetect3416.lib
opencv_xphoto3416.lib
#include
#include
#include "opencv2/xfeatures2d.hpp"
using namespace cv;
using namespace std;
using namespace xfeatures2d;
int main()
{
Mat matSrc = imread("E:\\Projects\\VS2017projects\\c++配置测试\\opencv扩展库\\Project1\\Project1\\dog.jpg");
Mat draw;
std::vector<KeyPoint> keypoints;
auto sift_detector = SIFT::create();
sift_detector->detect(matSrc, keypoints);
drawKeypoints(matSrc, keypoints, matSrc);
imshow("gray", matSrc);
waitKey(0);
return 0;
}
结果:加载你定义的图像即可