Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

PNG compression is computationally expensive. If this is a bottleneck of your application, you should choose another file format (like TIFF, which is read faster and can store 8 bit and 16 bit data, so it's well suited to store RGB-D data) or even uncompressed raw data.

Writing/reading RAW data is something like this (in pure C, can be adapted to other languages):

cv::Mat imgRGB,imgD;
//...acquire the images...
FILE *fptr;
fptr = fopen("imageRGB.dat","wb");
fwrite(imgRGB.ptr(0),3,imgRGB.cols*imgRGB.rows,fptr);
fclose(fptr);
fptr = fopen("imageD.dat","wb");
fwrite(imgD.ptr(0),2,imgD.cols*imgD.rows,fptr);
fclose(fptr);