user2035796
user2035796

Reputation: 67

program to read and display opencv video not working properly

I have written this video to display a video in OpenCV-2.4.2 using CodeBlocks. So far the file compiles fine but the video doesn't seem to be playing and the showing plus the display window is so small, all I see are the minimize, maximize and close buttons. Below is my code can anyone be of help? Thanks.

     using namespace cv;
     using namespace std;

     void info()
     {
         cout << "This program will accept input video with fixed lengths and produce video textures" << endl;
     }

     int main(int argc, char *argv[])
     {
         info();
         if(argc != 2)
         {
            cout << "Please enter more parameters" << endl;
            return -1;

         }

         const string source = argv[1];
         VideoCapture input_vid(source);
         if(! input_vid.isOpened())
         {
           cout << "Error: Could not find input video file" << source << endl;
           return -1;
         }

         const char* PLAY = "Video player";

         namedWindow(PLAY, 0);
         setWindowProperty(PLAY, CV_WND_PROP_AUTOSIZE,CV_WINDOW_AUTOSIZE);

         for(;;)
         {
           Mat frame;
           input_vid >> frame;
         }

          return 0;
    }

Upvotes: 0

Views: 291

Answers (1)

sfotiadis
sfotiadis

Reputation: 977

You need to push the frame to the window

imshow(PLAY, frame);

Upvotes: 3

Related Questions