ni-hello

Overview

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

Expect Output

Device found.
Name: LIPSTS800
URI: \\?\usb#vid_2df2&pid_0213#200901010001#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
USB Product ID: 531
USB Vendor ID: 11762
Vendor: LIPS

Tutorial

  • Import openni packages

using System;
using System.Threading;
using OpenNIWrapper;
  • Initialize SDK

OpenNI.Initialize();
  • Scan connected devices

OpenNI.OnDeviceConnected += OpenNiOnDeviceConnected;
OpenNI.OnDeviceDisconnected += OpenNiOnDeviceDisconnected;
DeviceInfo[] devices = OpenNI.EnumerateDevices();
  • Get info for each device

 DeviceInfo[] devices = OpenNI.EnumerateDevices();
if (devices.Length == 0)
{
    Console.WriteLine("Cannot find available OpenNI2 device.\n");
}
else
{
    DeviceInfo info = devices[0];
    Console.WriteLine("\nDevice found.");
    Console.WriteLine("Name: " + info.Vendor + info.Name);
    Console.WriteLine("URI: " + info.Uri);
    Console.WriteLine("USB Product ID: " + info.UsbProductId);
    Console.WriteLine("USB Vendor ID: " + info.UsbVendorId);
    Console.WriteLine("Vendor: " + info.Vendor);
}
  • Connect to the first found device

Device device = devices[0].OpenDevice();
  • Close camera and deconstruct OpenNI SDK

OpenNI.Shutdown();
Environment.Exit(0);

Full code

NiHello.Net

Last updated