Ask Your Question
0

display a video code error

asked 2015-06-08 09:43:53 -0600

sarmad gravatar image

HI

I have just started to learn opencv c++

I have written this code to play a video file but the following message is displayed in VC12

can anyone help me please

Regards

opencv.PNG

edit retag flag offensive close merge delete

Comments

AAAAA that is C!!! try to use C++ api ;)

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-06-08 10:46:06 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-06-30 18:54:22 -0600

#include <iostream> // for standard I/O
#include <string>   // for strings

#include <opencv2/core.hpp>        // Basic OpenCV structures (cv::Mat)
#include <opencv2/highgui.hpp>  // Video write

using namespace std;
using namespace cv;

int main(int argc, char *argv[])
{
    const string source = argv[1];           // the source file name

    VideoCapture inputVideo(source);              // Open input
    if (!inputVideo.isOpened())
    {
        cout  << "Could not open the input video: " << source << endl;
        return -1;
    }

    Mat src;

    for(;;) //Show the image in the window and repeat
    {

        inputVideo >> src;              // read

        if (src.empty()) break;         // check if at end
        imshow( source,src );
        if( (waitKey(29) & 255) == 27 ) break; // stop by pressing ESC
    }

    return 0;
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-06-08 09:43:53 -0600

Seen: 240 times

Last updated: Jun 30 '15