我正在使用openCV将视频分割成多个帧。为此,我需要fps和时长。通过cvGetCaptureProperty查询时,这两个值都返回1。
我使用AVURLAsset来获取fps和时长,但当我将其与openCV结合使用时,我只能得到部分视频。它看起来像是丢失了帧。
这是我现在的代码:
while (cvGrabFrame(capture)) {
    frameCounter++;
    if (frameCounter % (int)(videoFPS / MyDesiredFramesPerSecond) == 0) {
      IplImage *frame = cvCloneImage(cvRetrieveFrame(capture));
      // Do Stuff     
    }
    if (frameCounter > duration*fps)
    break; // this is here because the loop never stops on its own
}如何在iOS上使用openCV获取视频的所有帧?(opencv 2.3.2)
发布于 2012-04-22 18:43:54
根据documentation,您应该检查cvRetrieveFrame()返回的值,如果返回空指针,则表示位于视频序列的末尾。然后在发生这种情况时中断循环,而不是依赖于FPS*frame_number的准确性。
https://stackoverflow.com/questions/10267197
复制相似问题