MCPcopy Create free account
hub / github.com/apple/ml-aspanformer / export_depth_images

Method export_depth_images

tools/SensorData.py:78–91  ·  view source on GitHub ↗
(self, output_path, image_size=None, frame_skip=1)

Source from the content-addressed store, hash-verified

76
77
78 def export_depth_images(self, output_path, image_size=None, frame_skip=1):
79 if not os.path.exists(output_path):
80 os.makedirs(output_path)
81 print 'exporting', len(self.frames)//frame_skip, ' depth frames to', output_path
82 for f in range(0, len(self.frames), frame_skip):
83 depth_data = self.frames[f].decompress_depth(self.depth_compression_type)
84 depth = np.fromstring(depth_data, dtype=np.uint16).reshape(self.depth_height, self.depth_width)
85 if image_size is not None:
86 depth = cv2.resize(depth, (image_size[1], image_size[0]), interpolation=cv2.INTER_NEAREST)
87 #imageio.imwrite(os.path.join(output_path, str(f) + '.png'), depth)
88 with open(os.path.join(output_path, str(f) + '.png'), 'wb') as f: # write 16-bit
89 writer = png.Writer(width=depth.shape[1], height=depth.shape[0], bitdepth=16)
90 depth = depth.reshape(-1, depth.shape[1]).tolist()
91 writer.write(f, depth)
92
93 def export_color_images(self, output_path, image_size=None, frame_skip=1):
94 if not os.path.exists(output_path):

Callers 1

mainFunction · 0.95

Calls 1

decompress_depthMethod · 0.80

Tested by

no test coverage detected