Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
492 views
in Technique[技术] by (71.8m points)

python - pyrealsense2 -- 'numpy.ndarray' object has no attribute 'as_depth_frame'

I am using the helper_function Provided by Intel RealSense pyrealsense2 API:

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, x, y, intrinsics)
print(" metric x {}, y{} , z{} and also depth{}".format(x_m, y_m, z_m, depth_val))

And I get this error:

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

Here's the related part from the 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))

My depth_frame shape and type are as follows:

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

I even tried converting the depth_frame to float but didn't work as well. depth_float = original_depth_frame.astype(np.float32)

How should I fix this problem?

question from:https://stackoverflow.com/questions/65947585/pyrealsense2-numpy-ndarray-object-has-no-attribute-as-depth-frame

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...