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,
fps, cvSize(frameW, frameH), isColor);
// Create camera instance
_cam = CLEyeCreateCamera(_cameraGUID, _mode, _resolution, _fps);
if(_cam == NULL) return;
// Get camera frame dimensions
CLEyeCameraGetFrameDimensions(_cam, w, h);
// Depending on color mode chosen, create the appropriate OpenCV image
if(_mode == CLEYE_COLOR_PROCESSED || _mode == CLEYE_COLOR_RAW)
pCapImage = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 4);
else
pCapImage = cvCreateImage(cvSize(w, h), IPL_DEPTH_8U, 1);
// Set some camera parameters
CLEyeSetCameraParameter(_cam, CLEYE_GAIN, 0);
CLEyeSetCameraParameter(_cam, CLEYE_EXPOSURE, 511);
CLEyeSetCameraParameter(_cam, CLEYE_ZOOM, (int)(GetRandomNormalized()*100.0));
CLEyeSetCameraParameter(_cam, CLEYE_ROTATION, (int)(GetRandomNormalized()*300.0));
// Start capturing
CLEyeCameraStart(_cam);
cvGetImageRawData(pCapImage, &pCapBuffer;);
// image capturing loop
while(_running)
{
CLEyeCameraGetFrame(_cam, pCapBuffer);
cvWriteFrame(writer, pCapImage);
cvShowImage(_windowName, pCapImage);
}
// 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