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