OpenCV 3.0.0 + VS 2015 + Windows 10 Pro x64 - frame always empty

asked 2015-08-09 15:36:58 -0600

horothesun gravatar image

Hi all! I built OpenCV 3.0.0 for VS 2015 in Windows 10 Pro x64.

Then I compiled the following code:

#include "opencv2\opencv.hpp"
#include <iostream>

int main(int argc, char** argv)
{
    cv::VideoCapture capture("Vid_A_ball.avi");

    if (! capture.isOpened())
    {
        std::cout << "Video Not Opened" << std::endl;

        std::getchar();
        return -1;
    }

    int width = (int)capture.get(CV_CAP_PROP_FRAME_WIDTH);
    int height = (int)capture.get(CV_CAP_PROP_FRAME_HEIGHT);
    double fps = capture.get(CV_CAP_PROP_FPS);
    int frame_count = (int)capture.get(CV_CAP_PROP_FRAME_COUNT);

    std::cout << "Video Size = " << width << "x" << height << std::endl
              << "FPS = " << fps << std::endl
              << "Total Frames = " << frame_count << std::endl;

    cv::Mat frameReference;

    while (true)
    {
        capture >> frameReference;

        if (frameReference.empty())
        {
            std::cout << "Capture Finished" << std::endl;
            break;
        }
        else
        {
            cv::imshow("video", frameReference);
            cv::waitKey(1000.0f/fps);
        }
    }

    return 0;
}

Video opened correctly, but frameReference.empty() is always true.

TIA, horothesun.

edit retag flag offensive close merge delete

Comments

add this line on top of your code

int main(int argc, char** argv)
{
    std::cout  << cv::getBuildInformation() << std::endl;
    cv::VideoCapture capture("Vid_A_ball.avi");

and check

FFMPEG:                      YES (prebuilt binaries)
sturkmen gravatar imagesturkmen ( 2015-08-09 17:25:19 -0600 )edit

@sturkmen, that is actually an incorrect answer. There are multiple video backend on OpenCV which are checked one by one. So you do not need ffmpeg explicitly if you do not want to use it. As to the error of the user, could you sent us a link to the video so we can debug it?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-08-10 02:27:56 -0600 )edit