OpenCV4错误:在此作用域中未声明“CV_CAP_PROP_FRAME_WIDTH”。

14

我最近从OpenCV3.3迁移到了最新版本的OpenCV4,用的是Ubuntu 18.04 LTS系统。我在安装过程中遇到了一些持续性的问题。

我按照此教程安装时没有出现任何错误。但是,每当我在我的项目中包含opencv2/highgui.hpp模块时,就会出现以下问题。根据这个链接,这似乎是由highgui.hpp引起的问题。

/home/arun/Documents/AutonomousLaneDetection/app/main.cpp: In function ‘int main(int, char**)’:
/home/arun/Documents/AutonomousLaneDetection/app/main.cpp:118:36: error: ‘CV_CAP_PROP_FRAME_WIDTH’ was not declared in this scope
 int videoWidth = videofile.get(CV_CAP_PROP_FRAME_WIDTH);
                                ^~~~~~~~~~~~~~~~~~~~~~~
/home/arun/Documents/AutonomousLaneDetection/app/main.cpp:119:37: error: ‘CV_CAP_PROP_FRAME_HEIGHT’ was not declared in this scope
 int videoHeight = videofile.get(CV_CAP_PROP_FRAME_HEIGHT);
                                 ^~~~~~~~~~~~~~~~~~~~~~~~
/home/arun/Documents/AutonomousLaneDetection/app/main.cpp:123:27: error: ‘CV_FOURCC’ was not declared in this scope
                       CV_FOURCC('M', 'J', 'P', 'G'), 10,
                       ^~~~~~~~~
/home/arun/Documents/AutonomousLaneDetection/app/main.cpp:123:27: note: suggested alternative: ‘CV_BLURCV_FOURCC('M', 'J', 'P', 'G'), 10,
                       ^~~~~~~~~
                       CV_BLUR

2
OpenCV 3.4 不是 OpenCV 4。没有所谓的“AKA”。OpenCV有这两个版本,它们是独立的。 - alkasm
1个回答

24

这些常量在OpenCV中的名称和位置已经改变了一段时间。

对于捕获属性,它们不再以CV_开头,所以请将所有此前缀都删除。您可以在这里找到所有可用捕获属性的列表,请注意它们都只以CAP_PROP_开头。

FOURCC代码构造函数现在是VideoWriter类上的一个方法,因此您应该使用VideoWriter::fourcc(...)。文档可以在这里找到。


此外,命名空间应该在类的开头声明(例如:"using namespace cv;"),或者它应该放在枚举之前(例如:cv::CAP_PROP_FRAME_HEIGHT)。 - Mustafa Kemal

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接