/* Check the device Licence or Activate it */ private void ActivateDevice() { bool device_activated = Convert.ToBoolean(_device.GetActivationStatus()); Console.Clear(); while (!device_activated) { Console.WriteLine("Your device license is not activated\nEnter the activation key (or get one at https://cognitive.3divi.com/app/nuitrack/dashboard/): "); string activationKey = Console.ReadLine(); _device.Activate(activationKey); device_activated = Convert.ToBoolean(_device.GetActivationStatus()); } Console.WriteLine("Activation status: {0}", _device.GetActivationStatus().ToString()); }
static public void Main() { Console.CancelKeyPress += new ConsoleCancelEventHandler(consoleEventHandler); try { Nuitrack.Init(""); // get devices list List <NuitrackDevice> devices = Nuitrack.GetDeviceList(); if (devices.Count == 0) { throw new nuitrack.Exception("No devices found."); } // print available devices Console.Write("\nAvailable devices:\n"); for (int i = 0; i < devices.Count; i++) { Console.WriteLine(" [{0}] {1} ({2}), License: {3}", i, devices[i].GetInfo(DeviceInfoType.SERIAL_NUMBER), devices[i].GetInfo(DeviceInfoType.DEVICE_NAME), ToString(devices[i].GetActivationStatus())); } // select a device int devIndex = UserInteraction.AskInt("\nSelect the device number: ", 0, devices.Count); NuitrackDevice device = devices[devIndex]; // select video modes selectDeviceVideoMode(device, StreamType.DEPTH); selectDeviceVideoMode(device, StreamType.COLOR); // activate selected device bool isActivated = Convert.ToBoolean(device.GetActivationStatus()); if (isActivated) { isActivated = !UserInteraction.Confirm("The device is already activated. Do you want to reactivate it?"); } if (!isActivated) { string activationKey = UserInteraction.AskString("Enter the activation key: "); device.Activate(activationKey); Console.WriteLine("Activation status: {0}", ToString(device.GetActivationStatus())); } // set device and run Nuitrack if (UserInteraction.Confirm("Do you want to run Nuitrack with the selected device?")) { Nuitrack.SetDevice(device); DepthSensor depthSensor = DepthSensor.Create(); ColorSensor colorSensor = ColorSensor.Create(); depthSensor.OnUpdateEvent += onDepthSensorUpdate; colorSensor.OnUpdateEvent += onColorSensorUpdate; Nuitrack.Run(); _run = true; while (!_finished) { Nuitrack.WaitUpdate(depthSensor); } colorSensor.OnUpdateEvent -= onColorSensorUpdate; depthSensor.OnUpdateEvent -= onDepthSensorUpdate; } Nuitrack.Release(); } catch (nuitrack.Exception exception) { Console.WriteLine("Error: " + exception.ToString()); } }