6

OpenCV program to capture 30 frames from a video

 1 year ago
source link: https://gist.github.com/rakesh-gopal/f960721b105aaaee18fb
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

OpenCV program to capture 30 frames from a video · GitHub

Instantly share code, notes, and snippets.

OpenCV program to capture 30 frames from a video

Author

Full program to save frames in a video

You can use cvQueryFrame to get frames from the video, like this:

CvCapture *capture = cvCaptureFromAVI(argv[1]);
frame = cvQueryFrame(capture);

Also get the frames_per_second using:

int fps = (int) cvGetCaptureProperty(capture, CV_CAP_PROP_FPS);

Once you know the FPS, you can calculate the number of frames in 30 seconds:

int num_frames = NUM_SECONDS * fps;

Now repeatedly call cvQueryFrame in a loop, num_frames times, to get all the frames in 30 seconds. Then save each of the frame in the same loop:

cvSaveImage(filename, frame);

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK