我正在尝试从用鼠标单击的像素中提取深度数据。它在我打印 X,Y 坐标时起作用。当我尝试打印像素深度数据时它不起作用。我尝试使用的代码是从如何为单击的像素提取 RGB 值的修改。我遇到的问题是如何解析出要打印的深度数据。当我运行它时,我得到 TypeError: 'NoneType' object is not subscriptable 有什么想法吗?
这是代码:
kinect = PyKinectRuntime.PyKinectRuntime(PyKinectV2.FrameSourceTypes_Depth)
while True:
# --- Getting frames and drawing
if kinect.has_new_depth_frame():
frame = kinect.get_last_depth_frame()
frameD = kinect.get_last_depth_frame()
frameD = kinect._depth_frame_data
#frameD = frame.astype(np.uint8)
frame = frame.astype(np.uint8)
frame = np.reshape(frame, (424, 512))
output = cv2.cvtColor(frame, cv2.COLOR_GRAY2BGR)
def click_event(event, x, y, flags, param):
if event == cv2.EVENT_LBUTTONDOWN:
print(x, y)
if event == cv2.EVENT_RBUTTONDOWN:
Pixel_Depth = output[x, y , 1]
print(Pixel_Depth)
#output = cv2.bilateralFilter(output, 1, 150, 75)
cv2.imshow('KINECT Video Stream', output)
cv2.setMouseCallback('KINECT Video Stream', click_event)
output = None
key = cv2.waitKey(1)