stereolabs / zed-gstreamer

Package of GStreamer elements to interface with ZED Cameras
https://www.stereolabs.com/docs/gstreamer/
61 stars 23 forks source link

[Question] trying to get distances from Depth image of zedsrc #30

Closed gitwavelet closed 3 years ago

gitwavelet commented 3 years ago

Hi, This is my brief pipe flow using zedsrc and zeddemux.

zedsrc - zeddemux - src_left - queue - autovideoconvert - xvimagesink => OK |

When displaying the depth image (gray16_le), it was also almost black screen. I saw your answer that it's because the depth data is "not normalized float value". When using SDK ZED_Depth_Viewer at the same camera facing, distance values seem good.

According to your code, the gray16_le is guint16 casted. (float -> guint32 -> guint16) Do I need any extra (normalizing) process to extract the distance from the map?

Here is my appsink_new_sample_callback used to check values.

sample = gst_app_sink_pull_sample(sink); if (sample) { buffer = gst_sample_get_buffer(sample); gst_buffer_map( buffer, &info, (GstMapFlags)(GST_MAP_READ) ); data = info.data; size = info.size; g_print ("%ld (%dx%d)\n", size, width, height); memcpy(depth_map, data, size); for(i=0; i<10; i++) { g_print ("%d (%d,%d)\n", depth_map[width(height2+i) + width2], width2, height2+i); g_print ("%d (%d,%d)\n", depth_map[widthheight2 + (width2+i)], width2+i, height2); }
g_print ("\n"); gst_buffer_unmap(buffer, &info); gst_sample_unref(sample); }

Thanks

gitwavelet commented 3 years ago

I just added these two lines before setting runtime parameters as in the tutorial of the depth sensing. And I could get non-zero values.

sl::RuntimeParameters runtime_parameters; src->zedRtParams = runtime_parameters; GST_INFO("CAMERA RUNTIME PARAMETERS");

Myzhar commented 3 years ago

@gitwavelet if this modification fixes a bug, can you please open a pull request with it?