简体   繁体   English

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

[英]OpenCV4 error: ‘CV_CAP_PROP_FRAME_WIDTH’ was not declared in this scope

I recently migrated from OpenCV3.3 to the latest version OpenCV4 on my Ubuntu 18.04 LTS. 我最近在Ubuntu 18.04 LTS上从OpenCV3.3迁移到了最新版本的OpenCV4。 I have some persistent issues with the installation. 我的安装存在一些永久性问题。 My installation did not give any errors when I followed this installation tutorial. 遵循安装教程时,我的安装未出现任何错误。 But whenever I include the module opencv2/highgui.hpp in my project, I get problems like below. 但是,每当我在项目中包含模块opencv2/highgui.hpp时,都会遇到如下问题。 This seems to be an issue caused by highgui.hpp when I followed this link. 当我点击链接时,这似乎是由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

Those constants have been changed in name and location in OpenCV for some time now. 这些常量在OpenCV中的名称和位置已经更改了一段时间。

For the capture properties, they no longer begin with CV_ , so remove that prefix from all of them. 对于捕获属性,它们不再以CV_ ,因此请从所有前缀中删除该前缀。 You can find a list of all available capture properties here , note that they all simply start with CAP_PROP_ . 您可以在此处找到所有可用捕获属性的列表,请注意,它们都以CAP_PROP_开头。

The FOURCC code constructor is a method on the VideoWriter class now, so you should use VideoWriter::fourcc(...) . FOURCC代码构造函数现在是VideoWriter类的方法,因此您应该使用VideoWriter::fourcc(...) The docs can be found here . 这些文档可以在这里找到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Opencv-Python cv2.CV_CAP_PROP_FPS错误 - Opencv-Python cv2.CV_CAP_PROP_FPS error AttributeError:模块'cv2.cv.CV_CAP_PROP_FRAME_WIDTH'没有属性'cv' - AttributeError: module 'cv2.cv.CV_CAP_PROP_FRAME_WIDTH' has no attribute 'cv' python opencv cv2.cv.CV_CAP_PROP_FRAME_COUNT得到错误的数字 - python opencv cv2.cv.CV_CAP_PROP_FRAME_COUNT get wrong numbers OpenCV cap.get(cv2.CAP_PROP_FRAME_COUNT)返回-1 - OpenCV cap.get(cv2.CAP_PROP_FRAME_COUNT) returning -1 OpenCV-Python cv2.CV_CAP_PROP_POS_FRAMES 错误 - OpenCV-Python cv2.CV_CAP_PROP_POS_FRAMES error 在opencv python中使用CV_CAP_PROP_POS_FRAMES从视频中获取帧 - get frame from video with CV_CAP_PROP_POS_FRAMES in opencv python opencv`cv2` python模块中缺少CAP_PROP_FRAME_COUNT常量 - CAP_PROP_FRAME_COUNT constant is missing in opencv `cv2` python module 在“如何在Microsoft Visual Studio中使用OpenCV构建应用程序”示例代码中未声明CAP_PROP_FRAME_WIDTH - CAP_PROP_FRAME_WIDTH undeclared in 'How to build applications with OpenCV inside the Microsoft Visual Studio' sample code Opencv VideoCapture 设置 CV_CAP_PROP_POS_FRAMES 不起作用 - Opencv VideoCapture set CV_CAP_PROP_POS_FRAMES not working OpenCV VideoCapture :: get(CV_CAP_PROP_POS_MSEC)返回0 - OpenCV VideoCapture::get(CV_CAP_PROP_POS_MSEC) returns 0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM