Looks like a truncation problem to me.
You are multiplying the values in depth_img
by 0.001, which means the numbers are getting converted to floating point and then back to int16_t
in the assignment process. This means that any values less than 1000 in depth_img
will be truncated to zero in depth_img_meters
Any time you are dealing with different data types you have to watch out for errors associated with this sort of implicit conversion during assignment.