最近用opencv4.5.2配vins,总是报错,每次都要改一大堆,在此总结
OpenCV4 报错error:‘ CV_* ’was not declared in this scope 解决方法汇总
CV_AA
error: ‘CV_AA’ was not declared in this scope
在头文件中添加 #include <opencv2/imgproc/imgproc_c.h>
CV_CALIB_CB_ADAPTIVE_THRESH
error: ‘CV_CALIB_CB_ADAPTIVE_THRESH’ was not declared in this scope
在头文件中添加 #include <opencv2/calib3d/calib3d_c.h>
CV_GRAY2BGR
error: ‘CV_GRAY2BGR’ was not declared in this scope
在头文件中添加 #include <opencv2/imgproc/types_c.h>,或者改成cv::COLOR_GRAY2BGR
CV_THRESH_BINARY_INV / CV_CHAIN_APPROX_SIMPLE / CV_RETR_CCOMP / CV_FONT_HERSHEY_SIMPLEX
error: ‘CV_THRESH_BINARY_INV’ was not declared in this scope
error: ‘CV_CHAIN_APPROX_SIMPLE’ was not declared in this scope
error: ‘CV_RETR_CCOMP’ was not declared in this scope
error: ‘CV_FONT_HERSHEY_SIMPLEX’ was not declared in this scope
依次改为
cv::THRESH_BINARY_INV
cv::CHAIN_APPROX_SIMPLE
cv::RETR_CCOMP
cv::FONT_HERSHEY_SIMPLEX
CV_LOAD_IMAGE_GRAYSCALE
error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
改为cv::IMREAD_COLOR
参考博客:
【Opencv】CV_* was not declared in this scope 的部分解决方法
error: ‘CV_THRESH_BINARY_INV’ was not declared in this scope / error: ‘CV_THRESH_OTSU’ was not dec