-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Difference in depth value when calculated using get_distance() vs multiplying depth pixel value with depth scale #8150
Comments
I see even if one doesn't convert the depth frame to cv Mat and directly calculate the distance by multiplying depth scale and the pixel value of depth frame there is a variation in the distance measurement. code snip :
o/p snip : depth distance: 3.155 |
@sandeshk1 , the issue is within these lines: uint16_t* dp_data = (uint16_t*)depth.get_data();
uint16_t dp_pixel = dp_data[100,100]; Casting uint16_t* dp_data = (uint16_t*)depth.get_data();
uint16_t dp_pixel = dp_data[100 * w + 100]; With OpenCV the matrix dimensions are specified explicitly, but since the outcome is similar to results obtained in C++ then I'd suggest to check it again. |
@ev-mp, thanks a lot for the quick reply. My bad treating the 1-D buffer as though it was a 2-D array. With your recommendation I was able to get the correct distance value. So basically the index for the 1-D array should be "pixels's y-coordinate * width + pixel's x-coordinate" is it ? Could you explain a bit more on this solution for my understanding. |
@sandeshk1 , it is correct. |
@ev-mp Thanks for the explanation. Closing this thread as the solution was provided |
Issue Description
PFA below code snippet:
I had obtained depth distance from the depth frame for pixel co-ordinates (100,100). And then I am creating a cv Mat frame out of the depth frames's bytes data. Now I am trying to get the depth distance by multiplying the depth scale value with the depth pixel value of the converted cv Mat depth frame.
I am noticing a diff in the calculated depth distances. Why is this so ?
PFA o/p logs:
depth distance: 3.056
depth_scale: 0.001
depth distance from converted cv Mat frame: 2.35
depth distance: 3.07
depth_scale: 0.001
depth distance from converted cv Mat frame: 2.318
depth distance: 3.14
depth_scale: 0.001
depth distance from converted cv Mat frame: 2.279
depth distance: 3.14
depth_scale: 0.001
depth distance from converted cv Mat frame: 2.358
depth distance: 3.042
depth_scale: 0.001
depth distance from converted cv Mat frame: 2.264
The text was updated successfully, but these errors were encountered: