Ask Your Question
2

OpenCV 2.4.3 VideoCapture not working on *.avi file input

asked 2012-12-11 04:48:06 -0500

I am running two openCV versions on my system: - Visual Studio 2010 - Windows 7 x64 - OpenCV 2.3.1 and OpenCV 2.4.3 running - Using precompiled .lib and .dll files for my system

Im trying to compare GPU functionality between CPU and GPU performance. However, using the VideoCapture C++ interface for reading frame by frame, doesn't work anymore in version 2.4.3. Reading a frame and directly displaying it into a named window, results in a blank screen. No errors are produced but the frame isn't correctly imported and seems to be corrupt.

Anyone has an idea on what could be the problem?

Code to recreate the exact problem:

// Input path of video file
std::string path = "D:\\outputVideo\\outputVideo.avi";
VideoCapture capture(path);
Mat frame;
// Retrieve a single frame from the capture
capture.read(frame);
// Display the frame
imshow(window_name, frame);
// Wait until key is pressed, before closing the window
int c = waitKey(0);
edit retag flag offensive close merge delete

Comments

add capture.isOpened() assert

Victor1234 gravatar imageVictor1234 ( 2012-12-14 13:40:44 -0500 )edit

3 answers

Sort by ยป oldest newest most voted
1

answered 2012-12-17 02:26:14 -0500

Already fixed it - seemed problem with using video CPU reading and then processing on GPU. When reading and processing using solely GPU functionality, it works!

edit flag offensive delete link more

Comments

Hi, I'm using processing the images by ocl functions and I have the same problem. But there is no video reader implemented by for ocl! what's your idea?

MohammadShafiei gravatar imageMohammadShafiei ( 2015-06-23 00:52:52 -0500 )edit
-1

answered 2013-06-11 08:21:36 -0500

Hope this answer can help you, I Had the same pbm with video with 100fps. I converted them to 50fps and it worked

edit flag offensive delete link more

Comments

This comment actually added zero extra value to the solution. I already indicated in the post this topic that it was solved, no reason to add extra comments :) It just makes it more unclear for others.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-06-13 08:07:17 -0500 )edit
1

answered 2012-12-14 08:50:51 -0500

ubehagelig gravatar image

Do you only want to read a single frame? Otherwise do something along these lines:

    int main() {

    Mat frame;
    string path = "D:\\outputVideo\\outputVideo.avi";
    VideoCapture capture(path); 
    namedWindow("my_window");

    for(;;) {
    capture >> frame;
    imshow("my_window", frame);

    if(cv::waitKey(30) >= 0) break;
    }
}
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2012-12-11 04:48:06 -0500

Seen: 11,021 times

Last updated: Jun 11 '13