When we have IplImage , how can we save it so that we can use it later or view it as an image outside our code (for example, via png or jpeg)?
As an example of code, I have the following:
void SaveImage() { CvSize size; IplImage *rgb_img; int i = 0; size.height = HEIGHT; size.width = WIDTH; rgb_img = cvCreateImageHeader(size, IPL_DEPTH_8U, 3); rgb_img->imageData = my_device.ColorBuffer; rgb_img->imageDataOrigin = rgb_img->imageData; /*for (i = 2; i < rgb_img->imageSize; i+= 3) { // confirming all values print correctly printf("%d, ", rgb_img->imageData[i]); }*/ cvSaveImage("foo.png",rgb_img); }
I printed all the values ββin the loop of commented out loops, and it seems that the data is in the buffer correctly. Using cvShowImage to display an image also works correctly, so the image structure seems to be in order.
vapo
source share