OpenCV4.5 报错error:‘ CV_* ’was not declared in this scope 解决解决办法总结

在学习视觉SLAM十四讲过程中,好多地方的opencv需要更改,查阅了一些资料,在这里做一下总结

OpenCV4.5 报错error:‘ CV_* ’was not declared in this scope 解决解决办法总结

  • 1. CV_LOAD_IMAGE_UNCHANGED和CV_LOAD_IMAGE_COLOR
  • 2. CV_AA
  • 3. CV_CALIB_CB_ADAPTIVE_THRESH
  • 4. CV_GRAY2BGR
  • 5. CV_THRESH_BINARY_INV / CV_CHAIN_APPROX_SIMPLE / CV_RETR_CCOMP / CV_FONT_HERSHEY_SIMPLEX
  • 6. CV_LOAD_IMAGE_GRAYSCALE
  • 7. CV_FM_8POINT

1. CV_LOAD_IMAGE_UNCHANGED和CV_LOAD_IMAGE_COLOR

错误内容:

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

解决办法:

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

2. CV_AA

错误内容:

error: ‘CV_AA’ was not declared in this scope

解决办法:

//添加头文件
#include 

3. CV_CALIB_CB_ADAPTIVE_THRESH

错误内容:

error: ‘CV_CALIB_CB_ADAPTIVE_THRESH’ was not declared in this scope

解决办法:

//添加头文件
 #include 

4. CV_GRAY2BGR

错误内容:

error: ‘CV_GRAY2BGR’ was not declared in this scope

解决办法:

  1. 更改代码
//代码改为
cv::COLOR_GRAY2BGR
  1. 添加头文件
//添加头文件
#include 

5. 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

6. CV_LOAD_IMAGE_GRAYSCALE

错误内容:

error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope

解决办法:

//代码改为
cv::IMREAD_COLOR

7. CV_FM_8POINT

错误内容:

error: ‘CV_FM_8POINT’ was not declared in this scope

解决办法:

  1. 更改代码
//更改前
CV_FM_8POINTT
//更改后
FM_8POINT
  1. 添加头文件
#include 

你可能感兴趣的:(各种问题的解决,#,SLAM相关,opencv,计算机视觉,人工智能,ubuntu)