OpenCV4 错误:'CV_CAP_PROP_FRAME_WIDTH' 未在此范围内声明

Aru*_*mar 6 opencv highgui opencv4

我最近在我的 Ubuntu 18.04 LTS 上从 OpenCV3.3 迁移到了最新版本的 OpenCV4。我在安装过程中遇到了一些持续的问题。当我按照安装教程进行安装时,我的安装没有出现任何错误。但是每当我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_BLUR’
                       CV_FOURCC('M', 'J', 'P', 'G'), 10,
                       ^~~~~~~~~
                       CV_BLUR
Run Code Online (Sandbox Code Playgroud)

alk*_*asm 13

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

对于捕获属性,它们不再以 开头CV_,因此从所有这些属性中删除该前缀。您可以在此处找到所有可用捕获属性的列表,请注意,它们都只是以CAP_PROP_.

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