import numpy as np
import struct
import matplotlib.pyplot as plt
file = open(r"二进制文件目录", "rb")
imageRead = np.zeros((480,640),np.uint16)
for step in range(0,480):
for step2 in range(0,640):
a = struct.unpack("H",file.read(2))
imageRead[step,step2] = a[0]
file.close()
plt.imshow(imageRead,"gray")
二进制文件为摄像头获取的原始深度byte流直接存储的文件。不同的摄像头预览配置需要相应更改图像尺寸。
C++实现参考:https://blog.csdn.net/u012423865/article/details/77683509