微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

pyrealsense2 -- 'numpy.ndarray' 对象没有属性 'as_depth_frame'

如何解决pyrealsense2 -- 'numpy.ndarray' 对象没有属性 'as_depth_frame'

我正在使用英特尔实感 pyrealsense2 API 提供的 helper_function

from helper_functions import get_depth_at_pixel,convert_depth_pixel_to_metric_coordinate



depth_val= get_depth_at_pixel(depth_frame,x,y)
x_m,y_m,z_m = convert_depth_pixel_to_metric_coordinate(depth_val,y,intrinsics)
print(" metric x {},y{},z{} and also depth{}".format(x_m,z_m,depth_val))

我收到此错误

'numpy.ndarray' object has no attribute 'as_depth_frame'

这是 helper_functions.py 中的相关部分:

def get_depth_at_pixel(depth_frame,pixel_x,pixel_y):
        """
        Get the depth value at the desired image point

        Parameters:
        -----------
        depth_frame      : rs.frame()
                                                   The depth frame containing the depth information of the image coordinate
        pixel_x                          : double
                                                   The x value of the image coordinate
        pixel_y                          : double
                                                        The y value of the image coordinate

        Return:
        ----------
        depth value at the desired pixel

        """
        return depth_frame.as_depth_frame().get_distance(round(pixel_x),round(pixel_y))

我的depth_frame形状和类型如下:

<class 'numpy.ndarray'>
(720,1280)

我什至尝试将 depth_frame 转换为浮动,但效果不佳。 depth_float = original_depth_frame.astype(np.float32)

我应该如何解决这个问题?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。