Python

Description

The Python SDK mainly uses three utility libraries to facilitate calls:

  1. requests - Used to send HTTP requests

  2. numpy - Used for convenient manipulation of matrix data

  3. opencv-python - Used for storing image data

Interface Definition

Function Name Description Parameters and Return Values

get_sdk_version()

Get the SDK version number

Parameters: None

Return value:

version: str type, SDK version number

get_info(ip: str)

Get basic camera information, including serial number, IP address, model, and other device parameters. Returns None if retrieval fails.

Parameters:

ip: str type, IP address of the camera

Return value:

info: dict type, contains the following fields:

* sn: str type, camera serial number

* ip: str type, camera IP address

* model: str type, camera model

* alias: str type, camera name

* width: int type, image width

* height: int type, image height

get_header(ip: str, frame_id: str, timeout: int = 2000)

Get camera photo information, including width and height. Returns None if retrieval fails.

Parameters:

ip: str type, IP address of the camera

frame_id: str type, frame ID of the camera

timeout: int type, timeout duration in milliseconds, default is 2000 ms

Return value:

header: dict type, camera photo information including width and height

get_config(ip: str, frame_id: str = "")

Get the current or specified frame configuration parameters of the camera. Returns None if retrieval fails.

Parameters:

ip: str type, IP address of the camera

frame_id: str type, frame ID of the data to be retrieved. If an empty string is passed, the latest configuration will be returned.

Return value:

config: dict type, camera configuration parameters

set_config(ip: str, config: dict)

Update camera configuration parameters. Returns the current configuration if successful, or None if failed.

Parameters:

ip: str type, IP address of the camera

config: dict type, configuration parameters, defined the same as in get_config

Return value:

latest_config: dict type, the updated current configuration of the camera, defined the same as config

trigger_frame(ip: str, pointcloud: bool = True)

Trigger the capture of a frame, which may contain both 2D images and point cloud data. Uses frame ID for indexing. Returns None if failed.

Parameters:

ip: str type, IP address of the camera

pointcloud: bool type, whether to request point cloud data. If set to False, the triggered frame will contain only 2D image data.

Return value:

frame_id: str type, frame ID returned after triggering the capture

get_image(ip: str, frame_id: str)

Retrieve a 2D image based on the frame ID. Returns None if failed.

Parameters:

ip: str type, IP address of the camera

frame_id: str type, frame ID of the data to be retrieved, which can be obtained from trigger_frame

Return value:

image: numpy.ndarray type, retrieved image data

get_point_cloud(ip: str, frame_id: str)

Retrieve the point cloud based on the frame ID. Returns None if failed.

Parameters:

ip: str type, IP address of the camera

frame_id: str type, frame ID of the data to be retrieved, which can be obtained from trigger_frame

Return value:

point_map: numpy.ndarray type, point cloud data aligned pixel-wise with the 2D image

get_point_cloud_with_time_stats(ip: str, frame_id: str)

Retrieve the point cloud along with network transmission statistics based on the frame ID. Returns None if failed.

Parameters:

ip: str type, IP address of the camera

frame_id: str type, frame ID of the data to be retrieved, which can be obtained from trigger_frame

Return value:

point_map: numpy.ndarray type, point cloud data aligned pixel-wise with the 2D image

network_transmit_time_ms: float type, network transmission time in milliseconds

network_speed_mbps: float type, network transmission speed in Mbps

get_image_and_point_cloud(ip: str, frame_id: str)

Retrieve both 2D image and point cloud data based on the frame ID. Returns None if failed.

Parameters:

ip: str type, IP address of the camera

frame_id: str type, frame ID of the data to be retrieved, which can be obtained from trigger_frame

Return value:

image: numpy.ndarray type, retrieved image data

point_map: numpy.ndarray type, point cloud data aligned pixel-wise with the 2D image

get_image_and_point_cloud_with_time_stats(ip: str, frame_id: str)

Retrieve both 2D image and point cloud data along with network transmission statistics based on the frame ID. Returns None if failed.

Parameters:

ip: str type, IP address of the camera

frame_id: str type, frame ID of the data to be retrieved, which can be obtained from trigger_frame

Return value:

image: numpy.ndarray type, retrieved image data

point_map: numpy.ndarray type, point cloud data aligned pixel-wise with the 2D image

network_transmit_time_ms: float type, network transmission time in milliseconds

network_speed_mbps: float type, network transmission speed in Mbps

get_depth(ip: str, frame_id: str)

Retrieve the depth map based on the frame ID. Returns None if failed.

Parameters:

ip: str type, IP address of the camera

frame_id: str type, frame ID of the data to be retrieved, which can be obtained from trigger_frame

Return value:

depth: numpy.ndarray type, depth data aligned pixel-wise with the 2D image

get_camera_matrix(ip: str)

Retrieve the camera intrinsic matrix.

Parameters:

ip: str type, IP address of the camera

Return value:

camera_matrix: numpy.ndarray type, camera matrix stored row-wise, can be reshaped into a 3x3 matrix, compatible with OpenCV

get_distortion(ip: str)

Retrieve the camera distortion coefficients.

Parameters:

ip: str type, IP address of the camera

Return value:

distortion: numpy.ndarray type, distortion parameters, compatible with OpenCV

get_point_cloud_in_ply(ip: str, frame_id: str)

Retrieve point cloud data in PLY format. Returns None if failed.

Parameters:

ip: str type, IP address of the camera

frame_id: str type, frame ID of the data to be retrieved, which can be obtained from trigger_frame

Return value:

ply_data: bytes type, point cloud data in PLY format

search_camera()

Search for available camera devices on the network. Returns None if no cameras are found.

Parameters: None

Return value:

found_camera: list type, list of found camera information

Running on Linux

Most Debian-based Linux systems come with Python pre-installed.

Follow the steps in the README.md file of the Python sample program.

Running on Windows

Refer to Python on Windows for beginners to set up the Python environment.

Follow the steps in the README.md file of the Python sample program.