ZED User Guide (2) Hello ZED

6. Usage examples

1、Hello ZED

Turn on and configure the ZED, print its serial number, and turn off the camera.

To use ZED, you must first create and open a Camera object.

The ZED API can be used with two different video inputs: ZED live video (live mode) or SVO format video files recorded with the ZED API (playback mode).

(1) Configure camera

You need to create a camera object and specify InitParameters. The initial parameters can set the camera resolution, FPS, depth sensing parameters, etc. These parameters can only be set before turning on the camera and cannot be changed while the camera is in use.

# Create a ZED camera object
zed = sl.Camera()

# Set configuration parameters
init_params = sl.InitParameters()
init_params.camera_resolution = sl.RESOLUTION.HD1080
init_params.camera_fps = 30

InitParameters contains a configuration by default.

(2) Turn on the camera

# Open the camera
err = zed.open(init_params)
if (err != sl.ERROR_CODE.SUCCESS):
    exit(-1)

Initial parameters that can be set:
camera configuration parameters camera_(resolution, image flip...)

SDK configuration parameters sdk_(verbosity, GPU device used...)

Depth configuration parameter depth_(depth mode, minimum distance...)

Coordinate system configuration parameters coordinate_(coordinate system, coordinate units...)

SVO parameters of video files (filename, real-time mode...)

Camera parameters:

Focal length: fx,fy

Main points: cx,cy

Lens distortion: k1, k2

Horizontal and vertical field of view

Stereo calibration: rotation and translation between left and right eyes

These values ​​can be found in CalibrationParameters (containing the calibration parameters), accessed using get_camera_information().

(3) Retrieve the serial number of the camera

# Get camera information(serial number)
zed_serial = zed.get_camera_information().serial_number
print("Hello! This is my serial number: ", zed_serial)

(4) Turn off the camera

# Close the camera
zed.close()
return 0

complete program 

import pyzed.sl as sl


def main():
    # Create a Camera object
    zed = sl.Camera()

    # Create a InitParameters object and set configuration parameters
    init_params = sl.InitParameters()
    init_params.sdk_verbose = False

    # Open the camera
    err = zed.open(init_params)
    if err != sl.ERROR_CODE.SUCCESS:
        exit(1)

    # Get camera information (ZED serial number)
    zed_serial = zed.get_camera_information().serial_number
    print("Hello! This is my serial number: {0}".format(zed_serial))

    # Close the camera
    zed.close()

if __name__ == "__main__":
    main()

Guess you like

Origin blog.csdn.net/kchenlyee/article/details/130693662