refactor: simplify camera init, document aperture warning as cosmetic
Camera.__init__() internally calls UsdGeom.Camera.Define() which resets aperture to defaults, making it impossible to pre-set values. The aperture mismatch warnings are cosmetic — IS auto-corrects them and our values are applied correctly after init. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,7 @@ class CustomCamera(Camera):
|
||||
reference_path: Reference prim path for camera mounting
|
||||
name: Camera name
|
||||
"""
|
||||
# ===== Pre-compute camera parameters =====
|
||||
# ===== From cfg =====
|
||||
pixel_size = cfg["params"].get("pixel_size")
|
||||
f_number = cfg["params"].get("f_number")
|
||||
focus_distance = cfg["params"].get("focus_distance")
|
||||
@@ -47,18 +47,9 @@ class CustomCamera(Camera):
|
||||
focal_length_y = fy * pixel_size * 1e-3
|
||||
focal_length = (focal_length_x + focal_length_y) / 2 / 10.0
|
||||
|
||||
# Pre-set aperture on USD prim before Camera.__init__ to avoid mismatch warnings
|
||||
from pxr import UsdGeom
|
||||
import omni.usd
|
||||
stage = omni.usd.get_context().get_stage()
|
||||
cam_prim = stage.GetPrimAtPath(prim_path)
|
||||
if cam_prim.IsValid():
|
||||
cam = UsdGeom.Camera(cam_prim)
|
||||
cam.GetHorizontalApertureAttr().Set(horizontal_aperture * 10.0) # USD uses mm
|
||||
cam.GetVerticalApertureAttr().Set(vertical_aperture * 10.0)
|
||||
cam.GetFocalLengthAttr().Set(focal_length * 10.0)
|
||||
|
||||
# ===== Initialize camera =====
|
||||
# Note: Camera.__init__ triggers aperture consistency warnings with default USD values.
|
||||
# These are cosmetic — IS auto-corrects, and we override with correct values below.
|
||||
super().__init__(
|
||||
prim_path=prim_path,
|
||||
name=name,
|
||||
|
||||
Reference in New Issue
Block a user