Hi there,
if you getting empty arrays it is most probably because orchestrator.step()
has not been called to feed the annotators with new data.
Here is a script that can be called in the script editor and it should print you the camera parameters:
import asyncio
import omni.replicator.core as rep
cam1 = rep.create.camera(f_stop=1.8)
cam2 = rep.create.camera(position=(1, 0, 0), projection_type="fisheye_polynomial")
rp1 = rep.create.render_product(cam1, (512, 512))
rp2 = rep.create.render_product(cam2, (512, 512))
cam_params_annot1 = rep.annotators.get("CameraParams")
cam_params_annot1.attach(rp1)
cam_params_annot2 = rep.annotators.get("CameraParams")
cam_params_annot2.attach(rp2)
async def get_camera_params_async():
# NOTE: step_async() is needed to feed the annotator with new data
await rep.orchestrator.step_async()
data1 = cam_params_annot1.get_data()
print(f"data1={data1}")
data2 = cam_params_annot2.get_data()
print(f"data2={data2}")
await asyncio.sleep(1)
task = asyncio.ensure_future(get_camera_params_async())
Output:
data1={'cameraAperture': array([20.955 , 15.2908], dtype=float32), 'cameraApertureOffset': array([0., 0.], dtype=float32), 'cameraFisheyeLensP': array([], dtype=float32), 'cameraFisheyeLensS': array([], dtype=float32), 'cameraFisheyeMaxFOV': 0.0, 'cameraFisheyeNominalHeight': 0, 'cameraFisheyeNominalWidth': 0, 'cameraFisheyeOpticalCentre': array([0., 0.], dtype=float32), 'cameraFisheyePolynomial': array([0., 0., 0., 0., 0.], dtype=float32), 'cameraFocalLength': 24.0, 'cameraFocusDistance': 400.0, 'cameraFStop': 1.7999999523162842, 'cameraModel': 'pinhole', 'cameraNearFar': array([1.e+00, 1.e+06], dtype=float32), 'cameraProjection': array([ 2.29062286e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 2.29062286e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 1.00000100e-06, -1.00000000e+00,
0.00000000e+00, 0.00000000e+00, 1.00000100e+00, 0.00000000e+00]), 'cameraViewTransform': array([ 2.22044605e-16, -2.22044605e-16, 1.00000000e+00, 0.00000000e+00,
1.00000000e+00, 4.93038066e-32, -2.22044605e-16, 0.00000000e+00,
0.00000000e+00, 1.00000000e+00, 2.22044605e-16, -0.00000000e+00,
-0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 1.00000000e+00]), 'metersPerSceneUnit': 1.0, 'renderProductResolution': array([512, 512], dtype=int32)}
data2={'cameraAperture': array([20.955 , 15.2908], dtype=float32), 'cameraApertureOffset': array([0., 0.], dtype=float32), 'cameraFisheyeLensP': array([-0.00037, -0.00074], dtype=float32), 'cameraFisheyeLensS': array([-0.00058, -0.00022, 0.00019, -0.0002 ], dtype=float32), 'cameraFisheyeMaxFOV': 200.0, 'cameraFisheyeNominalHeight': 1216, 'cameraFisheyeNominalWidth': 1936, 'cameraFisheyeOpticalCentre': array([970.94244, 600.3748 ], dtype=float32), 'cameraFisheyePolynomial': array([0. , 0.00245, 0. , 0. , 0. , 0. ],
dtype=float32), 'cameraFocalLength': 24.0, 'cameraFocusDistance': 400.0, 'cameraFStop': 0.0, 'cameraModel': 'fisheyePolynomial', 'cameraNearFar': array([1.e+00, 1.e+06], dtype=float32), 'cameraProjection': array([ 2.29062286e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 2.29062286e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 1.00000100e-06, -1.00000000e+00,
0.00000000e+00, 0.00000000e+00, 1.00000100e+00, 0.00000000e+00]), 'cameraViewTransform': array([ 2.22044605e-16, -2.22044605e-16, 1.00000000e+00, 0.00000000e+00,
1.00000000e+00, 4.93038066e-32, -2.22044605e-16, 0.00000000e+00,
0.00000000e+00, 1.00000000e+00, 2.22044605e-16, -0.00000000e+00,
-2.22044605e-16, 2.22044605e-16, -1.00000000e+00, 1.00000000e+00]), 'metersPerSceneUnit': 1.0, 'renderProductResolution': array([512, 512], dtype=int32)}