Camera LookAt

Hi,
I wanted to recreate what viewport.set_camera_target was doing. I created a cube at (0,0,0) and then several cameras using azimuth and elevations. The cameras when not using set_camera_target are NOT centered at the cube. I don’t understand why. The cameras are all correctly placed. Its just that the rendered image is offset from what I would think the center should have been. Is there another camera frame in the camera primitive which actually represents the imaging camera?

UsdGeom.SetStageUpAxis(stage, "Y")
cube = stage.DefinePrim("/World/Cube", "Cube")
camera = stage.DefinePrim("/World/Camera1", "Camera")
xform_api = UsdGeom.Xformable(camera)

xform_api.ClearXformOpOrder()
xform_api.AddRotateZOp().Set(0) 
xform_api.AddRotateYOp().Set(az)
xform_api.AddRotateXOp().Set(el)
xform_api.AddTranslateOp().Set(Gf.Vec3f(0.0, 0.0, radius))

viewport.set_active_camera("/World/Camera1")

Also viewport.set_active_camera changes the scale of the camera when I use it within the simple_room USD.
In the images I create 20 cameras looking at a cube. After I cycle through them and set them as active camera and call set_target, may cameras become warped

DebugCamera1
DebugCamera2

@parrotdora There is a certain transformation between camera frame and world frame. For a newly created camera from UI, you can switch from local to world frame for the camera to see the difference. Also, you can see that in the rotation attribute property window.
transform

Thats great to know. I think the issue I show here in the image is that something is recaculating the Scale of the camera when it shouldnt ever touch the scale of the camera.

Interesting, when I ran your script, it did not scale for me. See the property window in below image.

import omni
from pxr import UsdGeom

viewport = omni.kit.viewport.get_viewport_interface().get_viewport_window()
stage = omni.usd.get_context().get_stage()
UsdGeom.SetStageUpAxis(stage, "Y")
cube = stage.DefinePrim("/World/Cube", "Cube")
camera = stage.DefinePrim("/World/Camera1", "Camera")
xform_api = UsdGeom.Xformable(camera)

xform_api.ClearXformOpOrder()
xform_api.AddRotateZOp().Set(0) 
xform_api.AddRotateYOp().Set(60)
xform_api.AddRotateXOp().Set(20)
xform_api.AddTranslateOp().Set(Gf.Vec3f(0.0, 0.0, 30))

viewport.set_active_camera("/World/Camera1")