我编写此视频是为了使用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);