我正在尝试从用鼠标单击的像素中提取深度数据。当我打印X,Y坐标时,它可以工作。我尝试打印像素深度数据时它不起作用。Im尝试使用的代码是对如何为单击的像素提取RGB值进行的修改。我的问题是如何解析出要打印的深度数据。当我运行此命令时,我收到TypeError:'NoneType'对象无法下标 有什么想法吗?
这是代码:
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)
答案 0 :(得分:0)
要使其正常工作,我必须指定像素编号,而不是“ frameD = kinect._depth_frame_data”的x,y坐标
这是代码:
FROM python:3
RUN apt-get update && \
apt-get install -y openjdk-8-jdk-headless && \
rm -rf /var/lib/apt/lists/*
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY my_script.py ./
CMD [ "python", "./my_script.py" ]