Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

OpenCV 4: 'CAP_PROP_POS_FRAMES' was not declared in this scope

I just installed the latest OpenCV (4.1.2) on a fresh Debian container. I was trying to compile a OpenCV code repo located here. I added the include and link path to the CMakeLists.txt file. I simply removed the CV_ prefix as I'm using OpenCV 4.x now. But I don't know why it still complains. When compiling with make, it complains for the names 'CAP_PROP_POS_FRAMES' was not declared in this scope, similary for CAP_PROP_FRAME_COUNT and CAP_PROP_FPS.

How to solve it?

Full errors:

[ 76%] Built target summengine
[ 80%] Building CXX object CMakeFiles/SimpleVideoSummExample.dir/src/utils/ShotDetector.cc.o
[ 84%] Building CXX object CMakeFiles/SimpleVideoSummExample.dir/src/videoSummarization/SimpleVideoSummarizer.cc.o
/home/Vis-DSS-master/src/utils/ShotDetector.cc: In function 'std::vector<int> shotDetector(cv::VideoCapture&, double, int, int, int)':
/home/Vis-DSS-master/src/utils/ShotDetector.cc:20:51: error: 'CAP_PROP_FPS' was not declared in this scope
     int FRAME_RATE = static_cast<int>(capture.get(CAP_PROP_FPS));
                                                   ^~~~~~~~~~~~
/home/Vis-DSS-master/src/utils/ShotDetector.cc:20:51: note: suggested alternative:
In file included from /usr/local/include/opencv4/opencv2/highgui.hpp:51:0,
                 from /usr/local/include/opencv4/opencv2/highgui/highgui.hpp:48,
                 from /home/Vis-DSS-master/src/utils/ShotDetector.h:12,
                 from /home/Vis-DSS-master/src/utils/ShotDetector.cc:8:
/usr/local/include/opencv4/opencv2/videoio.hpp:137:8: note:   'CAP_PROP_FPS'
        CAP_PROP_FPS            =5, //!< Frame rate.
        ^~~~~~~~~~~~
/home/Vis-DSS-master/src/utils/ShotDetector.cc:29:17: error: 'CAP_PROP_POS_FRAMES' was not declared in this scope
     capture.set(CAP_PROP_POS_FRAMES, 0);
                 ^~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/utils/ShotDetector.cc:29:17: note: suggested alternative:
In file included from /usr/local/include/opencv4/opencv2/highgui.hpp:51:0,
                 from /usr/local/include/opencv4/opencv2/highgui/highgui.hpp:48,
                 from /home/Vis-DSS-master/src/utils/ShotDetector.h:12,
                 from /home/Vis-DSS-master/src/utils/ShotDetector.cc:8:
/usr/local/include/opencv4/opencv2/videoio.hpp:133:8: note:   'CAP_PROP_POS_FRAMES'
        CAP_PROP_POS_FRAMES     =1, //!< 0-based index of the frame to be decoded/captured next.
        ^~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc: In constructor 'SimpleVideoSummarizer::SimpleVideoSummarizer(char*, int, int, int)':
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:20:46: error: 'CAP_PROP_FPS' was not declared in this scope
     frameRate = static_cast<int>(capture.get(CAP_PROP_FPS));
                                              ^~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:20:46: note: suggested alternative:
In file included from /usr/local/include/opencv4/opencv2/highgui.hpp:51:0,
                 from /usr/local/include/opencv4/opencv2/highgui/highgui.hpp:48,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.h:12,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:7:
/usr/local/include/opencv4/opencv2/videoio.hpp:137:8: note:   'CAP_PROP_FPS'
        CAP_PROP_FPS            =5, //!< Frame rate.
        ^~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:21:31: error: 'CAP_PROP_FRAME_COUNT' was not declared in this scope
     videoLength = capture.get(CAP_PROP_FRAME_COUNT) / frameRate;
                               ^~~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:21:31: note: suggested alternative:
In file included from /usr/local/include/opencv4/opencv2/highgui.hpp:51:0,
                 from /usr/local/include/opencv4/opencv2/highgui/highgui.hpp:48,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.h:12,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:7:
/usr/local/include/opencv4/opencv2/videoio.hpp:139:8: note:   'CAP_PROP_FRAME_COUNT'
        CAP_PROP_FRAME_COUNT    =7, //!< Number of frames in the video file.
        ^~~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc: In member function 'void SimpleVideoSummarizer::extractFeatures(double)':
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:34:17: error: 'CAP_PROP_POS_FRAMES' was not declared in this scope
     capture.set(CAP_PROP_POS_FRAMES, 0);
                 ^~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:34:17: note: suggested alternative:
In file included from /usr/local/include/opencv4/opencv2/highgui.hpp:51:0,
                 from /usr/local/include/opencv4/opencv2/highgui/highgui.hpp:48,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.h:12,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:7:
/usr/local/include/opencv4/opencv2/videoio.hpp:133:8: note:   'CAP_PROP_POS_FRAMES'
        CAP_PROP_POS_FRAMES     =1, //!< 0-based index of the frame to be decoded/captured next.
        ^~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc: In member function 'void SimpleVideoSummarizer::playAndSaveSummaryVideo(char*)':
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:252:17: error: 'CAP_PROP_POS_FRAMES' was not declared in this scope
     capture.set(CAP_PROP_POS_FRAMES, 0);
                 ^~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:252:17: note: suggested alternative:
In file included from /usr/local/include/opencv4/opencv2/highgui.hpp:51:0,
                 from /usr/local/include/opencv4/opencv2/highgui/highgui.hpp:48,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.h:12,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:7:
