imshow显示一片灰色

问题:循环读取视频帧,调用imshow显示一片灰色

        VideoCapture capture("vtest.avi");

	if (!capture.isOpened()) {
		cerr << "Failed to open the video device!\n" << endl;
		return 1;
	}

	Mat frame;
	for (;;) {
		capture >> frame;
		if (frame.empty())
		{
			cerr << "frame is empty!\n" << endl;
			break;
		}
		imshow("video", frame);
	}

原因分析:imshow()之后没有加waitKey(),导致highgui模块没时间处理imshow()的绘制请求。

 

你可能感兴趣的:(opencv)