5 Replies Latest reply on Jul 30, 2018 7:10 AM by MartyG

# measuring length of object using depth and rgb frames

Hello, i am wondering what is the best way to measure length or width of objects, using aligned frames of rgb and depth (16 bit grayscale) which i took with sr300 (i have the device so i know its parameters) and that saved on the disk.

I assume that first i need to coordinate the pixels into (x,y,z) and calculate the distance of the object from the camera using the depth frame, but i am not quite sure how to do it.

I know that the sdk offers such methods, but i have to implement them by myself, because i want to do the measuring on frames (tiff format) which i already saved on my disk.

Thank you very much

• ###### 1. Re: measuring length of object using depth and rgb frames

This thread may help with the first part of your problem, getting the frames in the SDK and aligned (which will be probably easier than implementing it all by yourself): upload color and depth images and then align them · Issue #1274 · IntelRealSense/librealsense · GitHub

Once you have the depth and colour aligned you can obtain the point cloud (xyz points), then just calculate the distance between 2 points using Pythagoras.

• ###### 2. Re: measuring length of object using depth and rgb frames

thank you very much for your quick reply, my rgb and depth frames are aligned (i used pyrealsesne2 as in the thread) so i don't need to implement it.

for example, pixel [24,56] with rgb value [100,150,125] is mapped to depth fame`s pixel [24,56] with depth value [1663]

now that i have those aligned frames i am wondering how to use those images to obtain the point cloud using python.

• ###### 3. Re: measuring length of object using depth and rgb frames

Ah right, if you have aligned depth and the intrinsics of the colour camera you can calculate the pointcloud using rs2_deproject_pixel_to_point, the process of which is explained here: Pinhole camera model | Three Constants.

• ###### 4. Re: measuring length of object using depth and rgb frames

thank you very much

• ###### 5. Re: measuring length of object using depth and rgb frames

Hi alover27, you asked a while ago about creating point clouds in Python.  There is a tutorial for this now.