/usr/local/include/opencv4/opencv2/videoio.hpp:133:8: note:   'CAP_PROP_POS_FRAMES'
        CAP_PROP_POS_FRAMES     =1, //!< 0-based index of the frame to be decoded/captured next.
        ^~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:255:82: error: 'CV_FOURCC' was not declared in this scope
         videoWriter = cv::VideoWriter(videoFileSave, CV_FOURCC('X', 'V', 'I', 'D'), static_cast<int>(capture.get(CAP_PROP_FPS)), cv::Size(capture.get(CAP_PROP_FRAME_WIDTH), capture.get(CAP_PROP_FRAME_HEIGHT)));
                                                                                  ^
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:255:114: error: 'CAP_PROP_FPS' was not declared in this scope
         videoWriter = cv::VideoWriter(videoFileSave, CV_FOURCC('X', 'V', 'I', 'D'), static_cast<int>(capture.get(CAP_PROP_FPS)), cv::Size(capture.get(CAP_PROP_FRAME_WIDTH), capture.get(CAP_PROP_FRAME_HEIGHT)));
                                                                                                                  ^~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:255:114: note: suggested alternative:
In file included from /usr/local/include/opencv4/opencv2/highgui.hpp:51:0,
                 from /usr/local/include/opencv4/opencv2/highgui/highgui.hpp:48,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.h:12,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:7:
/usr/local/include/opencv4/opencv2/videoio.hpp:137:8: note:   'CAP_PROP_FPS'
        CAP_PROP_FPS            =5, //!< Frame rate.
        ^~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:255:151: error: 'CAP_PROP_FRAME_WIDTH' was not declared in this scope
         videoWriter = cv::VideoWriter(videoFileSave, CV_FOURCC('X', 'V', 'I', 'D'), static_cast<int>(capture.get(CAP_PROP_FPS)), cv::Size(capture.get(CAP_PROP_FRAME_WIDTH), capture.get(CAP_PROP_FRAME_HEIGHT)));
                                                                                                                                                       ^~~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:255:151: note: suggested alternative:
In file included from /usr/local/include/opencv4/opencv2/highgui.hpp:51:0,
                 from /usr/local/include/opencv4/opencv2/highgui/highgui.hpp:48,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.h:12,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:7:
/usr/local/include/opencv4/opencv2/videoio.hpp:135:8: note:   'CAP_PROP_FRAME_WIDTH'
        CAP_PROP_FRAME_WIDTH    =3, //!< Width of the frames in the video stream.
        ^~~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:255:186: error: 'CAP_PROP_FRAME_HEIGHT' was not declared in this scope
         videoWriter = cv::VideoWriter(videoFileSave, CV_FOURCC('X', 'V', 'I', 'D'), static_cast<int>(capture.get(CAP_PROP_FPS)), cv::Size(capture.get(CAP_PROP_FRAME_WIDTH), capture.get(CAP_PROP_FRAME_HEIGHT)));
                                                                                                                                                                                          ^~~~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:255:186: note: suggested alternative:
In file included from /usr/local/include/opencv4/opencv2/highgui.hpp:51:0,
                 from /usr/local/include/opencv4/opencv2/highgui/highgui.hpp:48,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.h:12,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:7:
/usr/local/include/opencv4/opencv2/videoio.hpp:136:8: note:   'CAP_PROP_FRAME_HEIGHT'
        CAP_PROP_FRAME_HEIGHT   =4, //!< Height of the frames in the video stream.
        ^~~~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:262:90: error: 'cvPoint' was not declared in this scope
                 cv::putText(frame, "Time: " + IntToString(i) + " seconds", cvPoint(30, 30),
                                                                                          ^
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:263:88: error: 'cvScalar' was not declared in this scope
                             cv::FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(200, 200, 250), 1, CV_AA);
                                                                                        ^
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:263:94: error: 'CV_AA' was not declared in this scope
                             cv::FONT_HERSHEY_COMPLEX_SMALL, 0.8, cvScalar(200, 200, 250), 1, CV_AA);
                                                                                              ^~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc: In member function 'void SimpleVideoSummarizer::displayAndSaveSummaryMontage(char*, int)':
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:287:17: error: 'CAP_PROP_POS_FRAMES' was not declared in this scope
     capture.set(CAP_PROP_POS_FRAMES, 0);
                 ^~~~~~~~~~~~~~~~~~~
/home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:287:17: note: suggested alternative:
In file included from /usr/local/include/opencv4/opencv2/highgui.hpp:51:0,
                 from /usr/local/include/opencv4/opencv2/highgui/highgui.hpp:48,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.h:12,
                 from /home/Vis-DSS-master/src/videoSummarization/SimpleVideoSummarizer.cc:7:
/usr/local/include/opencv4/opencv2/videoio.hpp:133:8: note:   'CAP_PROP_POS_FRAMES'
        CAP_PROP_POS_FRAMES     =1, //!< 0-based index of the frame to be decoded/captured next.
        ^~~~~~~~~~~~~~~~~~~
CMakeFiles/SimpleVideoSummExample.dir/build.make:62: recipe for target 'CMakeFiles/SimpleVideoSummExample.dir/src/utils/ShotDetector.cc.o' failed
make[2]: *** [CMakeFiles/SimpleVideoSummExample.dir/src/utils/ShotDetector.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/SimpleVideoSummExample.dir/build.make:86: recipe for target 'CMakeFiles/SimpleVideoSummExample.dir/src/videoSummarization/SimpleVideoSummarizer.cc.o' failed
make[2]: *** [CMakeFiles/SimpleVideoSummExample.dir/src/videoSummarization/SimpleVideoSummarizer.cc.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/SimpleVideoSummExample.dir/all' failed
make[1]: *** [CMakeFiles/SimpleVideoSummExample.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2