Example #1
0
    def __init__(self, config):
        WriterInterface.__init__(self, config)

        self.rgb_output_key = self.config.get_string("rgb_output_key", "colors")
        self._supercategory = self.config.get_string("supercategory", "coco_annotations")
        self.segmap_output_key = self.config.get_string("segmap_output_key", "segmap")
        self.segcolormap_output_key = self.config.get_string("segcolormap_output_key", "segcolormap")
        self.mask_encoding_format = self.config.get_string("mask_encoding_format", "rle")
        self._append_to_existing_output = self.config.get_bool("append_to_existing_output", False)
Example #2
0
    def __init__(self, config):
        WriterInterface.__init__(self, config)

        # Create CameraWriter to write camera attibutes, use OpenCV coordinates
        self._camera_writer = CameraStateWriter(config)
        self._camera_writer.destination_frame = ["X", "-Y", "-Z"]

        # Parse configuration.
        self.dataset = self.config.get_string("dataset", "")

        self.append_to_existing_output = self.config.get_bool(
            "append_to_existing_output", False)

        # Save world to camera transformation
        self._save_world2cam = self.config.get_bool("save_world2cam", True)

        # Distance in meteres to object after which it is ignored. Mostly due to failed physics.
        self._ignore_dist_thres = self.config.get_float(
            "ignore_dist_thres", 100.)

        # Number of frames saved in each chunk.
        self.frames_per_chunk = 1000

        # Multiply the output depth image with this factor to get depth in mm.
        self.depth_scale = self.config.get_float("depth_scale", 1.0)

        # Output translation gt in mm
        self._scale = 1000. if self.config.get_bool("m2mm", True) else 1.

        # Format of the depth images.
        depth_ext = '.png'

        # Output paths.
        base_path = self._determine_output_dir(False)
        self.dataset_dir = os.path.join(base_path, 'bop_data', self.dataset)
        self.chunks_dir = os.path.join(self.dataset_dir, 'train_pbr')
        self.camera_path = os.path.join(self.dataset_dir, 'camera.json')
        self.rgb_tpath = os.path.join(self.chunks_dir, '{chunk_id:06d}', 'rgb',
                                      '{im_id:06d}' + '{im_type}')
        self.depth_tpath = os.path.join(self.chunks_dir, '{chunk_id:06d}',
                                        'depth', '{im_id:06d}' + depth_ext)
        self.chunk_camera_tpath = os.path.join(self.chunks_dir,
                                               '{chunk_id:06d}',
                                               'scene_camera.json')
        self.chunk_gt_tpath = os.path.join(self.chunks_dir, '{chunk_id:06d}',
                                           'scene_gt.json')

        # Create the output directory structure.
        if not os.path.exists(self.dataset_dir):
            os.makedirs(self.dataset_dir)
            os.makedirs(self.chunks_dir)
        elif not self.append_to_existing_output:
            raise Exception("The output folder already exists: {}.".format(
                self.dataset_dir))
Example #3
0
    def __init__(self, config):
        WriterInterface.__init__(self, config)

        self._avoid_rendering = config.get_bool("avoid_rendering", False)
        self.rgb_output_key = self.config.get_string("rgb_output_key", "colors")
        self._supercategory = self.config.get_string("supercategory", "coco_annotations")
        self.segmap_output_key = self.config.get_string("segmap_output_key", "segmap")
        self.segcolormap_output_key = self.config.get_string("segcolormap_output_key", "segcolormap")
        self._coco_data_dir = os.path.join(self._determine_output_dir(False), 'coco_data')
        if not os.path.exists(self._coco_data_dir):
            os.makedirs(self._coco_data_dir)
Example #4
0
    def __init__(self, config):
        WriterInterface.__init__(self, config)

        # Parse configuration.
        self.dataset = self.config.get_string("dataset")

        self.append_to_existing_output = self.config.get_bool("append_to_existing_output", False)

        # Distance in meteres to object after which it is ignored. Mostly due to failed physics.
        self._ignore_dist_thres = self.config.get_float("ignore_dist_thres", 5.)

        # Number of frames saved in each chunk.
        self.frames_per_chunk = 1000

        # Multiply the output depth image with this factor to get depth in mm.
        self.depth_scale = 0.1

        # Format of the depth images.
        depth_ext = '.png'

        # Output paths.
        base_path = self._determine_output_dir(False)
        self.dataset_dir = os.path.join(base_path, 'bop_data', self.dataset)
        self.chunks_dir = os.path.join(self.dataset_dir, 'train_pbr')
        self.camera_path = os.path.join(self.dataset_dir, 'camera.json')
        self.rgb_tpath = os.path.join(
            self.chunks_dir, '{chunk_id:06d}', 'rgb', '{im_id:06d}' + '{im_type}')
        self.depth_tpath = os.path.join(
            self.chunks_dir, '{chunk_id:06d}', 'depth', '{im_id:06d}' + depth_ext)
        self.chunk_camera_tpath = os.path.join(
            self.chunks_dir, '{chunk_id:06d}', 'scene_camera.json')
        self.chunk_gt_tpath = os.path.join(
            self.chunks_dir, '{chunk_id:06d}', 'scene_gt.json')

        # Create the output directory structure.
        if not os.path.exists(self.dataset_dir):
            os.makedirs(self.dataset_dir)
            os.makedirs(self.chunks_dir)
        elif not self.append_to_existing_output:
            raise Exception("The output folder already exists: {}.".format(
                self.dataset_dir))
