Saving an image in OpenCV

Posted by Sujay Ghosh on Stack Overflow See other posts from Stack Overflow or by Sujay Ghosh
Published on 2009-05-12T08:07:57Z Indexed on 2010/04/18 21:53 UTC
Read the original article Hit count: 351

Filed under:

I am new to OpenCV, and trying to capture an image, and then save it to a file. I am posting the code for your reference, below.

The jpg file is being saved, but it is black.

// Capture the Image from the webcam
CvCapture *pCapturedImage = cvCreateCameraCapture(0);

// Get the frame
IplImage *pSaveImg = cvQueryFrame(pCapturedImage);

// Save the frame into a file
cvSaveImage("test.jpg". ,pSaveImg); // A JPG FILE IS BEING SAVED
                                    // OF 6KB , BUT IT IS BLACK

All of the functions are succesful. I have tried the above code in both XP and Vista - the result is a black image on both. Please let me know what I am missing out.

© Stack Overflow or respective owner

Related posts about opencv