def decode_depth_map(self, raw):
raw = zlib.decompress(base64.urlsafe_b64decode(raw + self.make_padding(raw)))
pos = 0
(header_size, num_planes, pano_width, pano_height, plane_indices_offset) = struct.unpack('<BHHHB', raw[0:8])
self.depthHeader = {'numPlanes': num_planes, 'panoWidth': pano_width, 'panoHeight': pano_height}
if header_size != 8 or plane_indices_offset != 8:
print("Invalid depthmap data")
return
pos += header_size
self.depthMapIndices = [x for x in raw[plane_indices_offset:plane_indices_offset + (pano_width * pano_height)]]
pos += len(self.depthMapIndices)
self.depthMapPlanes = []
for i in range(0, num_planes):
(nx, ny, nz, d) = struct.unpack('<ffff', raw[pos:pos + 16])
self.depthMapPlanes.append(
{'d': d, 'nx': nx, 'ny': ny, 'nz': nz}) # nx/ny/nz = unit normal, d = distance from origin
pos += 16
评论列表
文章目录