ni-hello

Overview

This example shows how to connect to camera and get device info.

  • Import openni package

from openni import openni2
  • Initialize SDK and specify OpenNI Redist folder.

openni2.initialize('/path/to/Openni SDK/Redist')
  • Scan connected devices

uris = openni2.Device.enumerate_uris()
print(uris) # [b'USB#VID_2DF2&PID_0213&REV_0007&BUS_02&ADR_06']
  • Connect to camera and get camera device info

    Or you can use openni2.Device.open_any() to connect to the first found device.

dev = openni2.Device.open_file(uris[0])
deviceInfo = dev.get_device_info()
print(f'Name: {deviceInfo.name}')
print(f'Uri: {deviceInfo.uri}')
print(f'USB Product ID: {deviceInfo.usbProductId}')
print(f'USB Vendor ID: {deviceInfo.usbVendorId}')
print(f'Vendor: {deviceInfo.vendor}')
  • Output

Name: b'TS800'
Uri: b'USB#VID_2DF2&PID_0213&REV_0007&BUS_02&ADR_0C'
USB Product ID: 531
USB Vendor ID: 11762
Vendor: b'LIPS'
  • Close camera and deconstruct OpenNI SDK

dev.close()
openni2.unload()

Full code

ni-hello.py

Last updated