| 51 | |
| 52 | |
| 53 | def load(self, filename): |
| 54 | with open(filename, 'rb') as f: |
| 55 | version = struct.unpack('I', f.read(4))[0] |
| 56 | assert self.version == version |
| 57 | strlen = struct.unpack('Q', f.read(8))[0] |
| 58 | self.sensor_name = ''.join(struct.unpack('c'*strlen, f.read(strlen))) |
| 59 | self.intrinsic_color = np.asarray(struct.unpack('f'*16, f.read(16*4)), dtype=np.float32).reshape(4, 4) |
| 60 | self.extrinsic_color = np.asarray(struct.unpack('f'*16, f.read(16*4)), dtype=np.float32).reshape(4, 4) |
| 61 | self.intrinsic_depth = np.asarray(struct.unpack('f'*16, f.read(16*4)), dtype=np.float32).reshape(4, 4) |
| 62 | self.extrinsic_depth = np.asarray(struct.unpack('f'*16, f.read(16*4)), dtype=np.float32).reshape(4, 4) |
| 63 | self.color_compression_type = COMPRESSION_TYPE_COLOR[struct.unpack('i', f.read(4))[0]] |
| 64 | self.depth_compression_type = COMPRESSION_TYPE_DEPTH[struct.unpack('i', f.read(4))[0]] |
| 65 | self.color_width = struct.unpack('I', f.read(4))[0] |
| 66 | self.color_height = struct.unpack('I', f.read(4))[0] |
| 67 | self.depth_width = struct.unpack('I', f.read(4))[0] |
| 68 | self.depth_height = struct.unpack('I', f.read(4))[0] |
| 69 | self.depth_shift = struct.unpack('f', f.read(4))[0] |
| 70 | num_frames = struct.unpack('Q', f.read(8))[0] |
| 71 | self.frames = [] |
| 72 | for i in range(num_frames): |
| 73 | frame = RGBDFrame() |
| 74 | frame.load(f) |
| 75 | self.frames.append(frame) |
| 76 | |
| 77 | |
| 78 | def export_depth_images(self, output_path, image_size=None, frame_skip=1): |