解决Realsense相机水平反向经过deproject之后坐标值不准的问题

语言:Python
相机型号:Intel RealSense 435
需求:已知相机像素坐标和深度值求解在相机坐标系下点的三维坐标

depth_sensor = profile.get_device().first_depth_sensor()
depth_scale = depth_sensor.get_depth_scale()
# 得到内参
intr = profile.get_stream(rs.stream.color).as_video_stream_profile().get_intrinsics()
# 得到深度值
depth = depth_image[x, y].astype(float)
depth = depth * depth_scale 
# 得到在相机坐标系下的点坐标值
x, y, z = rs.rs2_deproject_pixel_to_point(intr, [x, y], depth)

需要注意的是:内参值的选择。
如果用的是经过align之后的图片,图片是经过裁剪对齐的,所以内参值其实已经改变了,但是此时相机内部存储的内参值还是之前的值所以这个时候如果intr取的是深度图的内参也就是如果这样写:
intr=profile.get_stream(rs.stream.depth).as_video_stream_profile().get_intrinsics()
得到的坐标值在图片的中心区域可能偏差不大,但是在图片左边坐标值会更偏左,在图片右边会更偏右。

参考:
Github解决:How to get the actual coordinates of a specific target captured by the camera at a certain resolution relative to the camera?

猜你喜欢

转载自blog.csdn.net/weixin_42299076/article/details/102731844