Hi community,
I want to mimic a real world camera of a robot. Thus, I want to precisely set the intrinsic matrix. I am using this code to set the parameters:
# extract parameters from matrix
f_x = intrinsic_matrix[0, 0]
c_x = intrinsic_matrix[0, 2]
f_y = intrinsic_matrix[1, 1]
c_y = intrinsic_matrix[1, 2]
# get viewport parameters
height, width = self.image_shape
height, width = float(height), float(width)
# resolve parameters for usd camera
params = {
"focal_length": focal_length,
"horizontal_aperture": width * focal_length / f_x,
"vertical_aperture": height * focal_length / f_y,
"horizontal_aperture_offset": (c_x - width / 2) / f_x,
"vertical_aperture_offset": (c_y - height / 2) / f_y,
}
# set parameters for camera
for param_name, param_value in params.items():
# convert to camel case (CC)
param_name = to_camel_case(param_name, to="CC")
# get attribute from the class
param_attr = getattr(self._sensor_prim, f"Get{param_name}Attr")
# set value
# note: We have to do it this way because the camera might be on a different layer (default cameras are on session layer),
# and this is the simplest way to set the property on the right layer.
omni.usd.utils.set_prop_val(param_attr(), param_value)
Especially, the horizontal and vertical aperture offset do not seem to be set in the simulator. Would be a good solution to have a function that receives an intrinsic matrix and the focal length and sets all the corresponding parameters correctly.
To reproduce, I am using a camera with focal_length=1.0, width=1440 and height=1080 with intrinsic matrix= (575.60504, 0.0, 745.73121, 0.0, 578.56484, 519.52070, 0.0, 0.0, 1.0).
System Info:
Isaac Sim Version: 2022.2.1-rc.14
OS: Ubuntu 20.04