Randomize Camera position and angle via Python scripting

I want to randomize a camera’s position and angle via Python scripting for synthetic data. Please, how do I go about this? Thank you.


Please check this example and see if it helps:
Domain Randomization — Omniverse Robotics documentation


the simplest way is to use the viewport interface using something similar below.

viewport_interface = omni.kit.viewport.get_viewport_interface()
viewport_handle = viewport_interface.get_instance('Viewport')
viewport_window = viewport_interface.get_viewport_window(viewport_handle)
viewport_window.set_camera_position("/OmniverseKit_Persp", 50.0, 50.0, 50.0, True)
viewport_window.set_camera_target("/OmniverseKit_Persp", 0.0, 0.0, 0.0, True)

Alternatively you can use movement component like liila suggested

which has a look at target option

Thank you Liila.
The issue is that though the camera rotates around the object it does not focus on the object even though I defined the target points. It looks outwards and not inwards of the circular path (my object is in the center of the circular path). Please, how can this be solved so that my object would always be in focus of the camera? Thank you.

My guess is that there are some miss match in your coordinate system, because if you set the camera-target should work. could you please check your camera coordinates.

@ifeoluwaademola17 Can you provide an example image of what you mean by out of focus?