Items with no label
3335 Discussions

How do I get the depth of a specific pixel?

LRahi
Beginner
698 Views

For a computer vision application, we're trying to access the depth of four specific pixels. We tried to do that with several member functions of the "points" class but it didn't work.

 

Thanks for any help!

 

 

// ---Capture a snapshot via realsense   // Declare pointcloud object, for calculating pointclouds and texture mappings rs2::pointcloud pc; // Declare points object rs2::points points; //--Create a Pipeline - this serves as an API for streaming and processing frames rs2::pipeline pipe; //Create a configuration for configuring the pipeline with a non default profile rs2::config cfg; //Add desired streams to configuration cfg.enable_stream(RS2_STREAM_DEPTH, 640, 480, RS2_FORMAT_Z16, 30); //--Configure and start the pipeline pipe.start(cfg); //--Camera warmup - dropping several first frames to let auto-exposure stabilize auto frames = pipe.wait_for_frames(); //--Get one color and one depth frame rs2::frame color_frame = frames.get_color_frame(); rs2::depth_frame depth_fr = frames.get_depth_frame(); // Generate the pointcloud and texture mappings points = pc.calculate(depth_fr); // Tell pointcloud object to map to this color frame pc.map_to(color_frame); // Get depth coordinates and print them auto vertices = points.get_vertices();

 

0 Kudos
1 Solution
MartyG
Honored Contributor III
264 Views

The link below has advice and scripting for getting the depth of a pixel in meters using the frame_get_distance instruction.

 

https://github.com/IntelRealSense/librealsense/wiki/Projection-in-RealSense-SDK-2.0#depth-image-formats

View solution in original post

1 Reply
MartyG
Honored Contributor III
265 Views

The link below has advice and scripting for getting the depth of a pixel in meters using the frame_get_distance instruction.

 

https://github.com/IntelRealSense/librealsense/wiki/Projection-in-RealSense-SDK-2.0#depth-image-formats

Reply