Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Save image, C++

I am trying to save a color image from a SoftKinetic DS311 camera, using OpenCV.

However, the imagefile that is saved is black.

CvCapture *capture = cvCreateCameraCapture(0);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);
cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);

// Get one frame
IplImage* frame;

for (int i = 0; i < 25; i++)
    frame = cvQueryFrame(capture);
printf("Image captured \n");
cvSaveImage("test.jpg", frame);

printf("Image Saved \n");

This is the part of the code that is supposed to save the .jpeg The program is in a function that is called continously in the main loop, so it should not be because the camera is not initialized?