Items with no label
3335 Discussions

Locate nearest object with R200

TKirv1
New Contributor II
1,344 Views

Hello,

I am hoping to use the R200 camera to determine the position of the nearest object in the camera frame. In theory this should be easy using the "points" data, and this is what I've tried;

float dist,min_dist;

min_dist = 5;

float px,py,pz;

auto points = reinterpret_cast(dev.get_frame_data(rs::stream::points));

for(int y=0; y

{

for(int x=0; x

{

if(points->z) //if(uint16_t d = *depth++)

{

dist = sqrt(points->x*points->x+points->y*points->y+points->z*points->z);

if (dist

min_dist = dist;

px = points->x;

py = points->y;

pz = points->z;

}

}

++points;

}

}

}

printf("object position = %f, %f, %f \n",px,py,pz);

However plotting px vs time, py vs time, pz vs time shows very noisy results even when the camera FOV is empty except for a single visible objects at a fixed position.

For example if I put an object 1 meter in from of the camera .2 meters up and .2 meters to the left and left it stationary, I would expect the time vs px,py,pz graphs to reflect this clearly, but they do not.

Is there something obvious I am doing wrong or expecting the camera to do something it's not capable of?

Thanks,

Thomas

0 Kudos
5 Replies
idata
Employee
433 Views

Hi Thomas,

Thanks for your interest in the Intel® Realsense™ Platform.

Personally, I don't have too much experience in determining the nearest object in front of the camera. Nevertheless, I did some research and found the Blob Tracking algorithm https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?doc_blob_blob_tracking.html Intel® RealSense™ SDK 2016 R2 Documentation which allows you to detect objects in front of the camera, I would encourage to use the Sample BlobViewer as a reference in order to detect the nearest object in front of the camera.

By the way I found this thread , where the user MartyG recommends the function SetDSMinMaxZ() in order to reduce the noise from the R200 data. Maybe it will be useful to you.

I hope you find this information useful, have a nice day!

Best Regards,

 

-Jose P.
0 Kudos
TKirv1
New Contributor II
433 Views

Thanks for the info Jose!

Unfortunately I am using a linux machine so I can't use the Realsense SDK. I will see if there is something similar in the librealsense library.

Best,

Thomas

0 Kudos
MartyG
Honored Contributor III
433 Views

Here's a documentation page about depth in Librealsense.

https://github.com/IntelRealSense/librealsense/blob/master/doc/projection.md librealsense/projection.md at master · IntelRealSense/librealsense · GitHub

0 Kudos
idata
Employee
433 Views

Hi Thomas,

 

 

I see, yes the SDK documentation won't be useful to you. I would encourage you to follow the documentation shared by MartyG. Also, if you are able to determine the nearest object in the camera frame, we would appreciate if you share your results, since they would be useful for other members of the community.

 

 

Have a great day!

 

 

Best Regards,

 

-Jose P.
0 Kudos
TKirv1
New Contributor II
433 Views

I'll be sure to do that! I have found that the applying the depth preset

apply_depth_control_preset(&dev,5);

Reduces much of the noise in the depth map, which makes the simple algorithm I posted work a little better.

-Thomas

0 Kudos
Reply