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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…