Example #5
0
    def __init__(self, config):
        WriterInterface.__init__(self, config)

        # Parse configuration.
        self._dataset = self.config.get_string("dataset", "")

        self._append_to_existing_output = self.config.get_bool(
            "append_to_existing_output", False)

        # Save world to camera transformation
        self._save_world2cam = self.config.get_bool("save_world2cam", True)

        # Distance in meteres to object after which it is ignored. Mostly due to failed physics.
        self._ignore_dist_thres = self.config.get_float(
            "ignore_dist_thres", 100.)

        # Multiply the output depth image with this factor to get depth in mm.
        self._depth_scale = self.config.get_float("depth_scale", 1.0)

        # Output translation gt in mm
        self._mm2m = self.config.get_bool("m2mm", True)
Example #6
0
 def __init__(self, config):
     WriterInterface.__init__(self, config)
     self._avoid_rendering = config.get_bool("avoid_rendering", False)
 def __init__(self, config):
     WriterInterface.__init__(self, config)
     self.object_writer = ItemWriter(self._get_attribute)
 def __init__(self, config):
     WriterInterface.__init__(self, config)
Example #9
0
 def __init__(self, config):
     WriterInterface.__init__(self, config)
     self.object_writer = ItemWriter(WriterUtility.get_cam_attribute)
Example #10
0
 def __init__(self, config):
     WriterInterface.__init__(self, config)
     self._append_to_existing_output = self.config.get_bool("append_to_existing_output", False)
     self._output_dir = self._determine_output_dir(False)
Example #11
0
 def __init__(self, config):
     WriterInterface.__init__(self, config)
     self.light_writer = ItemWriter(WriterUtility.get_light_attribute)
Example #12
0
    def __init__(self, config):
        WriterInterface.__init__(self, config)

        # Create CameraWriter to write camera attibutes, use OpenCV coordinates
        self._camera_writer = CameraStateWriter(config)
        self._camera_writer.destination_frame = ["X", "-Y", "-Z"]

        # Parse configuration.
        self.dataset = self.config.get_string("dataset", "")

        self.append_to_existing_output = self.config.get_bool(
            "append_to_existing_output", True)

        # Save world to camera transformation
        self._save_world2cam = self.config.get_bool("save_world2cam", True)

        # Distance in meteres to object after which it is ignored. Mostly due to failed physics.
        self._ignore_dist_thres = self.config.get_float(
            "ignore_dist_thres", 100.)

        # Multiply the output depth image with this factor to get depth in mm.
        self.depth_scale = self.config.get_float("depth_scale", 1.0)

        # Output translation gt in mm
        self._scale = 1000. if self.config.get_bool("m2mm", False) else 1.

        # Format of the depth images.
        depth_ext = '.png'

        # Debug mode flag
        self._avoid_rendering = config.get_bool("avoid_rendering", False)

        # Output paths.
        base_path = self._determine_output_dir(False)
        self.dataset_dir = os.path.join(base_path, 'data', self.dataset)
        self.camera_path = os.path.join(self.dataset_dir, 'camera.json')
        self.rgb_tpath = os.path.join(self.dataset_dir, '{chunk_id:06d}',
                                      'rgb', '{im_id:06d}' + '{im_type}')
        self.depth_tpath = os.path.join(self.dataset_dir, '{chunk_id:06d}',
                                        'depth', '{im_id:06d}' + depth_ext)
        self.chunk_camera_tpath = os.path.join(self.dataset_dir,
                                               '{chunk_id:06d}',
                                               'scene_camera.json')
        self.foreground_background_objects_tpath = os.path.join(
            self.dataset_dir, '{chunk_id:06d}', 'foreground_background.json')
        self.segmentations_tpath = os.path.join(self.dataset_dir,
                                                '{chunk_id:06d}',
                                                'segmentation',
                                                '{im_id:06d}' + '.png')
        self.segmentations_labels_tpath = os.path.join(
            self.dataset_dir, '{chunk_id:06d}', 'segmentation_labels.csv')
        self.correspondances_tpath = os.path.join(
            self.dataset_dir, '{chunk_id:06d}', 'correspondance',
            'from_{im_id_from:06d}' + '_to_{im_id_to:06d}' + '.png')
        self.semantic_map_tpath = os.path.join(
            self.dataset_dir, '{chunk_id:06d}', 'correspondance_semantic_map',
            'from_{im_id_from:06d}' + '_to_{im_id_to:06d}' + '.png')

        # Create the output directory structure.
        if not os.path.exists(self.dataset_dir):
            os.makedirs(self.dataset_dir)

        elif not self.append_to_existing_output:
            raise Exception("The output folder already exists: {}.".format(
                self.dataset_dir))