Software Archive
Read-only legacy content
17061 Discussions

Saving 1080p image in hard drive

Saif_I_
Beginner
760 Views

I am working on a project where I need to capture high quality images from Intel Realsense F200 cameras. I was able to stream the high resolution color (1920 x 1080) and capture one frame and save it in binary file in the hard disk to be used later with other tools in Matlab.  But I was unable to get the high resolution images as expected; and was finding several block like artifacts in the image. Is it because the captured frames are compressed by default and that's why after saving it on disk, I am getting the compressed version, or it it because of something else?? If I am getting the compressed version of the image, what can be done to uncompress the image and get the full definition image. Please note that I am capturing still images, not the video stream which is supposedly seems to be the common thing.

Any help will be deeply appreciated.

Thanks

Saif.

 

0 Kudos
8 Replies
samontab
Valued Contributor II
760 Views

It sounds like your problem is in the jpg encoding. Try saving the image in a lossless format, like png for example.
 

0 Kudos
Saif_I_
Beginner
760 Views

Hi Samon,

Thanks for the reply. I was not compressing anything during data acquisition, just saving the binary file acquired by locking the image frame. Do you think the camera has already the image jpeg encoded?? Or what else needs to be done to recover the data?? I was using all the required configuration (like USB 3.0 port; so data corruption through transfer does not seem to be the problem as USB 3 can support high speed data transfer). Any other ideas??

 

Saif.

0 Kudos
samontab
Valued Contributor II
760 Views

The camera gives you uncompressed data. When you store it into the disk you can use different formats. Some formats are lossy, which means that you throw away information to save space. Other formats are lossless, which preserve 100% of the original information.

JPG is a lossy format, so if you save a frame to disk as a JPG image you will not get the original pixel values stored in the file but a compressed version of it that looks very similar to the original. The block like artifacts that you see are the result of this compression. There is no way to recover the original information from this JPG file. Well, there is a fun area of image processing called superresolution, but that's another thing.

So, in conclusion, if you only have JPG files with block like artifacts, that's all you have. There is no way for you to get the original image from the compressed JPG. And the camera is totally fine, the problem was the usage of a lossy JPG encoding, probably with a high compression rate, while saving the file. From now on, you will know that you have to save your images to disk using a lossless format, like PNG for example, if you want to keep the original data that came directly from the camera.

0 Kudos
Saif_I_
Beginner
760 Views

Hi Samon,

Thanks for your detailed explanation. Let me share with you the code snippet. I have been developing the data acquisition program using C++ and some OpenCV. So the code snippet follows from that C++ program:

Mat colorMat (cvSize(color.high,color.low),CV_8UC3,(short*)ColorData.planes[0],ColorData.pitches[0]); //

return colorMat;

As you can see, I am using the Mat object of OpenCV to save the image in matrix from the data plane offered by the Intel RealSense Camera. This mat object data is then used to save it in binary file.

imagebin.write(reinterpret_cast<char*>(bgrImage.data),sizeof(unsigned char)*bgrImage.rows*bgrImage.cols*3);

where imagebin is the fstream object used to write binary files in C++.

Do you think by any chance, I am compressing the image to jpg format by these steps??

Once again, any reply will be deeply appreciated.

Thanks

Saif.

 

0 Kudos
samontab
Valued Contributor II
760 Views

colorMat is an uncompressed image. Assuming that you made the conversion from RealSense to OpenCV correctly, everything should be fine here. Check that by using OpenCV to write your image:

cv::imwrite( "uncompressed.png", colorMat );

Look at the uncompressed.png image and post it here to see what the problem is.

0 Kudos
Saif_I_
Beginner
760 Views

https://drive.google.com/file/d/0B9vpBRldeDX2Rmw3SDhTVWtfaG8/view?usp=sharing

 

You will find the image in this link. I did as you told me to do. I write the image from OpenCV imwrite, and obtain this image. I also created the mat object using (uchar*) typecast instead of (short*). If you zoom in the picture, you will see that there are several block like artifacts in the image. Do you think it can be removed??

 

 

0 Kudos
samontab
Valued Contributor II
760 Views

That image is as good as you are going to get.

Keep in mind that the RealSense camera does not use this color camera to generate the 3D structure, so you can always use an external higher quality color image as long as you do your own calibration.

0 Kudos
Saif_I_
Beginner
760 Views

Thanks a lot Samon. I also found that while zooming in, some pixels have abnormal colors (especially at the edges of objects). I believe there are some fringing effects of the camera lens. Anyway, I will keep that in note.

0 Kudos
Reply