赞
踩
自己的测试环境:Ubuntu 20.04.5,OpenCV4.2.0
CV_INTER_LINEAR was not declared in this scope
自己把OpenCV3的程序转到OpenCV4下进行编译,遇到如下报错
error: ‘CV_INTER_LINEAR’ was not declared in this scope
出现这个问题的主要原因是 OpenCV3 和 OpenCV4 中的某些变量是不一样的。OpenCV4部分取消了CV_前缀
解决方法很简单,就是找到报错的文件,报错的变量修改适配 OpenCV4 中的变量。
CV_INTER_LINEAR 修改为 cv::INTER_LINEAR
或者,添加头文件
#include<opencv2/imgproc/imgproc_c.h>
然后再次编译就可以编译通过了。
CV_RANSAC was not declared in this scope
error: ‘CV_RANSAC’ was not declared in this scope
程序中的 CV_RANSAC 修改为 cv::RANSAC
然后再次编译就可以编译通过了。
CV_WINDOW_AUTOSIZE was not declared in this scope
error: ‘CV_WINDOW_AUTOSIZE’ was not declared in this scope
CV_WINDOW_AUTOSIZE 修改为 cv::WINDOW_AUTOSIZE
或者,添加头文件
#include <opencv2/highgui/highgui_c.h>
然后再次编译就可以编译通过了。
[1] xlsemmmmmm. opencv常见用法和opencv3->opencv4版本切换 [EB/OL]. https://blog.csdn.net/weixin_43848456/article/details/123380782, 2022-07-10/2022-11-28.
CV_GRAY2RGB was not declared in this scope
error: ‘CV_GRAY2RGB’ was not declared in this scope
添加头文件
#include <opencv2/imgproc/types_c.h>
然后再次编译就可以编译通过了。
[1] 老文化沙漠. opencv4中未定义标识符CV_BGR2GRAY和CV_CAP_PROP_FRAME_COUNT问题 [EB/OL]. https://blog.csdn.net/qq_48176859/article/details/109735701, 2020-11-17/20222-12-03.
fatal error: opencv/cv.h: No such file or directory
编译报错:
找不到opencv/cv.h文件
fatal error: opencv/cv.h: No such file or directory
将报错文件包含的头文件进行修改:
#include <opencv/cv.h>
修改为:
#include <opencv2/imgproc/types_c.h>
然后再次编译就可以编译通过了。
fatal error: opencv/highgui.h: No such file or directory
编译报错:
fatal error: opencv/highgui.h: No such file or directory
将报错文件包含的头文件进行修改:
#include <opencv/highgui.h>
修改为:
#include <opencv2/highgui/highgui_c.h>
然后再次编译就可以编译通过了。
[1] xlsemmmmmm. opencv常见用法和opencv3->opencv4版本切换 [EB/OL]. https://blog.csdn.net/weixin_43848456/article/details/123380782, 2022-07-10/2022-11-28.
error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
编译报错:
error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
将报错文件包含的头文件进行修改:
CV_LOAD_IMAGE_GRAYSCALE
修改为:
cv::IMREAD_GRAYSCALE
然后再次编译就可以编译通过了。
[1] 我是快乐的小趴菜. ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope [EB/OL]. https://blog.csdn.net/guanjing_dream/article/details/124960771, 2022-05-25/2022-12-05.
error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
编译报错:
error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope
将报错文件包含的 CV_LOAD_IMAGE_COLOR
进行修改:
CV_LOAD_IMAGE_COLOR
修改为:
cv::IMREAD_COLOR
然后再次编译就可以编译通过了。
[1] 我是快乐的小趴菜. ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope [EB/OL]. https://blog.csdn.net/guanjing_dream/article/details/124960771, 2022-05-25/2022-12-05.
error: ‘CV_RGB2GRAY’ was not declared in this scope
编译报错:
error: ‘CV_RGB2GRAY’ was not declared in this scope
将报错文件包含的 CV_RGB2GRAY
进行修改:
CV_RGB2GRAY
修改为:
cv::COLOR_RGB2GRAY
然后再次编译就可以编译通过了。
将报错文件中增加包含头文件:
#include <opencv2/imgproc/types_c.h>
// #include <opencv2/opencv.hpp> // 如果只包含上一个头文件依旧不能解决问题,那么就把两个头文件都包含进去。
然后再次编译就可以编译通过了。
[1] 翟羽嚄. OpenCV4、C++:未定义标识符 “CV_RGB2GRAY“ 的解决方案 [EB/OL]. https://blog.csdn.net/mao_hui_fei/article/details/109135733, 2020-10-17/2023-10-29.
error: ‘CV_FONT_HERSHEY_SIMPLEX’ was not declared in this scope
编译报错:
error: ‘CV_FONT_HERSHEY_SIMPLEX’ was not declared in this scope
将报错文件包含的 CV_FONT_HERSHEY_SIMPLEX
进行修改:
CV_FONT_HERSHEY_SIMPLEX
修改为:
cv::FONT_HERSHEY_SIMPLEX
然后再次编译就可以编译通过了。
[1] 宇文树雪. VINS-Mono在opencv4环境下的安装问题和解决方法 [EB/OL]. https://zhuanlan.zhihu.com/p/548140724, 2022-07-31/2023-10-29.
CV_GRAY2BGR was not declared in this scope
error: ‘CV_GRAY2BGR’ was not declared in this scope
添加头文件
#include <opencv2/imgproc/types_c.h>
然后再次编译就可以编译通过了。
CV_CALIB_CB_ADAPTIVE_THRESH was not declared in this scope
error: ‘CV_CALIB_CB_ADAPTIVE_THRESH’ was not declared in this scope
添加头文件
#include <opencv2/calib3d/calib3d_c.h>
然后再次编译就可以编译通过了。
[1] xlsemmmmmm. opencv常见用法和opencv3->opencv4版本切换 [EB/OL]. https://blog.csdn.net/weixin_43848456/article/details/123380782, 2022-07-10/2024-07-04.
CV_AA was not declared in this scope
error: ‘CV_AA’ was not declared in this scope
添加头文件
#include <opencv2/imgproc/imgproc_c.h>
然后再次编译就可以编译通过了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。