OpenCV4.5 error error:' CV_* 'was not declared in this scope Summary of solutions

In the process of learning the 14th lecture of visual SLAM, the opencv in many places needs to be changed. I checked some information and made a summary here

1. CV_LOAD_IMAGE_UNCHANGED和CV_LOAD_IMAGE_COLOR

Error content:

‘CV_LOAD_IMAGE_UNCHANGED‘ : undeclared identifier
error: ‘CV_LOAD_IMAGE_COLOR’ was not declared in this scope

Solution:

//添加头文件
#include "opencv2/imgcodecs/legacy/constants_c.h" 

2. CV_AA

Error content:

error: ‘CV_AA’ was not declared in this scope

Solution:

//添加头文件
#include <opencv2/imgproc/imgproc_c.h>

3. CV_CALIB_CB_ADAPTIVE_THRESH

Error content:

error: ‘CV_CALIB_CB_ADAPTIVE_THRESH’ was not declared in this scope

Solution:

//添加头文件
 #include <opencv2/calib3d/calib3d_c.h>

4. CV_GRAY2BGR

Error content:

error: ‘CV_GRAY2BGR’ was not declared in this scope

Solution:

  1. change code
//代码改为
cv::COLOR_GRAY2BGR
  1. add header file
//添加头文件
#include <opencv2/imgproc/types_c.h>

5. CV_THRESH_BINARY_INV / CV_CHAIN_APPROX_SIMPLE / CV_RETR_CCOMP / CV_FONT_HERSHEY_SIMPLEX

Error content:

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

Solution:

//代码改为
cv::THRESH_BINARY_INV
cv::CHAIN_APPROX_SIMPLE
cv::RETR_CCOMP
cv::FONT_HERSHEY_SIMPLEX

6. CV_LOAD_IMAGE_GRAYSCALE

Error content:

error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope

Solution:

//代码改为
cv::IMREAD_COLOR

7. CV_FM_8POINT

Error content:

error: ‘CV_FM_8POINT’ was not declared in this scope

Solution:

  1. change code
//更改前
CV_FM_8POINTT
//更改后
FM_8POINT
  1. add header file
#include <opencv2/opencv.hpp>

8. CV_FILLED

Error content:

error: ‘CV_FILLED’ was not declared in this scope

Solution:

// 添加头文件
#include <opencv2/imgproc/imgproc_c.h>

9. CV_MINMAX

Error content:

error: ‘CV_MINMAX’ was not declared in this scope

Solution:

// 添加头文件
#include<opencv2/opencv.hpp>

10. CV_RGB2GRAY

Error content:

error: ‘CV_RGB2GRAY’ was not declared in this scope

Solution:

// 添加头文件
#include <opencv2/highgui/highgui_c.h>

11. CV_ADAPTIVE_THRESH_MEAN_C

Error content:

error: ‘CV_ADAPTIVE_THRESH_MEAN_C’ was not declared in this scope

Solution:

// 添加头文件
#include <opencv2/calib3d/calib3d_c.h>

Guess you like

Origin blog.csdn.net/qq_44164791/article/details/131210608