读取和显示opencv视频的程序工作不正常

program to read and display opencv video not working properly

本文关键字:程序 工作 不正常 视频 显示 opencv 读取      更新时间:2023-10-16

我编写此视频是为了使用CodeBlocks在OpenCV-2.4.2中显示视频。到目前为止,文件编译得很好,但视频似乎没有播放,显示加上显示窗口太小,我看到的只是最小化、最大化和关闭按钮。下面是我的代码,有人能帮忙吗?谢谢

     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;
    }

您需要将框架推到窗口

imshow(PLAY, frame);