stereolabs / zed-python-api

Python API for the ZED SDK
https://www.stereolabs.com/docs/app-development/python/install/
MIT License
213 stars 94 forks source link

pyzed.sl.FLIP_MODE bug introduced in sdk 4.1 #239

Open AlbertFlorinus opened 3 months ago

AlbertFlorinus commented 3 months ago

Preliminary Checks

Description

With ZED SDK 4.0 flip mode works just fine and adjust for the current camera orientation (executed on Jetson Orin Nano). On Jetson Orin NX with SDK 4.1 however this no longer works. The code still runs but it does not adjust for the orientation.

import numpy as np import cv2 import pyzed.sl as sl

class ZedRunner: def init(self): self.zedcam = self.start_zed() self.runtime_param = sl.RuntimeParameters() self.image = sl.Mat()

def start_zed(self) -> sl.Camera:
    zed = sl.Camera()
    #if zed is upside down when calling this function, flips frame 180 degrees to adjust
    #this works on zed sdk 4.0 jetson orin nano, not sdk 4.1 jetson orin nx
    sl.FLIP_MODE(0)
    init_params = sl.InitParameters()
    init_params.camera_resolution = sl.RESOLUTION.HD720    # Use HD720 video mode for USB cameras
    init_params.camera_fps = 60                            # Set fps at 60
    err = zed.open(init_params)
    if err != sl.ERROR_CODE.SUCCESS:
        print(repr(err))
        exit(-1)
    return zed

def get_frame(self) -> np.array:
    if self.zedcam.grab(self.runtime_param) == sl.ERROR_CODE.SUCCESS:
        self.zedcam.retrieve_image(self.image, sl.VIEW.LEFT)
        frame : np.array = self.image.get_data()
        frame = frame[:,:,:-1] #remove depth channel
        return frame
    else:
        raise ValueError("Error grabbing frame")

if name == "main": zed_runner = ZedRunner() for i in range(30): frame: np.array = zed_runner.getframe() cv2.imwrite(f"test{i}.jpg", frame)

Steps to Reproduce

  1. install the python zed api to your environment. This bug occurs on SDK 4.1 with Jetson Orin NX but not on SDK 4.0 with Jetson Orin Nano.
  2. Orient camera upside down before running the script and don't flip it while the code is running.
  3. Inspect the saved images ...

Expected Result

That the image will not be upside down if even if the zed 2i is when the script is started.

Actual Result

The images are upside down.

ZED Camera model

ZED2i

Environment

This is for the Orin Nano running zed SDK 4.0 with jetpack
from cat /etc/nv_tegra_release.
R35 (release), REVISION: 4.1, BOARD: t186ref, EABI: aarch64

This is for the Orin NX running zed SDK 4.1 with jetpack
from cat /etc/nv_tegra_release.
R35 (release), REVISION: 3.1, BOARD: t186ref, EABI: aarch64

Anything else?

No response