Connecting Tech Pros Worldwide Forums | Help | Site Map

C++ avi player - Open CV

Newbie
 
Join Date: Mar 2008
Posts: 1
#1: Mar 10 '08
Hello all,

I have been having some problems with using Open CV to play an avi file.

I am currently creating a eye input based system, where the mouse is replaced by an eye tracker. I am currently working on flat .csv files, and importing the coordinates then using those coordinates to do various tasks on the screen.

These coordinates have been recorded using a real eye tracker which creates two files, a .csv file of the coordinates of they eye movement and an avi file.

In essence what i am trying to achieve is to run the video in tandem with my self created code for the processing of the moues movements.

I have been advised to use Open CV for this, however i cannot seem to find a tutorial that shows me how to process an avi file and play it. This is very frustrating as i have seen many people comment on the ease of OpenCV yet i can't find any examples which aren't overly complicated! The file in question is named "test_00003.avi"

Leaving my rant behind :) I was hoping i may be able to open my question to a wider audience who may be able to help me in understanding how to create a simple, full screen avi player.

Kind Regards,
David


PS for additional information, I am currently using XP, Using Visual C++

Here is my code that i have attempted to make work :D

Expand|Select|Wrap|Line Numbers
  1.         CvCapture* capture = 0;
  2.     IplImage *frame, *frame_copy = 0;
  3.     static CvMemStorage* storage = cvCreateMemStorage(0);
  4.  
  5.     capture = cvCaptureFromAVI( "test_00003.avi" );
  6.  
  7.     cvNamedWindow( "Picture:", 1 );
  8.  
  9.     if( capture )
  10.     {
  11.         for(;;)
  12.         {
  13.             if( !cvGrabFrame( capture ))
  14.                 break;
  15.             frame = cvRetrieveFrame( capture );
  16.             if( !frame )
  17.                 break;
  18.             if( !frame_copy )
  19.                 frame_copy = cvCreateImage(
  20. cvSize(frame->width,frame->height),
  21.                                             IPL_DEPTH_8U,
  22. frame->nChannels );
  23.             if( frame->origin == IPL_ORIGIN_TL )
  24.                 cvCopy( frame, frame_copy, 0 );
  25.             else
  26.                 cvFlip( frame, frame_copy, 0 );
  27.  
  28.             cvShowImage("Picture:",frame_copy);
  29.  
  30.             // Varying this will vary the speed of the avi file
  31.             if( cvWaitKey( 20 ) >= 0 )
  32.                 break;
  33.         }
  34.  
  35.         cvReleaseImage( &frame_copy );
  36.         cvReleaseCapture( &capture );
  37.     }
  38.  
  39.     cvClearMemStorage( storage );   
  40.     cvDestroyWindow("Picture:");
  41. }
  42.  

Reply