Esempio n. 1
0
    static private void selectDeviceVideoMode(NuitrackDevice device, StreamType stream)
    {
        List <VideoMode> modes = device.GetAvailableVideoModes(stream);

        if (stream == StreamType.DEPTH)
        {
            Console.WriteLine("Available depth video modes:");
        }
        else if (stream == StreamType.COLOR)
        {
            Console.WriteLine("Available color video modes:");
        }

        for (int vm = 0; vm < modes.Count; vm++)
        {
            Console.WriteLine("    [{0}] {1} x {2} @ {3} fps",
                              vm,
                              modes[vm].width,
                              modes[vm].height,
                              modes[vm].fps);
        }
        Console.WriteLine("(WARNING: not all video modes are supported)");

        int vmIdx = UserInteraction.AskIntDefault("\nSelect the video mode", 0, modes.Count, -1);

        if (vmIdx != -1)
        {
            device.SetVideoMode(stream, modes[vmIdx]);
        }
    }
Esempio n. 2
0
        /* Initialize the Nuitrack Environment */
        private void Initialize()
        {
            try {
                Nuitrack.Init("");
            }
            catch (nuitrack.Exception exception) {
                Console.WriteLine("Cannot initialize Nuitrack.");
                throw exception;
            }
            // Select the device
            _device = SelectDevice();

            // Select video configurations
            _configVideo = SelectVideoMode();


            // Activate the license
            ActivateDevice();

            Nuitrack.SetDevice(_device);

            // Add modules Sensors
            _depthSensor     = DepthSensor.Create();
            _colorSensor     = ColorSensor.Create();
            _userTracker     = UserTracker.Create();
            _skeletonTracker = SkeletonTracker.Create();

            // Add modules Events Handlers
            _depthSensor.OnUpdateEvent             += onDepthSensorUpdate;
            _colorSensor.OnUpdateEvent             += onColorSensorUpdate;
            _userTracker.OnUpdateEvent             += onUserTrackerUpdate;
            _userTracker.OnNewUserEvent            += onUserTrackerNewUser;
            _userTracker.OnLostUserEvent           += onUserTrackerLostUser;
            _skeletonTracker.OnSkeletonUpdateEvent += onSkeletonUpdate;

            // Connect to remote
            _streamer = SelectStreamer();


            // Run Nuitrack
            Nuitrack.Run();
            _running = true;

            Console.WriteLine("Nuitrack is Running...");
        }
Esempio n. 3
0
    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());
        }
    }