Error when setting a camera's vertical/horizontal aperture

Isaac Sim version: 2023.1.0

Hello.
While trying to execute the example “camera_opencv.py” I experienced the following error:

Traceback (most recent call last):
  File "/home/user/.local/share/ov/pkg/isaac_sim-2023.1.0/standalone_examples/api/omni.isaac.sensor/camera_opencv.py", line 72, in <module>
    camera.set_horizontal_aperture(horizontal_aperture / 10.0)
  File "/home/user/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.sensor/omni/isaac/sensor/scripts/camera.py", line 1089, in set_horizontal_aperture
    (width, height) = self.get_resolution()
  File "/home/user/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.sensor/omni/isaac/sensor/scripts/camera.py", line 498, in get_resolution
    return get_resolution(self._render_product_path)
  File "/home/user/.local/share/ov/pkg/isaac_sim-2023.1.0/exts/omni.isaac.core/omni/isaac/core/utils/render_product.py", line 126, in get_resolution
    render_prod_prim = UsdRender.Product(stage.GetPrimAtPath(render_product_path))
Boost.Python.ArgumentError: Python argument types in
    Stage.GetPrimAtPath(Stage, NoneType)
did not match C++ signature:
    GetPrimAtPath(pxrInternal_v0_22__pxrReserved__::UsdStage {lvalue}, pxrInternal_v0_22__pxrReserved__::SdfPath path)

The error indicates that there is a problem when trying to use the set_horizontal_aperture(...) function.

Just to make sure I also tried to use this function in my own separate python script, where I got the same error. Specifically, the error only occurs when trying to set the horizontal or vertical aperture of a camera. The other parameters seem to work fine.

This issue appears to be related to a bug and I don’t know if there is any workaround.

Yeah, I get the same result.

I managed to solve the error in my own code. It appears to be necessary to set the camera’s horizontal or vertical aperture after the camera is initialized.

The error showed that the problem was within the get_resolution() mehtod used in set_vetical_aperture() / set_horizontal_aperture(). Looking into the code I noticed that the get_resolution() method tries to obtain the resolution values from the _render_product_path defined for the camera:

    def get_resolution(self) -> Tuple[int, int]:
        """
        Returns:
            Tuple[int, int]: width and height respectively.
        """
        return get_resolution(self._render_product_path)

The problem is that if no product_render_path is specified when camera is created, then the camera wont’t have a product_render_path until it is intialized. The initialize() method is the one responsible of cheking if the camera has a product_render_path, and creates one if it is missing.
Therefore, in this case, without initializing the camera there is no product_render_path and the get_resolution() mehtod has nowhere to get the resolution from, and so it crashes.

Summarizing, in the current Isaac Sim 2023.1.0 version, the camera’s horizontal or vertical aperture must be set after the use of camera.initialize(). Which is not done in the “camera_opencv.py” example and so it crashes.

3 Likes

Thank you @jarozamena - Thank you for bringing this to our attention. This should be fixed in our upcoming bug fix release.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.