Getting individual frames using CV_CAP_PROP_POS_FRAMES in cvSetCaptureProperty

前端 未结 5 964
天命终不由人
天命终不由人 2020-12-15 09:00

I am trying to jump to a specific frame by setting the CV_CAP_PROP_POS_FRAMES property and then reading the frame like this:

cvSetCapturePropert         


        
5条回答
  •  佛祖请我去吃肉
    2020-12-15 09:06

    I don't know whether or not this would be precise enough for your purpose, but I've had success getting to a particular point in an MPEG video by grabbing the frame rate, converting the frame number to a time, then advancing to the time. Like so:

    cv::VideoCapture sourceVideo("/some/file/name.mpg");
    double frameRate = sourceVideo.get(CV_CAP_PROP_FPS);
    double frameTime = 1000.0 * frameNumber / frameRate;
    sourceVideo.set(CV_CAP_PROP_POS_MSEC, frameTime);
    

提交回复
热议问题