[英]cvQueryFrame(capture) always returns null
Does anyone know why I keep getting null frames? 有谁知道为什么我不断收到空帧? I tried skipping the first five and still null.
我尝试跳过前五个,但仍然为null。
int _tmain(int argc, char** argv)
{
CvCapture *capture = cvCaptureFromFile(argv[1]);
int fps = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);
IplImage* frame;
cvNamedWindow("video", CV_WINDOW_AUTOSIZE);
while(1)
{
frame = cvQueryFrame(capture);
if(!frame)
break;
cvShowImage("video", frame);
char c = cvWaitKey(1000/fps);
if(c == 33)
break;
}
cvReleaseCapture( &capture);
cvDestroyWindow( "video" );
return 0;
}
Video file must UNCOMPRESSED avi! 视频文件必须未压缩avi! So actually I was getting null frames because cvCapture returned a null because my input video file was not uncompressed.
所以实际上我得到的是空帧,因为cvCapture返回了空值,因为我的输入视频文件未解压缩。
I use your code for test, then it run well with 'xvid' format video. 我使用您的代码进行测试,然后在“ xvid”格式的视频中运行良好。 I think OpenCV 'capture' function maybe process some popular and old format of videos.
我认为OpenCV的“捕获”功能可能会处理一些流行和较旧的视频格式。 Video with format "H264" may be not work.
格式为“ H264”的视频可能无法正常工作。
When cvCaptureFromFile()
fails it returns NULL
, and I suspect it is failing: 当
cvCaptureFromFile()
失败时,它返回NULL
,我怀疑它失败了:
CvCapture *capture = cvCaptureFromFile(argv[1]);
if (!capture)
{
// print error, quit application
}
It usually fails for one of these reasons: either it can't find the file, or OpenCV doesn't know how to open it. 通常由于以下原因之一而失败:它找不到文件,或者OpenCV不知道如何打开它。 For instance,
.mkv
files are not supported by OpenCV. 例如,OpenCV不支持
.mkv
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.