I have an Intel Lidar L515 and have recorded a ROS message through realsense-viewer with default settings on Windows.
I am interested in the depth message: /device_0/sensor_0/Depth_0/image/data.
I have subscribed to the ROS sensor_msg::Image topic in C++, and am converting to an opencv image using cv_bridge. I'm trying to use the opencv at function with char, and am getting a lot of 7's, and many values from 168-190. I'm focused on the light green square in the middle, which is at 1.28 meters. The most common hex value when my mouse moves over it in the realsense-viewer is 0x1410.
The specs say the image data is Z16, and the data represents distance from the sensor. I have an object at 1.28 meters and the range of the sensor is 9 meters, though I don't think I have values beyond 2.5 as I'm in a relatively small room.
A code example of what I'm doing is:
void callback( const sensor_msgs::ImageConstPtr &depthImage, cv::Point upperLeft, cv::Point lowerRight )
{
cv::Mat depthImage_cv = ( cv_bridge::toCvCopy( depthImage, depthImage->encoding ) )->image;
for(int row = upperLeft.x; row <= lowerRight.x; row++)
{
for(int column = upperLeft.y; column <= lowerRight.y; column++)
{
float depth = depthImage_cv.at<uchar>(row,column);
ROS_INFO_STREAM("Depth char value: " << depth);
}
}
}
Here is an example image in the realsense-viewer, which shows a 0-4 scale:

I know what distance my object is. I want to know how to find what pixel value it should be at if it accurately detects that object. Any help or insight is appreciated!