Hi,
I am trying to work to get the depth of the center pixel using the sample tutorial that’s provided by the ZED. I have a doubt about the depth values I am getting as output
protected:
void depthCallback(const sensor_msgs::msg::Image::SharedPtr msg) {
// Get a pointer to the depth values casting the data
// pointer to floating point
float* depths = (float*)(&msg->data[0]);
// Image coordinates of the center pixel
int u = msg->width / 2;
int v = msg->height / 2;
// Linear index of the center pixel
int centerIdx = u + msg->width * v;
// Output the measure
RCLCPP_INFO(get_logger(), "Center distance : %g m", depths[centerIdx]);
}
Above is the code that takes the center pixel and outputs as depth but when I try to echo the depth topic I only see the values from 0-255 which are grayscale values.
I am not understanding how did they convert those values to depth or distance in m.
Thanks in advance for your help.