From 40fc9e8bc2265b582e563a81b819e5c74ace1cfe Mon Sep 17 00:00:00 2001 From: Timo Korthals Date: Sat, 1 Jun 2024 01:15:20 +0200 Subject: [PATCH 01/14] Add fisheye cameras Signed-off-by: Timo Korthals --- syclops/blender/sensors/camera.py | 55 +++++++++++++------ .../blender/sensors/schema/camera.schema.yaml | 8 ++- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/syclops/blender/sensors/camera.py b/syclops/blender/sensors/camera.py index ea27cf8..2b3c6ed 100644 --- a/syclops/blender/sensors/camera.py +++ b/syclops/blender/sensors/camera.py @@ -16,9 +16,7 @@ class Camera(SensorInterface): def setup_sensor(self): self.create_camera() # Create self.objs - for obj in self.objs: - if obj.get().type == "CAMERA": - cam = obj.get() + cam = self.get_camera() cam["name"] = self.config["name"] if "depth_of_field" in self.config: cam.data.dof.use_dof = True @@ -30,9 +28,7 @@ def create_frustum_pyramid(self): """Create sensor's frustum as pyramid""" # Get cam object - for obj in self.objs: - if obj.get().type == "CAMERA": - cam = obj.get() + cam = self.get_camera() cam_matrix = cam.matrix_world.normalized() scene = bpy.context.scene @@ -131,6 +127,11 @@ def create_frustum(self): """Create sensor's frustum""" if "frustum" in self.config: if self.config["frustum"]["enabled"]: + if self.get_camera() != "PERSP": + logging.warning( + "Camera: create_frustum not supported for non-perspective cameras" + ) + return if self.config["frustum"]["type"] == "pyramid": self.create_frustum_pyramid() else: @@ -150,9 +151,7 @@ def render_outputs(self): scene.render.resolution_x = self.config["resolution"][0] scene.render.resolution_y = self.config["resolution"][1] # Set camera as active camera - for obj in self.objs: - if obj.get().type == "CAMERA": - cam = obj.get() + cam = self.get_camera() scene.camera = cam if cam.data.dof.use_dof: @@ -215,7 +214,23 @@ def create_camera(self): camera_data = bpy.data.cameras.new(name=self.config["name"]) # Initial camera settings - camera_data.lens = utility.eval_param(self.config["focal_length"]) + + lense_type = utility.eval_param(self.config["lense_type"]) + if lense_type == "PERSPECTIVE": + camera_data.type = "PERSP" + camera_data.lens = utility.eval_param(self.config["focal_length"]) + elif lense_type == "FISHEYE_EQUIDISTANT": + camera_data.type = "PANO" + camera_data.cycles.panorama_type = "FISHEYE_EQUIDISTANT" + camera_data.fisheye_fov = utility.eval_param(self.config["fisheye_fov"]) + elif lense_type == "FISHEYE_EQUISOLID": + camera_data.type = "PANO" + camera_data.cycles.panorama_type = "FISHEYE_EQUISOLID" + camera_data.lens = utility.eval_param(self.config["focal_length"]) + camera_data.fisheye_fov = utility.eval_param(self.config["fisheye_fov"]) + else: + raise ValueError("Camera: not supported lense type \"%s\"", lense_type) + camera_data.sensor_width = utility.eval_param(self.config["sensor_width"]) camera_object = bpy.data.objects.new(self.config["name"], camera_data) @@ -274,7 +289,11 @@ def get_camera_matrix(self, camera): numpy.array: The camera matrix """ if camera.type != "PERSP": - raise ValueError("Non-perspective cameras not supported") + logging.warning( + "Camera: get_camera_matrix not supported for non-perspective cameras" + ) + return Matrix(((1, 0, 0), (0, 1, 0), (0, 0, 1))) + scene = bpy.context.scene f_in_mm = camera.lens resolution_x_in_px = self.config["resolution"][0] @@ -324,9 +343,7 @@ def get_camera_pose(camera): def write_intrinsics(self): """Write the camera intrinsics to a file""" - for obj in self.objs: - if obj.get().type == "CAMERA": - cam = obj.get() + cam = self.get_camera() curr_frame = bpy.context.scene.frame_current cam_name = cam["name"] calibration_folder = ( @@ -370,9 +387,7 @@ def write_intrinsics(self): def write_extrinsics(self): """Write the camera extrinsics to a file""" - for obj in self.objs: - if obj.get().type == "CAMERA": - cam = obj.get() + cam = self.get_camera() curr_frame = bpy.context.scene.frame_current cam_name = cam["name"] @@ -415,3 +430,9 @@ def write_extrinsics(self): writer.data["expected_steps"] = utility.get_job_conf()["steps"] writer.data["sensor"] = cam_name writer.data["id"] = cam_name + "_extrinsics" + + def get_camera(self): + for obj in self.objs: + if obj.get().type == "CAMERA": + return obj.get() + raise Exception("'self' has no object 'CAMERA'.") diff --git a/syclops/blender/sensors/schema/camera.schema.yaml b/syclops/blender/sensors/schema/camera.schema.yaml index cf640e1..40281ed 100644 --- a/syclops/blender/sensors/schema/camera.schema.yaml +++ b/syclops/blender/sensors/schema/camera.schema.yaml @@ -16,12 +16,18 @@ items: type: integer maxItems: 2 minItems: 2 + lense_type: + description: Lense type (PERSPECTIVE [default],FISHEYE_EQUISOLID,FISHEYE_EQUIDISTANT) + type: string focal_length: - description: Focal length of the camera in mm. + description: Focal length of the camera in mm. Only effects lense_type=(PERSPECTIVE,FISHEYE_EQUISOLID). $ref: "#/definitions/number_evaluation" sensor_width: description: Width of the sensor in mm. $ref: "#/definitions/number_evaluation" + fisheye_fov: + description: Horizontal angular field of view in rad. Only effects lense_type=(FISHEYE_EQUIDISTANT,FISHEYE_EQUISOLID). + type: number exposure: description: Exposure offset in stops. $ref: "#/definitions/number_evaluation" From 2b9d6d9906c2e49c0ae587b4d8213dbee336db07 Mon Sep 17 00:00:00 2001 From: Timo Korthals Date: Sat, 1 Jun 2024 01:54:17 +0200 Subject: [PATCH 02/14] Fix fisheye parameters for cycles Signed-off-by: Timo Korthals --- syclops/blender/sensors/camera.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/syclops/blender/sensors/camera.py b/syclops/blender/sensors/camera.py index 2b3c6ed..c447446 100644 --- a/syclops/blender/sensors/camera.py +++ b/syclops/blender/sensors/camera.py @@ -127,7 +127,7 @@ def create_frustum(self): """Create sensor's frustum""" if "frustum" in self.config: if self.config["frustum"]["enabled"]: - if self.get_camera() != "PERSP": + if self.get_camera().data.type != "PERSP": logging.warning( "Camera: create_frustum not supported for non-perspective cameras" ) @@ -213,21 +213,25 @@ def create_camera(self): # Place Camera in scene camera_data = bpy.data.cameras.new(name=self.config["name"]) - # Initial camera settings + # Set lense type and use "PERSPECTIVE" as default + if "lense_type" in self.config: + lense_type = utility.eval_param(self.config["lense_type"]) + else: + lense_type = "PERSPECTIVE" - lense_type = utility.eval_param(self.config["lense_type"]) + # Initial camera settings if lense_type == "PERSPECTIVE": camera_data.type = "PERSP" camera_data.lens = utility.eval_param(self.config["focal_length"]) elif lense_type == "FISHEYE_EQUIDISTANT": camera_data.type = "PANO" camera_data.cycles.panorama_type = "FISHEYE_EQUIDISTANT" - camera_data.fisheye_fov = utility.eval_param(self.config["fisheye_fov"]) + camera_data.cycles.fisheye_fov = utility.eval_param(self.config["fisheye_fov"]) elif lense_type == "FISHEYE_EQUISOLID": camera_data.type = "PANO" camera_data.cycles.panorama_type = "FISHEYE_EQUISOLID" - camera_data.lens = utility.eval_param(self.config["focal_length"]) - camera_data.fisheye_fov = utility.eval_param(self.config["fisheye_fov"]) + camera_data.cycles.fisheye_lens = utility.eval_param(self.config["focal_length"]) + camera_data.cycles.fisheye_fov = utility.eval_param(self.config["fisheye_fov"]) else: raise ValueError("Camera: not supported lense type \"%s\"", lense_type) From 8ff0fffbf8497567ffb1701bae50b8d10659bd84 Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Wed, 5 Jun 2024 16:07:23 +0200 Subject: [PATCH 03/14] chore: Update camera.schema.yaml with enum for lense_type and $ref for fisheye_fov --- syclops/blender/sensors/schema/camera.schema.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syclops/blender/sensors/schema/camera.schema.yaml b/syclops/blender/sensors/schema/camera.schema.yaml index 40281ed..3fddb3c 100644 --- a/syclops/blender/sensors/schema/camera.schema.yaml +++ b/syclops/blender/sensors/schema/camera.schema.yaml @@ -19,6 +19,7 @@ items: lense_type: description: Lense type (PERSPECTIVE [default],FISHEYE_EQUISOLID,FISHEYE_EQUIDISTANT) type: string + enum: [PERSPECTIVE,FISHEYE_EQUISOLID,FISHEYE_EQUIDISTANT] focal_length: description: Focal length of the camera in mm. Only effects lense_type=(PERSPECTIVE,FISHEYE_EQUISOLID). $ref: "#/definitions/number_evaluation" @@ -27,7 +28,7 @@ items: $ref: "#/definitions/number_evaluation" fisheye_fov: description: Horizontal angular field of view in rad. Only effects lense_type=(FISHEYE_EQUIDISTANT,FISHEYE_EQUISOLID). - type: number + $ref: "#/definitions/number_evaluation" exposure: description: Exposure offset in stops. $ref: "#/definitions/number_evaluation" From c7944e00116aaa0a30a2753f8ac4a542ec50a845 Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Wed, 5 Jun 2024 16:08:36 +0200 Subject: [PATCH 04/14] chore: Update camera.py to use "lens" instead of "lense" and fix typo in error message --- syclops/blender/sensors/camera.py | 16 ++++++++-------- .../blender/sensors/schema/camera.schema.yaml | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/syclops/blender/sensors/camera.py b/syclops/blender/sensors/camera.py index c447446..e76583e 100644 --- a/syclops/blender/sensors/camera.py +++ b/syclops/blender/sensors/camera.py @@ -213,27 +213,27 @@ def create_camera(self): # Place Camera in scene camera_data = bpy.data.cameras.new(name=self.config["name"]) - # Set lense type and use "PERSPECTIVE" as default - if "lense_type" in self.config: - lense_type = utility.eval_param(self.config["lense_type"]) + # Set lens type and use "PERSPECTIVE" as default + if "lens_type" in self.config: + lens_type = utility.eval_param(self.config["lens_type"]) else: - lense_type = "PERSPECTIVE" + lens_type = "PERSPECTIVE" # Initial camera settings - if lense_type == "PERSPECTIVE": + if lens_type == "PERSPECTIVE": camera_data.type = "PERSP" camera_data.lens = utility.eval_param(self.config["focal_length"]) - elif lense_type == "FISHEYE_EQUIDISTANT": + elif lens_type == "FISHEYE_EQUIDISTANT": camera_data.type = "PANO" camera_data.cycles.panorama_type = "FISHEYE_EQUIDISTANT" camera_data.cycles.fisheye_fov = utility.eval_param(self.config["fisheye_fov"]) - elif lense_type == "FISHEYE_EQUISOLID": + elif lens_type == "FISHEYE_EQUISOLID": camera_data.type = "PANO" camera_data.cycles.panorama_type = "FISHEYE_EQUISOLID" camera_data.cycles.fisheye_lens = utility.eval_param(self.config["focal_length"]) camera_data.cycles.fisheye_fov = utility.eval_param(self.config["fisheye_fov"]) else: - raise ValueError("Camera: not supported lense type \"%s\"", lense_type) + raise ValueError("Camera: not supported lens type \"%s\"", lens_type) camera_data.sensor_width = utility.eval_param(self.config["sensor_width"]) diff --git a/syclops/blender/sensors/schema/camera.schema.yaml b/syclops/blender/sensors/schema/camera.schema.yaml index 3fddb3c..2947176 100644 --- a/syclops/blender/sensors/schema/camera.schema.yaml +++ b/syclops/blender/sensors/schema/camera.schema.yaml @@ -16,18 +16,18 @@ items: type: integer maxItems: 2 minItems: 2 - lense_type: - description: Lense type (PERSPECTIVE [default],FISHEYE_EQUISOLID,FISHEYE_EQUIDISTANT) + lens_type: + description: Lens type (PERSPECTIVE [default],FISHEYE_EQUISOLID,FISHEYE_EQUIDISTANT) type: string enum: [PERSPECTIVE,FISHEYE_EQUISOLID,FISHEYE_EQUIDISTANT] focal_length: - description: Focal length of the camera in mm. Only effects lense_type=(PERSPECTIVE,FISHEYE_EQUISOLID). + description: Focal length of the camera in mm. Only effects lens_type=(PERSPECTIVE,FISHEYE_EQUISOLID). $ref: "#/definitions/number_evaluation" sensor_width: description: Width of the sensor in mm. $ref: "#/definitions/number_evaluation" fisheye_fov: - description: Horizontal angular field of view in rad. Only effects lense_type=(FISHEYE_EQUIDISTANT,FISHEYE_EQUISOLID). + description: Horizontal angular field of view in rad. Only effects lens_type=(FISHEYE_EQUIDISTANT,FISHEYE_EQUISOLID). $ref: "#/definitions/number_evaluation" exposure: description: Exposure offset in stops. From da5a42dfe4e8e4ed82314956fe9c2adbf1d336e7 Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Wed, 5 Jun 2024 16:14:44 +0200 Subject: [PATCH 05/14] Update camera.py to allow for dynamic change of lens parameter during job --- syclops/blender/sensors/camera.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/syclops/blender/sensors/camera.py b/syclops/blender/sensors/camera.py index e76583e..598c618 100644 --- a/syclops/blender/sensors/camera.py +++ b/syclops/blender/sensors/camera.py @@ -167,9 +167,22 @@ def render_outputs(self): cam.data.dof.focus_distance, ) + if "lens_type" in self.config: + lens_type = utility.eval_param(self.config["lens_type"]) + else: + lens_type = "PERSPECTIVE" + # Set camera settings - cam.data.lens = utility.eval_param(self.config["focal_length"]) cam.data.sensor_width = utility.eval_param(self.config["sensor_width"]) + if lens_type == "PERSPECTIVE": + cam.data.lens = utility.eval_param(self.config["focal_length"]) + elif lens_type == "FISHEYE_EQUIDISTANT": + cam.data.cycles.fisheye_fov = utility.eval_param(self.config["fisheye_fov"]) + elif lens_type == "FISHEYE_EQUISOLID": + cam.data.cycles.fisheye_lens = utility.eval_param(self.config["focal_length"]) + cam.data.cycles.fisheye_fov = utility.eval_param(self.config["fisheye_fov"]) + else: + raise ValueError("Camera: not supported lens type \"%s\"", lens_type) if "motion_blur" in self.config: if self.config["motion_blur"]["enabled"]: From 6610c00e33bb9308d8a06e34f16856f51c9536e8 Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Mon, 6 Jan 2025 13:57:12 +0100 Subject: [PATCH 06/14] Add fisheye camera configuration and update schema for lens types --- .../__example_assets__/test_job.syclops.yaml | 16 +++++++++++++++- .../blender/sensors/schema/camera.schema.yaml | 18 +++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/syclops/__example_assets__/test_job.syclops.yaml b/syclops/__example_assets__/test_job.syclops.yaml index 22aa8b8..cd0e3e2 100644 --- a/syclops/__example_assets__/test_job.syclops.yaml +++ b/syclops/__example_assets__/test_job.syclops.yaml @@ -107,7 +107,7 @@ sensor: - name: "main_camera" # Location, rotation and velocity of camera is optional if frame_id is set frame_id: "camera_link" - resolution: [1280, 960] + resolution: [256, 256] focal_length: 65 # mm shutter_speed: 0.02 # s Currently only affects motion blur sensor_width: 35 # mm @@ -154,6 +154,20 @@ sensor: intensity: 10000 scale: 200 samples: 4 + - name: "fisheye_camera" + frame_id: "camera_link" + resolution: [256, 256] + fisheye_fov: 1.8 + lens_type: "FISHEYE_EQUIDISTANT" + sensor_width: 35 # mm + outputs: + syclops_output_rgb: + - samples: 4 + compositor: + chromatic_aberration: 0.007 #Strong aberration can cause shift between ground truth and rgb + bloom: + threshold: 0.99 # higher is less bloom + id: main_cam_rgb postprocessing: syclops_postprocessing_bounding_boxes: diff --git a/syclops/blender/sensors/schema/camera.schema.yaml b/syclops/blender/sensors/schema/camera.schema.yaml index 2947176..f0973c0 100644 --- a/syclops/blender/sensors/schema/camera.schema.yaml +++ b/syclops/blender/sensors/schema/camera.schema.yaml @@ -111,14 +111,26 @@ items: syclops_output_keypoints: $ref: "#/definitions/syclops_output_keypoints" additionalProperties: False - required: [name, frame_id, resolution, focal_length, sensor_width, outputs] + required: [name, frame_id, resolution, sensor_width, outputs] allOf: - if: + required: [motion_blur] properties: motion_blur: properties: enabled: const: true - required: [motion_blur] then: - required: [shutter_speed] \ No newline at end of file + required: [shutter_speed] + - if: + properties: + lens_type: + enum: [PERSPECTIVE, FISHEYE_EQUISOLID] + then: + required: [focal_length] + - if: + properties: + lens_type: + enum: [FISHEYE_EQUIDISTANT, FISHEYE_EQUISOLID] + then: + required: [fisheye_fov] \ No newline at end of file From 50d6bc22aafb6de50fecdf8bb2087f44a5a2fcd2 Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Mon, 6 Jan 2025 14:06:41 +0100 Subject: [PATCH 07/14] Update camera documentation to include lens types and parameters --- .../config_descriptions/camera.md | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/docs/usage/job_description/config_descriptions/camera.md b/docs/docs/usage/job_description/config_descriptions/camera.md index 4229b85..cb2dbdb 100644 --- a/docs/docs/usage/job_description/config_descriptions/camera.md +++ b/docs/docs/usage/job_description/config_descriptions/camera.md @@ -1,6 +1,6 @@ # Camera Plugin Documentation -The Camera Plugin simulates a basic camera sensor, allowing you to configure the optical and digital properties of the camera within your scene. It supports various parameters such as resolution, focal length, exposure, depth of field, motion blur, and frustum visualization for debugging purposes. Additionally, it outputs the intrinsic and extrinsic camera parameters. +The Camera Plugin simulates a basic camera sensor, allowing you to configure the optical and digital properties of the camera within your scene. It supports various parameters such as resolution, lens types (perspective and fisheye), exposure, depth of field, motion blur, and frustum visualization for debugging purposes. Additionally, it outputs the intrinsic and extrinsic camera parameters. ## Configuration Parameters @@ -11,7 +11,9 @@ The following table describes each configuration parameter for the Camera Plugin | `name` | string | Unique identifier of the sensor. | **Required** | | `frame_id` | string | Transformation tree node the camera attaches to. | **Required** | | `resolution` | array (2 integers: width x height) | Width and height of the camera in pixels. | **Required** | -| `focal_length` | float | Focal length of the camera in mm. | **Required** | +| `lens_type` | string | Type of lens projection (PERSPECTIVE [default], FISHEYE_EQUISOLID, FISHEYE_EQUIDISTANT). | Optional | +| `focal_length` | float | Focal length of the camera in mm. Required for PERSPECTIVE and FISHEYE_EQUISOLID. | Conditional | +| `fisheye_fov` | float | Horizontal angular field of view in radians. Required for FISHEYE_EQUIDISTANT and FISHEYE_EQUISOLID. | Conditional | | `sensor_width` | float | Width of the sensor in mm. | **Required** | | `exposure` | float | Exposure offset in stops. | Optional | | `gamma` | float | Gamma correction applied to the image (1 means no change in gamma). | Optional | @@ -62,6 +64,28 @@ The following table describes each configuration parameter for the Camera Plugin | `enabled` | boolean | Whether to render as wireframe lines. | | `thickness` | number | Thickness of the wireframe lines. | +### Lens Types and Parameters + +The camera supports three types of lens projections: + +1. **PERSPECTIVE** (default) + - Requires `focal_length` + - Standard perspective projection + +2. **FISHEYE_EQUISOLID** + - Requires both `focal_length` and `fisheye_fov` + - Follows the equisolid angle projection formula + - Commonly used in real fisheye lenses + +3. **FISHEYE_EQUIDISTANT** + - Requires `fisheye_fov` + - Linear mapping between angle and image distance + - Theoretical fisheye projection + +!!! note + When using fisheye lens types, the frustum visualization is not supported and will be disabled automatically. + Camera extrinsic parameters are not output when using fisheye lens types as they are not supported. + !!! warning If `motion_blur` is enabled, `shutter_speed` becomes a required parameter. From ea72a2e72ab3423257062430f0249130740ea1b0 Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Mon, 6 Jan 2025 15:14:27 +0100 Subject: [PATCH 08/14] Enhance camera schema: set default lens type to PERSPECTIVE and update required fields for fisheye lens types --- syclops/blender/sensors/schema/camera.schema.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/syclops/blender/sensors/schema/camera.schema.yaml b/syclops/blender/sensors/schema/camera.schema.yaml index f0973c0..f427f89 100644 --- a/syclops/blender/sensors/schema/camera.schema.yaml +++ b/syclops/blender/sensors/schema/camera.schema.yaml @@ -20,6 +20,7 @@ items: description: Lens type (PERSPECTIVE [default],FISHEYE_EQUISOLID,FISHEYE_EQUIDISTANT) type: string enum: [PERSPECTIVE,FISHEYE_EQUISOLID,FISHEYE_EQUIDISTANT] + default: PERSPECTIVE focal_length: description: Focal length of the camera in mm. Only effects lens_type=(PERSPECTIVE,FISHEYE_EQUISOLID). $ref: "#/definitions/number_evaluation" @@ -131,6 +132,12 @@ items: - if: properties: lens_type: - enum: [FISHEYE_EQUIDISTANT, FISHEYE_EQUISOLID] + const: FISHEYE_EQUIDISTANT then: - required: [fisheye_fov] \ No newline at end of file + required: [fisheye_fov] + - if: + properties: + lens_type: + const: FISHEYE_EQUISOLID + then: + required: [fisheye_fov, focal_length] \ No newline at end of file From 59f6badb5b0fbf9c82e17ea40ba36c70eadae79c Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Mon, 6 Jan 2025 15:14:33 +0100 Subject: [PATCH 09/14] Add fisheye camera output paths to integration test workflow --- .github/workflows/integration_test.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/integration_test.yaml b/.github/workflows/integration_test.yaml index 142e7cf..d1cd1a7 100644 --- a/.github/workflows/integration_test.yaml +++ b/.github/workflows/integration_test.yaml @@ -60,6 +60,8 @@ jobs: "./output/*/main_camera_annotations/structured_light/*metadata.yaml" "./output/*/object_positions/*.json" "./output/*/object_positions/*metadata.yaml" + "./output/*/fisheye_camera/rect/*.png" + "./output/*/fisheye_camera/rect/*metadata.yaml" ) missing=false From ddd998b01a0f19011ff5e0ecdb0615f9d751c4a7 Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Mon, 6 Jan 2025 15:14:56 +0100 Subject: [PATCH 10/14] Rename `scale_std` to `scale_standard_deviation` in documentation and configuration files for consistency --- .../config_descriptions/simulated_scatter.md | 6 +++--- syclops/__example_assets__/test_job.syclops.yaml | 2 +- .../blender/plugins/schema/simulated_scatter.schema.yaml | 4 ++-- syclops/blender/plugins/simulated_scatter.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/docs/usage/job_description/config_descriptions/simulated_scatter.md b/docs/docs/usage/job_description/config_descriptions/simulated_scatter.md index 77f291a..9a7f83e 100644 --- a/docs/docs/usage/job_description/config_descriptions/simulated_scatter.md +++ b/docs/docs/usage/job_description/config_descriptions/simulated_scatter.md @@ -15,13 +15,13 @@ The following table describes each configuration parameter for the Simulated Sca | `decimate_mesh_factor` | number (0-1) | Factor between 0-1 that decimates the number of vertices of the mesh. Lower means less vertices. | Optional | | `density` | number | Density of objects per square meter. | **Required** | | `density_texture` | image/texture evaluation | Texture that alters the density per pixel. Needs to be a single channel image that is normalized to 0-1. | Optional | -| `scale_std` | number | Standard deviation of the scale randomization. | **Required** | +| `scale_standard_deviation` | number | Standard deviation of the scale randomization. | **Required** | | `convex_decomposition_quality` | integer (1-100) | Quality setting for the convex decomposition. Higher means more accurate but slower. | **Required** | | `simulation_steps` | integer | Number of simulation steps to run. | **Required** | ### Dynamic Evaluators -Parameters like `density_texture` and `scale_std` can be dynamically evaluated. This means that their values can be altered for each new frame. For more insights on dynamic evaluators and how to use them, kindly refer to [Dynamic Evaluators](../dynamic_evaluators.md). +Parameters like `density_texture` and `scale_standard_deviation` can be dynamically evaluated. This means that their values can be altered for each new frame. For more insights on dynamic evaluators and how to use them, kindly refer to [Dynamic Evaluators](../dynamic_evaluators.md). ## Example Configuration @@ -33,7 +33,7 @@ scene: floor_object: "Ground" max_texture_size: 2048 density: 5 - scale_std: 0.3 + scale_standard_deviation: 0.3 convex_decomposition_quality: 90 simulation_steps: 100 ``` diff --git a/syclops/__example_assets__/test_job.syclops.yaml b/syclops/__example_assets__/test_job.syclops.yaml index cd0e3e2..9de65af 100644 --- a/syclops/__example_assets__/test_job.syclops.yaml +++ b/syclops/__example_assets__/test_job.syclops.yaml @@ -57,7 +57,7 @@ scene: floor_object: Ground class_id: 1 simulation_steps: 5 - std_scale: 1 + scale_standard_deviation: 1 density: 0.01 convex_decomposition_quality: 90 diff --git a/syclops/blender/plugins/schema/simulated_scatter.schema.yaml b/syclops/blender/plugins/schema/simulated_scatter.schema.yaml index dd1646b..4269293 100644 --- a/syclops/blender/plugins/schema/simulated_scatter.schema.yaml +++ b/syclops/blender/plugins/schema/simulated_scatter.schema.yaml @@ -28,7 +28,7 @@ items: density_texture: description: Texture that alters the density per pixel. Needs to be a single channel image that is normalized to 0-1. $ref: "#/definitions/image_texture_evaluation" - scale_std: + scale_standard_deviation: description: Standard deviation of the scale randomization. type: number convex_decomposition_quality: @@ -44,7 +44,7 @@ items: models, floor_object, density, - scale_std, + scalscale_standard_deviatione_std, convex_decomposition_quality, simulation_steps, ] diff --git a/syclops/blender/plugins/simulated_scatter.py b/syclops/blender/plugins/simulated_scatter.py index b4a8320..093f3af 100644 --- a/syclops/blender/plugins/simulated_scatter.py +++ b/syclops/blender/plugins/simulated_scatter.py @@ -42,8 +42,8 @@ def _simulate_convex_objects(self, scatter_points: np.array): conv_hulls = utility.filter_objects("PARENT_UUID", parent_uuid) random_rotation = Vector(np.random.uniform(0, 2 * np.pi, size=3)) random_scale_value = ( - np.random.normal(1, self.config["scale_std"]) - if "scale_std" in self.config + np.random.normal(1, self.config["scale_standard_deviation"]) + if "scale_standard_deviation" in self.config else 1 ) random_scale = Vector([random_scale_value] * 3) From 8c42175c0155009e8870557caedeff1595465e90 Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Mon, 6 Jan 2025 15:19:27 +0100 Subject: [PATCH 11/14] Bump version to 1.4.0 in pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 250f858..365f66e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ readme = "README.md" requires-python = ">=3.8" license = {text = "GPLv3"} -version = "1.3.10" +version = "1.4.0" dynamic = ["dependencies"] From cfdc544943df5e2fd4544b37d2df193333a7c0b7 Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Mon, 6 Jan 2025 15:40:50 +0100 Subject: [PATCH 12/14] Fix typo in simulated scatter schema: correct `scalscale_standard_deviatione_std` to `scale_standard_deviation` --- syclops/blender/plugins/schema/simulated_scatter.schema.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syclops/blender/plugins/schema/simulated_scatter.schema.yaml b/syclops/blender/plugins/schema/simulated_scatter.schema.yaml index 4269293..08c5490 100644 --- a/syclops/blender/plugins/schema/simulated_scatter.schema.yaml +++ b/syclops/blender/plugins/schema/simulated_scatter.schema.yaml @@ -44,7 +44,7 @@ items: models, floor_object, density, - scalscale_standard_deviatione_std, + scale_standard_deviation, convex_decomposition_quality, simulation_steps, ] From 62379a32990fb43e062495dc5779f50c4ec25fd6 Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Mon, 6 Jan 2025 15:42:47 +0100 Subject: [PATCH 13/14] Remove unused `res` parameter from perlin operation in test job configuration --- syclops/__example_assets__/test_job.syclops.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/syclops/__example_assets__/test_job.syclops.yaml b/syclops/__example_assets__/test_job.syclops.yaml index 9de65af..79043dc 100644 --- a/syclops/__example_assets__/test_job.syclops.yaml +++ b/syclops/__example_assets__/test_job.syclops.yaml @@ -32,7 +32,6 @@ textures: num_textures: 2 ops: - perlin: - res: 4 octaves: 4 - math_expression: "((x-0.5) * 100 + 65535 / 2)/65535" From 7246228951df8b51a21d51cc2faa3834626a7fad Mon Sep 17 00:00:00 2001 From: Anton Elmiger Date: Mon, 6 Jan 2025 16:07:17 +0100 Subject: [PATCH 14/14] Add structured light output schema and update camera schema references --- .../schema/structured_light.schema.yaml | 26 +++++++++++++ .../blender/sensors/schema/camera.schema.yaml | 39 +++++++++---------- 2 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 syclops/blender/sensor_outputs/schema/structured_light.schema.yaml diff --git a/syclops/blender/sensor_outputs/schema/structured_light.schema.yaml b/syclops/blender/sensor_outputs/schema/structured_light.schema.yaml new file mode 100644 index 0000000..e394f4b --- /dev/null +++ b/syclops/blender/sensor_outputs/schema/structured_light.schema.yaml @@ -0,0 +1,26 @@ +description: Structured light pattern output from a camera with a projected pattern. +type: array +items: + type: object + properties: + id: + description: Unique identifier of the output + type: string + frame_id: + description: Frame ID to attach the structured light source to + type: string + samples: + description: Render quality of the image. More means a better quality and more samples per pixel. + type: integer + intensity: + description: Light intensity of the structured light pattern + type: number + scale: + description: Scale factor of the Voronoi pattern + type: number + debug_breakpoint: + description: Whether to break and open Blender before rendering. Only works if scene debugging is active. + type: boolean + required: [id, frame_id, samples, intensity, scale] +minItems: 1 +maxItems: 1 diff --git a/syclops/blender/sensors/schema/camera.schema.yaml b/syclops/blender/sensors/schema/camera.schema.yaml index f427f89..f30f3a1 100644 --- a/syclops/blender/sensors/schema/camera.schema.yaml +++ b/syclops/blender/sensors/schema/camera.schema.yaml @@ -19,7 +19,7 @@ items: lens_type: description: Lens type (PERSPECTIVE [default],FISHEYE_EQUISOLID,FISHEYE_EQUIDISTANT) type: string - enum: [PERSPECTIVE,FISHEYE_EQUISOLID,FISHEYE_EQUIDISTANT] + enum: [PERSPECTIVE, FISHEYE_EQUISOLID, FISHEYE_EQUIDISTANT] default: PERSPECTIVE focal_length: description: Focal length of the camera in mm. Only effects lens_type=(PERSPECTIVE,FISHEYE_EQUISOLID). @@ -68,7 +68,7 @@ items: type: number frustum: description: Settings for the camera frustum visualization - type: object + type: object properties: enabled: description: Whether to enable frustum visualization @@ -93,7 +93,7 @@ items: properties: enabled: description: Whether to render as wireframe - type: boolean + type: boolean thickness: description: Thickness of wireframe lines type: number @@ -111,6 +111,8 @@ items: $ref: "#/definitions/syclops_output_object_positions" syclops_output_keypoints: $ref: "#/definitions/syclops_output_keypoints" + syclops_output_structured_light: + $ref: "#/definitions/syclops_output_structured_light" additionalProperties: False required: [name, frame_id, resolution, sensor_width, outputs] allOf: @@ -123,21 +125,16 @@ items: const: true then: required: [shutter_speed] - - if: - properties: - lens_type: - enum: [PERSPECTIVE, FISHEYE_EQUISOLID] - then: - required: [focal_length] - - if: - properties: - lens_type: - const: FISHEYE_EQUIDISTANT - then: - required: [fisheye_fov] - - if: - properties: - lens_type: - const: FISHEYE_EQUISOLID - then: - required: [fisheye_fov, focal_length] \ No newline at end of file + - anyOf: + - properties: + lens_type: + enum: [PERSPECTIVE, null] + required: [focal_length] + - properties: + lens_type: + const: FISHEYE_EQUIDISTANT + required: [fisheye_fov] + - properties: + lens_type: + const: FISHEYE_EQUISOLID + required: [fisheye_fov, focal_length]