diff --git a/script/dataset_generator/generate_scene.py b/script/dataset_generator/generate_scene.py index c9b2eb1363..d5b9427550 100644 --- a/script/dataset_generator/generate_scene.py +++ b/script/dataset_generator/generate_scene.py @@ -84,7 +84,9 @@ def convert_to_visp_frame(aTb): Blender: +X = Right, +Y = Up, +Z = Behind Same as converting to an OpenCV frame ''' - return bproc.math.change_source_coordinate_frame_of_transformation_matrix(aTb, ["X", "-Y", "-Z"]) + aTbbis = aTb.copy() + aTbbis[1:3] = -aTbbis[1:3] + return aTbbis def convert_points_to_visp_frame(points: np.ndarray): ''' @@ -381,7 +383,6 @@ def save_data(self, path: Path, objects: List[bproc.types.MeshObject], data: Dic hit_count += 1 final_visibility = base_visibility * (hit_count / len(ray_directions)) - print(final_visibility) # Including occlusions, the object is now not visible enough to be detectable if final_visibility < min_visibility: print(f'Filtered object {object.get_name()}, because of occlusions: {final_visibility}') @@ -583,7 +584,7 @@ def create_target_objects(self) -> List[bproc.types.MeshObject]: random_scale = np.random.uniform(-scale_noise, scale_noise) + 1.0 object.set_scale([random_scale, random_scale, random_scale]) # Uniform scaling object.set_location([0.0, 0.0, 0.0]) - object.persist_transformation_into_mesh() + object.persist_transformation_into_mesh(location=False, rotation=False, scale=True) if displacement_amount > 0.0: add_displacement(objects, displacement_amount) @@ -659,7 +660,8 @@ def sample_pose(obj: bproc.types.MeshObject): ) for object in objects: - object.persist_transformation_into_mesh() + object.persist_transformation_into_mesh(location=False, rotation=False, scale=True) + distractors = self.create_distractors(size) @@ -670,8 +672,7 @@ def sample_pose(obj: bproc.types.MeshObject): object.enable_rigidbody(False, collision_shape='BOX') bproc.object.simulate_physics_and_fix_final_poses(min_simulation_time=3, max_simulation_time=3.5, check_object_interval=1) - for object in objects: - object.persist_transformation_into_mesh() + def filter_objects_outside_room(objects: List[bproc.types.MeshObject]) -> List[bproc.types.MeshObject]: inside = [] outside = [] @@ -681,7 +682,7 @@ def filter_objects_outside_room(objects: List[bproc.types.MeshObject]) -> List[b for object in outside: object.delete() - print(f'Filtered {len(objects) - len(inside)} objects') + print(f'Filtered {len(objects) - len(inside)} objects that were outside the room') return inside objects = filter_objects_outside_room(objects) @@ -787,5 +788,3 @@ def run(self): bproc.init() # Works if you have a GPU generator.run() - -