#include "opencv2/opencv.hpp"
#pragma comment (lib , "opencv_core244d.lib")
#pragma comment (lib ,"opencv_highgui244d.lib")
#pragma comment(lib , "opencv_imgproc244d.lib")
int main(int argc, char* argv[])
{
CvCapture* capture = cvCaptureFromFile("try.avi");
IplImage* frame = NULL;
do
{
frame = skipNFrames(capture, 1);
cvNamedWindow("frame", CV_WINDOW_AUTOSIZE);
cvShowImage("frame", frame);
cvWaitKey(0);
} while( frame != NULL );
cvReleaseCapture(&capture);
cvDestroyWindow("frame");
cvReleaseImage(&frame);
return 0;
}
This is my program to get frames from the video , but when i run this program , it works , it show me the video , but its not saving the frames automatically (without using any button or mouse) , which should save in my directory
To save each frame individually,
#include<stdio.h>
Declare a global variable
int flag=0;
add following code just below to cvWaitKey(0) :
char *str=new char[50];
flag++;
sprintf(str,"%d",flag);
strcat(str," frame");
strcat(str,".jpg");
Mat image=frame;
imwrite(str,image);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With