VideoCapture acquiring an image frame of a video

int main(void)
{
    Capture VideoCapture ( " F: \\ 1.avi " ); // This is an error in the implementation of embedded devices, moved on a computer with no errors VS, 
    IF (! Capture.isOpened ())
    {
        printf("fail to open 1.avi\n");
    }
long totalFrameNumber = capture.get(CV_CAP_PROP_FRAME_COUNT); printf("total frame number is:%f\n", totalFrameNumber); long frameToStart = 1; capture.set(CV_CAP_PROP_POS_FRAMES, frameToStart); long frameToStop = 1000; double rate = capture.get(CV_CAP_PROP_FPS); printf("rate is :%d\n", rate); bool stop = false; Mat frame; int delay = 1000 / rate; long currentFrame = frameToStart; char path[20] = {}; int imageNum = 0; while (!stop) { if (!capture.read(frame)) { printf("get frame fail!\n"); return -1; } sprintf(path, "F:\\%d.jpg", imageNum); imageNum ++ ; // save the acquired frame data imwrite (path, Frame);
IF (the currentFrame> frameToStop) { stop = true; } currentFrame++; } capture.release(); return 0; }

 

Guess you like

Origin www.cnblogs.com/cumtchw/p/11956844.html