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.
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
# Specify the MAC address to connect to the remote sensor
master_service = "master_000000000000"
sensor = Sensor.create('OP000064', mac_addr="000000000000")
# Release resources after use
sensor.release()
tips
You can refer to how to get the master_service in Example 3. EzROS.