Write Camera video to out.avi
Posted: 06 May 2011 04:02 PM   [ Ignore ]
New Member
Rank
Total Posts:  3
Joined  2011-04-24

Can anyone provide some advice as to how I would utilize the CLEye SDK along with the OpenCV API to write the camera’s video to an avi file?

What I have done so far it to modify the “CLEyeMulticamTest.cpp” file. I’ve changed only the run function:

void Run()
    
{
        int w
h;
        
IplImage *pCapImage;
        
PBYTE pCapBuffer NULL;

        
// init a video writer
        
CvVideoWriter *writer 0;
        
int isColor 1;
        
int fps        30;
        
int frameW    640;
        
int frameH  480;

        
/*writer = cvCreateVideoWriter("out.avi", CV_FOURCC('P','I','M','1'),
                                        fps, cvSize(frameW, frameH), isColor);
        */
        
        
writer cvCreateVideoWriter("out.avi", -1,
                                        
fpscvSize(frameWframeH), isColor);
        
        
// Create camera instance
        
_cam CLEyeCreateCamera(_cameraGUID_mode_resolution_fps);
        if(
_cam == NULL)        return;
        
// Get camera frame dimensions
        
CLEyeCameraGetFrameDimensions(_camwh);
        
// Depending on color mode chosen, create the appropriate OpenCV image
        
if(_mode == CLEYE_COLOR_PROCESSED || _mode == CLEYE_COLOR_RAW)
            
pCapImage cvCreateImage(cvSize(wh), IPL_DEPTH_8U4);
        else
            
pCapImage cvCreateImage(cvSize(wh), IPL_DEPTH_8U1);

        
// Set some camera parameters
        
CLEyeSetCameraParameter(_camCLEYE_GAIN0);
        
CLEyeSetCameraParameter(_camCLEYE_EXPOSURE511);
         
CLEyeSetCameraParameter(_camCLEYE_ZOOM, (int)(GetRandomNormalized()*100.0));
         
CLEyeSetCameraParameter(_camCLEYE_ROTATION, (int)(GetRandomNormalized()*300.0));
        
        
// Start capturing
        
CLEyeCameraStart(_cam);
        
cvGetImageRawData(pCapImage, &pCapBuffer;);
        
// image capturing loop
        
while(_running)
        
{
            CLEyeCameraGetFrame
(_campCapBuffer);

            
cvWriteFrame(writerpCapImage);
            
cvShowImage(_windowNamepCapImage);
        
}
        
// Stop camera capture
        
CLEyeCameraStop(_cam);
        
// Destroy camera object
        
CLEyeDestroyCamera(_cam);
        
// Destroy the allocated OpenCV image
        
cvReleaseImage(&pCapImage;);
        
// release the video writer
        
cvReleaseVideoWriter(&writer;);
        
_cam NULL;
    


Currently, the only way to get the video written to the file is by setting the ‘int fourcc’ parameter of ‘cvCreateVideoWriter’ to -1. I’m then prompted to choose one of the following (please see attached) the only option which writes to the avi file is ‘Full Frames (Uncompressed)’. I’ve tired all other possibilities they result in an empty out.avi file. I’m fine with the avi file being uncompressed, but my goal is to produce two synchronized video files(Already have the VSYNC and FSIN hooked up!). However, when I am prompted each time to selected the compression type there is no way the files will begin at the same time.

Any suggestions? I’m using OpenCv 1.x. The SDK I downloaded said it worked with all revision of 1.x, but not necessarily 2.x. Does anyone even know if the newer release of Opencv provides any more option in this regard?

Thank you.

David A. Wisecup

Image Attachments
prompt.png
Profile
 
 
 
 


RSS 2.0     Atom Feed