Problem reading a video file with OpenCV

asked 2014-11-26 04:34:57 -0500

Hi all, I want to read a video file (.avi) but it is imposible. I've been searching a lot through the forums and no solution helps me :(

The code is this:

#include "playvideo.h"
#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdio.h>
#include <iostream>

using namespace cv;
using namespace std;


int playVideo::displayVideo() {

   VideoCapture cap("../DisplayVideo/people1.mp4");

    try {
        if(!cap.isOpened()) {
            cout << "error" << endl;

    } catch (cv::Exception e) {
       cout << e.err << endl;


    namedWindow("w", 1);

    while (true) {
        Mat frame;
        cap >> frame;
        imshow("w", frame);

    return 0;

And the error I get always is:

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in unknown function, file /home/.../opencv/modules/highgui/src/window.cpp, line 261

Thanks in advance! Anyone knows what is the problem?


edit retag flag offensive close merge delete