2019/12/19学习笔记
1.cvtColor函数
cvtColor()函数是一个颜色空间转换函数,可以实现RGB颜色向HSV,HSI等颜色空间转换,以及转换为灰度图。
cvtColor(src1, srcGray1, CV_RGB2GRAY);
cvtColor(src2, srcGray2, CV_RGB2GRAY); //转为灰度图
在opencv2版本之前运行成功!
使用最新版本opencv4.1.2时,提示:“CV_RGB2GRAY”: 未声明的标识符。
#include <opencv2/imgproc/types_c.h>//添加该头文件,cvtColor函数运行成功
2.openCV(头文件问题)
在更新最新版本之后(OpenCV4.1.2)。无法打开 源 文件 "opencv2/nonfree/nonfree.hpp"问题!
原因在于:官方公布的文件https://docs.opencv.org/3.1.0/db/dfa/tutorial_transition_guide.html
Changed modules
- ml module has been rewritten
- highgui module has been split into parts: imgcodecs, videoio and highgui itself
- features2d module have been reorganized (some feature detectors has been moved to opencv_contrib/xfeatures2d module)
- legacy, nonfree modules have been removed. Some algorithms have been moved to different locations and some have been completely rewritten or removed
- CUDA API has been updated (gpu module -> several cuda modules, namespace gpu -> namespace cuda)
- OpenCL API has changed (ocl module has been removed, separate ocl:: implementations -> Transparent API)
- Some other methods and classes have been relocated
就是将部分算法模块删除或迁移,将很多算法放到了opencv_contrib中,https://github.com/opencv/opencv_contrib
想要使用该部分算法,需要自己opencv_contrib编译到opencv中。以下简单介绍以下opencv在windows下编译的过程。
因为我用的是opencv目前最新版本opencv4.1.2,所以我下载了相对应的版本。
在https://github.com/opencv中下载了 opencv源码opencv4.1.2和opencv-contrib4.1.2。
在cmake官网https://cmake.org/download/上下载了最新版本Cmake3.16.1。
图片为我刚下载好的压缩包。
详细的windows下编译opencv+opencv_contrib教程,参考https://blog.csdn.net/qq_42299461/article/details/103626611
来源:CSDN
作者:璃墟
链接:https://blog.csdn.net/qq_42299461/article/details/103614034