Ask Your Question

Revision history [back]

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

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.