13

I recently migrated from OpenCV3.3 to the latest version OpenCV4 on my Ubuntu 18.04 LTS. 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. This seems to be an issue caused by highgui.hpp when I followed this link.

/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
Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
Arun Kumar
  • 634
  • 2
  • 12
  • 26
  • 2
    OpenCV 3.4 is *not* OpenCV 4. There is no "AKA." OpenCV has both versions, and they are separate. – alkasm Jun 13 '19 at 02:53

1 Answers1

23

Those constants have been changed in name and location in OpenCV for some time now.

For the capture properties, they no longer begin with CV_, so remove that prefix from all of them. You can find a list of all available capture properties here, note that they all simply start with CAP_PROP_.

The FOURCC code constructor is a method on the VideoWriter class now, so you should use VideoWriter::fourcc(...). The docs can be found here.

alkasm
  • 22,094
  • 5
  • 78
  • 94
  • In addition to that, namespace should be stated at start of the class(Ex: "using namespace cv;") or it should be put before the enum (Ex: cv::CAP_PROP_FRAME_HEIGHT). – Mustafa Kemal Mar 02 '23 at 10:52