def reconstruction_case(self, scene_name, scene, camera, projector, viewport, projector_lods): color, depth = self.render(scene, camera, viewport) self.dump_debug_img(Path(scene_name) / "scene_color.png", color) self.dump_debug_img(Path(scene_name) / "scene_depth.png", support.array_to_grayscale(depth)) central_line_processor = CentralLineExtractionProcessor(debug_enabled=self.with_debug_output()) reconstructor = ReconstructionBuilder(line_extraction_processor=central_line_processor) self.register_releasable(projector) for i in range(projector_lods): projector.stripes_number = 2 ** i scene.set_projector(projector) color, depth = self.render(scene, camera, viewport) self.dump_debug_img(Path(scene_name) / "{}_color.png".format(i), color) reconstructor.process_observation(i, color) points_3d = reconstructor.build_point_cloud(projector, camera) if self.with_debug_output(): subdir = Path(scene_name) / "central_line" self.dump_debug_matrix_by_hue( subdir / "is_edge_pixel.png", central_line_processor._debug_last_values["is_edge_pixel"] ) self.dump_debug_matrix_by_hue( subdir / "distance.png", central_line_processor._debug_last_values["distance"] ) self.dump_debug_matrix_by_hue( subdir / "is_maximum.png", central_line_processor._debug_last_values["is_maximum"] ) ply.write_ply(self.debug_dir() / scene_name / "points.ply", points_3d)
def _make_screenshot_and_save(self): w, h = 2048, int(2048 * self._camera.aspect) logger.info('Making screenshot... ({}x{})'.format(w, h)) renderer = ImageRenderer(self._gl_executor) color, depth = yield from renderer.render(self.scene, self._camera, (w, h)) filename = 'screenshot' next_id = 2 while Path(filename).exists(): filename = 'screenshot{}'.format(next_id) next_id += 1 color_name, depth_name = filename + '.png', filename + '_depth.png' logger.info('Saving screenshot to {}, {}...'.format(color_name, depth_name)) yield from self._io_async_executor.map(support.save_image, color_name, np.uint8(color)) yield from self._io_async_executor.map(support.save_image, depth_name, support.array_to_grayscale(depth)) yield from renderer.release()
def reconstruction_case(self, scene_name, scene, camera, projector, viewport, projector_lods): color, depth = self.render(scene, camera, viewport) self.dump_debug_img(Path(scene_name) / "scene_color.png", color) self.dump_debug_img( Path(scene_name) / "scene_depth.png", support.array_to_grayscale(depth)) central_line_processor = CentralLineExtractionProcessor( debug_enabled=self.with_debug_output()) reconstructor = ReconstructionBuilder( line_extraction_processor=central_line_processor) self.register_releasable(projector) for i in range(projector_lods): projector.stripes_number = 2**i scene.set_projector(projector) color, depth = self.render(scene, camera, viewport) self.dump_debug_img( Path(scene_name) / "{}_color.png".format(i), color) reconstructor.process_observation(i, color) points_3d = reconstructor.build_point_cloud(projector, camera) if self.with_debug_output(): subdir = Path(scene_name) / 'central_line' self.dump_debug_matrix_by_hue( subdir / 'is_edge_pixel.png', central_line_processor._debug_last_values['is_edge_pixel']) self.dump_debug_matrix_by_hue( subdir / 'distance.png', central_line_processor._debug_last_values['distance']) self.dump_debug_matrix_by_hue( subdir / 'is_maximum.png', central_line_processor._debug_last_values['is_maximum']) ply.write_ply(self.debug_dir() / scene_name / 'points.ply', points_3d)
def _make_screenshot_and_save(self): w, h = 2048, int(2048 * self._camera.aspect) logger.info('Making screenshot... ({}x{})'.format(w, h)) renderer = ImageRenderer(self._gl_executor) color, depth = yield from renderer.render(self.scene, self._camera, (w, h)) filename = 'screenshot' next_id = 2 while Path(filename).exists(): filename = 'screenshot{}'.format(next_id) next_id += 1 color_name, depth_name = filename + '.png', filename + '_depth.png' logger.info('Saving screenshot to {}, {}...'.format( color_name, depth_name)) yield from self._io_async_executor.map(support.save_image, color_name, np.uint8(color)) yield from self._io_async_executor.map( support.save_image, depth_name, support.array_to_grayscale(depth)) yield from renderer.release()