create Method

Sensor.create(cam_id=0, use_gpu=True, config_path=None, api=None, check_serial=True, rectify_size=None, mac_addr=None, video_path=None)

Creates a sensor instance. After use, call release() to free up resources.

Parameters:
  • cam_id (int | str, optional) – Sensor ID, serial number, or video path. Defaults to 0.

  • use_gpu (bool, optional) – Whether to use GPU for inference.

  • config_path (str | Path, optional) – Path or directory of the configuration file. If it is a directory, it must contain a calibration file with the same name as the sensor serial number.

  • api (Enum, optional) – Camera API type (e.g., OpenCV backend), used to specify the camera access method.

  • check_serial (bool, optional) – Whether to check the sensor serial number.

  • rectify_size (tuple[int, int], optional) – Rectified image size (width, height).

  • mac_addr (str, optional) – Camera MAC address used for remote connection.

Returns:

Sensor instance, used for subsequent data collection and processing.

Return type:

Sensor

Note

After use, be sure to call release() to free up system resources.

Example Code

from xensesdk import Sensor

# Create an instance using the sensor serial number (SN)
sensor = Sensor.create('OP000064')

# Release resources after use
sensor.release()
from xensesdk import Sensor

# Create an instance using the camera ID (e.g., 0, 1)
sensor = Sensor.create(0)

# Release resources after use
sensor.release()
from xensesdk import Sensor

# Load local data via video_path (set cam_id to None)
sensor = Sensor.create(None, video_path=r"data.h5")

# Release resources after use
sensor.release()
from xensesdk import Sensor

# Specify the IP address to connect to the remote sensor
sensor = Sensor.create('OP000064', ip_address="192.168.66.66")

# Release resources after use
sensor.release()

tips

The mac_address parameter in Example 4 is compatible with the device IP address. For instructions on how to obtain the device MAC address, refer to EzROS.