This example save snapshot form the loaded video with a name of current time. Note that this code uses struct tm and time_t for accessing system time. And the code is written for Linux platform. Below is the code.
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include <stdio.h>>
int main(int argc, char *argv[])
{
int i=0;
char image[1000];
cvNamedWindow("mainWin");
CvCapture* capture = cvCreateFileCapture( argv[1]);
if(argv[1]==NULL){
printf("Cannot laod video\n");
return 0;
}
IplImage* frame,*output;
struct tm *local;
time_t t;
printf("Press 's' to save image 'Esc' to exit\n");
while (1)
{
frame = cvQueryFrame( capture );
if ( !frame ) break;
cvShowImage( "mainWin", frame );
char c = cvWaitKey(33);
if (c=='s')
{
t = time(NULL);
local = localtime(&t);
output=cvCreateImage(cvGetSize(frame),8,3);
sprintf(image,"%s.jpg",asctime(local));
cvSaveImage(image,frame);
cvCopy(frame,output);
cvNamedWindow("Result");
cvShowImage("Result",output);
cvReleaseImage(&output);
i++;
}
if ( c == 27 ) break;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "mainWin" );
return 0;
}
Hope these helpful....
can u tell me how to do the same procedure for gray scale video???
ReplyDeleteGray scale video means the video already gray, or you want to save gray scale image of colour video. For the second case you can use cvtColor. Also don't use outdated C, switch to new C++ interface. See Doc
ReplyDeletePokerStars Casino - New York - JtmHub
ReplyDelete› poker-stars-casino › poker-stars-casino PokerStars Casino › 제주도 출장샵 poker-stars-casino PokerStars Casino In New York, you will 상주 출장안마 be able to enjoy more than $100 김제 출장안마 games such as blackjack, 남원 출장마사지 roulette 경산 출장샵 and live dealer poker.