def get_cloud_image(self, data):
""" Get an image from the cloud """
dta = np.zeros((data.height, data.width), dtype="float32")
dtype = np.dtype('float32')
dtype = dtype.newbyteorder('<')
buf = np.frombuffer(data.data, dtype)
buf = np.resize(buf, (data.width * data.height, 8))
buf = np.compress([True, True, True, True, True, False, False, False],
buf, axis=1)
buf = buf[~np.isnan(buf).any(1)]
for point in buf:
point[3] = 1.0
src = np.asmatrix(point[:4])
src = np.reshape(src, (4, 1))
dst = np.dot(self.p_left, src)
pnt_w = dst[2, 0]
if pnt_w != 0:
img_x = dst[0, 0] / pnt_w
img_y = dst[1, 0] / pnt_w
dta[img_y, img_x] = point[4]
nstr = dta.tostring()
img = np.fromstring(nstr, dtype='uint8')
img.resize(data.height, data.width, 4)
img = np.compress([True, True, True, False], img, axis=2)
return img
评论列表
文章目录