XenseSDK 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():
# You can also pass camera index 0/1, or mac_addr for a remote connection
sensor = Sensor.create("OP000064", use_gpu=True)
try:
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)
finally:
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(None, video_path="sample.mp4") # offline video
Do not open the same sensor repeatedly from multiple threads. Use finally to release camera handles and inference workers in long-running applications.