Code
Code
h" int main() { IplImage* myimage; int RGBstep,i,j; int RGBchannels; int Height, Width,count; FILE *imgfile; char fname[10],fname1[10]; unsigned char temp1,temp2,temp3; int key = 0; CvCapture* capture = cvCaptureFromAVI("a.avi"); count=0; while( key != 'x' ) { myimage = cvQueryFrame( capture ); count++; if( !myimage ) break; cvNamedWindow("Smile", 1); cvMoveWindow("Smile", 100, 100); cvShowImage("Smile", myimage); Height = myimage -> height; Width = myimage -> width; RGBstep = myimage ->widthStep; RGBchannels = myimage -> nChannels; sprintf(fname1,"Img%d.txt",count); imgfile = fopen(fname1,"w"); for ( i = 0; i < Height; i++) for (j = 0; j < Width; j++)
{ temp1 = (unsigned char) (myimage -> imageData[i*RGBstep+j*RGBchannels+ 0]); temp2 = (unsigned char) (myimage -> imageData[i*RGBstep+j*RGBchannels+ 1]); temp3 = (unsigned char) (myimage -> imageData[i*RGBstep+j*RGBchannels+ 2]); fprintf(imgfile,"i = %d j =%d B= %d G =%d R=%d \n",i,j,temp1,temp2,tem p3); } fclose(imgfile); sprintf(fname,"Frame%d.jpg",count); cvSaveImage(fname,myimage); } cvWaitKey(0); cvDestroyWindow( "Smile" ); cvReleaseImage( &myimage ); return 0; } **Matlab code** vid = VideoReader('C:\Users\hano\Documents\Visual Studio 2008\Projects\Getframe\ Getframe\a.avi'); for i=1:vid.NumberOfFrames img = read(vid,i); figure; imshow(img); end