Exemplo n.º 1
0
    def _render(self,
                default_prefix: str,
                default_key: str,
                output_key_parameter_name: str = "output_key",
                output_file_prefix_parameter_name: str = "output_file_prefix",
                enable_transparency: bool = False,
                file_format: str = "PNG"):
        """ Renders each registered keypoint.

        :param default_prefix: The default prefix of the output files.
        """
        if self.config.get_bool("render_distance", False):
            RendererUtility.enable_distance_output(
                self._determine_output_dir(),
                self.config.get_string("distance_output_file_prefix",
                                       "distance_"),
                self.config.get_string("distance_output_key", "distance"),
                self.config.get_float("distance_start", 0.1),
                self.config.get_float("distance_range", 25.0),
                self.config.get_string("distance_falloff", "LINEAR"))

        if self.config.get_bool("render_depth", False):
            RendererUtility.enable_depth_output(
                self._determine_output_dir(),
                self.config.get_string("depth_output_file_prefix", "depth_"),
                self.config.get_string("depth_output_key", "depth"))

        if self.config.get_bool("render_normals", False):
            RendererUtility.enable_normals_output(
                self._determine_output_dir(),
                self.config.get_string("normals_output_file_prefix",
                                       "normals_"),
                self.config.get_string("normals_output_key", "normals"))

        if self.config.get_bool("render_diffuse_color", False):
            RendererUtility.enable_diffuse_color_output(
                self._determine_output_dir(),
                self.config.get_string("diffuse_color_output_file_prefix",
                                       "diffuse_"),
                self.config.get_string("diffuse_color_output_key", "diffuse"))

        RendererUtility.set_output_format(
            file_format, enable_transparency=enable_transparency)
        if not self._avoid_output:
            RendererUtility.render(
                self._determine_output_dir(),
                self.config.get_string(output_file_prefix_parameter_name,
                                       default_prefix),
                self.config.get_string(output_key_parameter_name, default_key),
                return_data=False)
Exemplo n.º 2
0
    def _render(self,
                default_prefix,
                default_key,
                output_key_parameter_name="output_key",
                output_file_prefix_parameter_name="output_file_prefix",
                enable_transparency=False,
                file_format="PNG"):
        """ Renders each registered keypoint.

        :param default_prefix: The default prefix of the output files.
        """
        if self.config.get_bool("render_distance", False):
            RendererUtility.enable_distance_output(
                self._determine_output_dir(),
                self.config.get_string("distance_output_file_prefix",
                                       "distance_"),
                self.config.get_string("distance_output_key", "distance"),
                self.config.get_bool("use_mist_distance", True),
                self.config.get_float("distance_start", 0.1),
                self.config.get_float("distance_range", 25.0),
                self.config.get_string("distance_falloff", "LINEAR"))

        if self.config.get_bool("render_normals", False):
            RendererUtility.enable_normals_output(
                self._determine_output_dir(),
                self.config.get_string("normals_output_file_prefix",
                                       "normals_"),
                self.config.get_string("normals_output_key", "normals"))

        RendererUtility.set_output_format(
            file_format, enable_transparency=enable_transparency)
        if not self._avoid_rendering:
            RendererUtility.render(
                self._determine_output_dir(),
                self.config.get_string(output_file_prefix_parameter_name,
                                       default_prefix),
                self.config.get_string(output_key_parameter_name, default_key))
Exemplo n.º 3
0
    height = np.random.uniform(0.5, 2)
    location, _ = point_sampler.sample(height)
    # Sample rotation (fix around X and Y axis)
    euler_rotation = np.random.uniform([1.2217, 0, 0],
                                       [1.2217, 0, 6.283185307])
    cam2world_matrix = MathUtility.build_transformation_mat(
        location, euler_rotation)

    # Check that obstacles are at least 1 meter away from the camera and make sure the view interesting enough
    if CameraValidation.perform_obstacle_in_view_check(
            cam2world_matrix, {"min": 1.0}, bvh_tree
    ) and CameraValidation.scene_coverage_score(cam2world_matrix) > 0.4:
        CameraUtility.add_camera_pose(cam2world_matrix)
        poses += 1
    tries += 1

# activate normal and distance rendering
RendererUtility.enable_normals_output()
RendererUtility.enable_distance_output()
MaterialLoaderUtility.add_alpha_channel_to_textures(blurry_edges=True)

# render the whole pipeline
data = RendererUtility.render()

data.update(
    SegMapRendererUtility.render(Utility.get_temporary_directory(),
                                 Utility.get_temporary_directory(), "class"))

# write the data to a .hdf5 container
WriterUtility.save_to_hdf5(args.output_dir, data)