我有以下代码。我试图将从Kinect v1检索到的16位深度图像保存为png文件。我编写了以下代码示例:
def display_depth(dev, data, timestamp):
global keep_runningp
#cv2.imshow('Depth', frame_convert2.pretty_depth_cv(data))
cv2.imshow('Depth', frame_convert2.pretty_depth_cv(data))
print type(data)
print data.shape
depthf.write(repr(timestamp)+" Depth/"+repr(timestamp)+".png\n")
namef="Sample_dataset/Depth/"+repr(timestamp)+".png"
cv2.imwrite(namef,frame_convert2.pretty_depth(data))
if cv2.waitKey(10) == 27:
keep_running = False
当我添加以下代码(将数据从16位无符号的NumPy数组转换为8位无符号的NumPy数组)时,它起作用:
depth = depth.astype(np.uint8)
没有这一行,我只是得到整个空白/白色png图像。但是我需要一个16位的png文件。
如何将其保存为16位png文件?
虽然我的数据是这样的
解决方案,我的问题是在代码中添加这一行
相关问题 更多 >
编程相关推荐