OpenCV4 error error: ' CV_* 'was not declared in this scope Solution summary

Recently I used opencv4.5.2 with vins, and it always reported errors. I had to make a lot of changes every time. Here’s a summary.

CV_AA

error: ‘CV_AA’ was not declared in this scope

Add #include <opencv2/imgproc/imgproc_c.h> to the header file

CV_CALIB_CB_ADAPTIVE_THRESH

error: ‘CV_CALIB_CB_ADAPTIVE_THRESH’ was not declared in this scope

Add #include <opencv2/calib3d/calib3d_c.h> to the header file

CV_GRAY2BGR

error: ‘CV_GRAY2BGR’ was not declared in this scope

Add #include <opencv2/imgproc/types_c.h> to the header file, or change it to 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

Change to
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

Change to cv::IMREAD_COLOR


Reference blog:
[Opencv] Some solutions to 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

Guess you like

Origin blog.csdn.net/slender_1031/article/details/130530639