当前位置:   article > 正文

opencv常见用法和opencv3->opencv4版本切换_error: ‘cvmat’ does not name a type

error: ‘cvmat’ does not name a type

opencv

一、opencv4的一些语法用法记录

1.1 cv::TermCriteria

The class defining termination criteria for iterative algorithms(这个类定义了迭代算法的终止准则)

1.1.1 Public Types

枚举类

enum Type {
		COUNT =1,
		MAX_ITER =COUNT,
		EPS =2
}
  • 1
  • 2
  • 3
  • 4
  • 5
EnumeratorMeaning
COUNTthe maximum number of iterations or elements to compute最大迭代次数
MAX_ITERditto最大迭代次数
EPSthe desired accuracy or change in parameters at which the iterative algorithm stops迭代算法停止时所需的精度或参数变化

1.1.2 defaut constructor

cv::TermCriteria::TermCriteria()	
  • 1

1.1.3 构造2

cv::TermCriteria::TermCriteria(int type, int maxCount, double epsilon)	
  • 1
typeThe type of termination criteria, one of TermCriteria::Type
maxCountThe maximum number of iterations or elements to compute
epsilonThe desired accuracy or change in parameters at which the iterative algorithm stops

二、opencv3->opencv4版本切换报错

2.1 identifier “CV_AA” is undefined:

#include <opencv2/imgproc/imgproc_c.h>
  • 1

2.2 identifier “CV_GRAY2RGB” is undefined:

#include <opencv2/imgproc/types_c.h>
  • 1

2.3 identifier “CV_CALIB_CB_ADAPTIVE_THRESH” is undefined

CV_CALIB_CB_NORMALIZE_IMAGE
CV_CALIB_CB_FILTER_QUADS
CV_CALIB_CB_FAST_CHECK
CV_CALIB_CB_NORMALIZE_IMAGE
CV_CALIB_CB_FAST_CHECK
CV_CALIB_CB_ADAPTIVE_THRESH
CV_CALIB_CB_FILTER_QUADS

#include <opencv2/calib3d/calib3d_c.h>
  • 1

2.4 fatal error: opencv/cv.h: No such file or directory

找不到opencv/cv.h文件
#include <opencv/cv.h>改为

#include <opencv2/imgproc.hpp>
  • 1

2.5 fatal error: opencv/highgui.h: No such file or directory

#include <opencv2/highgui/highgui_c.h>
  • 1

2.6 error: ‘CV_FONT_HERSHEY_SIMPLEX’ was not declared in this scope

CV_FONT_HERSHEY_SIMPLEX--->FONT_HERSHEY_SIMPLEX
  • 1

opencv4部分取消了CV_前缀
正确作法:

#include <opencv2/imgproc/imgproc_c.h>
  • 1

2.7 error: ‘CV_WINDOW_NORMAL’ was not declared in this scope

#include <opencv2/highgui/highgui_c.h>
  • 1

2.8 error: ‘CV_INTER_LINEAR’ was not declared in this scope

将CV_删除转到变量定义查看某hpp,再寻找所对应的.h文件

#include<opencv2/imgproc/imgproc_c.h>
  • 1

2.9 error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope

#include <opencv2/imgcodecs/legacy/constants_c.h>
  • 1

2.10 pcl的一大段错误

pcl报错(types等等)
选择c++14 编译标准
https://blog.csdn.net/weixin_44001261/article/details/123299374.

2.11 error: ‘CvMat’ does not name a type

2.11.1

error: ‘CvMat’ has not been declared
cvCreateMat()

添加头文件

#include <opencv2/core/types_c.h>
  • 1

2.11.2 CV_REDUCE_SUM(‘CV_REDUCE_SUM’ was not declared in this scope)

#include<opencv2/core/core_c.h>
  • 1

查阅
https://docs.opencv.org.

2.12 error: static assertion failed: std::map must have the same value_type as its allocator on Ubuntu 20.04

链接: https://github.com/raulmur/ORB_SLAM2/pull/585/commits/d5c04468ce85d600f8a0a23fa280b0153fe115e0.

2.13 编译DBoW2等出现"OpenCV > 2.4.3 not found."

make[2]: *** No rule to make target '../Thirdparty/DBoW2/lib/libDBoW2.so', needed by '../lib/libORB_SLAM2.so'
  • 1

改成对应的版本

2.14 Pangolin出错(orb_slam2在ubuntu20.04上编译时)

https://blog.csdn.net/qq_41035283/article/details/122093494.
https://blog.csdn.net/qq_37719890/article/details/122072958.
https://blog.csdn.net/guowenkang123/article/details/120172907.

2.15 fatal error: opencv/cxcore.h: No such file or directory

#include<opencv2/core/core_c.h>
  • 1

2.16 CV_LOAD_IMAGE_UNCHANGED

添加头文件

#include <opencv2/imgcodecs/legacy/constants_c.h>
或者修改为
cv::IMREAD_UNCHANGED
  • 1
  • 2
  • 3

2.17 CV_MINMAX

添加头文件

#include<opencv2/core/core_c.h>
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/966628
推荐阅读
相关标签
  

闽ICP备14008679号