Software Archive
Read-only legacy content
17061 Discussions

Relate the depth value with real world value(meters,centimeters,millimeters)

himanshu_p_
Beginner
492 Views

Hi,
I have Intel RealSense Camera F200,Object is placed around 1/2 meter distance from camera.
I am able to get the depth value via using "PIXEL_FORMAT_DEPTH_F32".
CodeSnippet:-
 sts = senseMgr.AcquireFrame(true);  
                
                if (sts == pxcmStatus.PXCM_STATUS_NO_ERROR)
                {
                     PXCMCapture.Sample sample = senseMgr.QuerySample();  
                    
                
                    if (sample.depth != null)
                    {       
                       PXCMImage.ImageData dData = new PXCMImage.ImageData();
                        sample.depth.AcquireAccess(PXCMImage.Access.ACCESS_READ,PXCMImage.PixelFormat.PIXEL_FORMAT_DEPTH_F32, dData);
                        if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR)<0)
                        {
                            System.out.println ("Failed to AcquireAccess of depth image data");
                            System.exit(3);
                        }
                        
                        int dBuff[] = new int[dData.pitches[0]/4 * dHeight];
                     
                        dData.ToIntArray(0, dBuff);

The values which i am getting is of order 10 example:-"1136884736"
How to relate this value with real world value? As camera is only at a distance of 1/2 meter from the object.

 

Regards,

Himanshu

0 Kudos
4 Replies
Xusheng_L_Intel
Employee
492 Views

If you use PIXEL_FORMAT_DEPTH_F32, the depth map data in 32-bit floating point. The value precision is in millimeters. Looks like the value you got is not the right one. Please found our sample C# code @C:\Program Files (x86)\Intel\RSSDK\framework\CSharp\DF_RawStreams.cs. Thanks!

0 Kudos
kfind1
New Contributor I
492 Views

You are converting a float32 to an int. Of course it will come out incorrect. Try reading the values in as floats and when you print to stdout, also make sure the formatting is for %f (so the value is printed as a float not interpreted as an int)

0 Kudos
himanshu_p_
Beginner
492 Views

thanks for your prompt reply kyran......we got the code running based on your comment.....

0 Kudos
kfind1
New Contributor I
492 Views

himanshu p. wrote:

thanks for your prompt reply kyran......we got the code running based on your comment.....

 

Great! Glad I could help. I am new to this forum, and what is funny is I can't even get my SDK to install yet!

0 Kudos
Reply