This example shows how to connect to camera and get device info.
Name:TS800
Uri:USB#VID_2DF2&PID_0213&REV_0007&BUS_02&ADR_10
USB Product ID:531
USB Vendor ID:11762
Vendor:LIPS
#include <openni2/OpenNI.h>
if (openni::OpenNI::initialize() != openni::STATUS_OK)
{
printf("Initialize Failed:%s\n", openni::OpenNI::getExtendedError());
return -1;
}
openni::Array<openni::DeviceInfo> deviceList;
openni::OpenNI::enumerateDevices(&deviceList);
Or you can use open(openni::ANY_DEVICE)
to connect to the first found device.
for (int i = 0; i < deviceList.getSize(); i++)
{
openni::DeviceInfo info = deviceList[i];
printf("Name:%s\n", info.getName());
printf("Uri:%s\n", info.getUri());
printf("USB Product ID:%s\n", info.getUsbProductId());
printf("USB Vendor ID:%s\n", info.getUsbVendorId());
printf("Vendor:%s\n", info.getVendor());
}
openni::Device device;
if (device.open(deviceList[0].getUri()) != openni::STATUS_OK)
{
printf("Cannot open device: %s\n", openni::OpenNI::getExtendedError());
return -1;
}
device.close();
openni::OpenNI::shutdown();