简体   繁体   English

OpenCV / C ++-从视频文件读取的帧在视频结束后重新启动

[英]OpenCV/C++ - frames read from video file restart after end of the video

I'm trying to get each frame from an mp4 video with OpenCV. 我正在尝试使用OpenCV从mp4视频中获取每一帧。 I followed the standard examples but for some reason, when the last frame is read, the loop does not terminate but in fact starts again. 我遵循了标准示例,但是由于某种原因,当读取最后一帧时,循环不会终止,而是实际上再次开始。 Here is the code: 这是代码:

while (1) {
        inputVideo.read(inputFrame);
        nFrames = inputVideo.get(CV_CAP_PROP_POS_FRAMES);
        cout << "Frame: " << nFrames << endl;
        n++;
    }

Why doesn't it stop after all the frames have been processed? 处理完所有帧后为什么不停止?

您可以使用inputVideo.get()来检测框架在文件中的位置,并使用它在结尾处断开

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM