Skip to main content

Quick Start

This program connects by serial number and requests a rectified image and depth map from the same frame:

from time import sleep
from xensesdk import Sensor


def main():
sensor = Sensor.create("OP000064")
try:
# Captures continuously until you press Ctrl+C to stop
while True:
rectify, depth = sensor.selectSensorInfo(
Sensor.OutputType.Rectify,
Sensor.OutputType.Depth,
)
if rectify is not None:
print("rectify:", rectify.shape, rectify.dtype)
if depth is not None:
print("depth:", depth.shape, depth.dtype)
sleep(0.02)
except KeyboardInterrupt:
# Exit gracefully after Ctrl+C
print("Capture stopped")
finally:
# Release the sensor on normal exit or interruption
sensor.release()


if __name__ == "__main__":
main()

Select a source​

Sensor.create(0) # local camera index
Sensor.create("OP000064") # sensor serial number
Sensor.create("OP000064", mac_addr="...") # sensor on a compute unit
Sensor.create("OP000064", infer_mode="small") # select an inference mode
Sensor.create(0, disable_infer=True) # verify acquisition only

Do not open the same sensor repeatedly from multiple threads. Use finally to release camera handles and inference workers in long-running applications.

More code examplesBrowse examples for local and remote connections, output types, and data processing.
Open GitHub examples ↗

If an example does not cover your use case, describe it in the project Issues.