OpenCV4 报错error:‘ CV_* ’was not declared in this scope 解决方法汇总

文章总结了在使用OpenCV4.5.2时遇到的CV_*未声明的错误,提供了解决方案,包括添加对应的头文件,如<imgproc_c.h>,<calib3d_c.h>,以及将旧的CV_常量替换为cv::新常量,如CV_THRESH_BINARY_INV替换为cv::THRESH_BINARY_INV等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近用opencv4.5.2配vins,总是报错,每次都要改一大堆,在此总结

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值