Ejemplo 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]);
        }
    }
Ejemplo n.º 2
0
        /* Load the List of available Modes and Select the Video Mode */
        private VideoMode SelectVideoMode()
        {
            StreamType stream = StreamType.DEPTH;

            // List availaible video modes
            List <VideoMode> modes = _device.GetAvailableVideoModes(stream);
            int modes_count        = modes.Count;

            Console.Clear();

            // Check for an Empty List
            if (modes_count == 0)
            {
                Console.WriteLine("Error: there is no video mode for this device."); throw new nuitrack.Exception("Error: there is no video mode for this device.");
            }

            // Format the VideoModes to String and output the array
            Console.WriteLine("Available {0} modes:", stream.ToString());
            for (int i = 0; i < modes_count; i++)
            {
                Console.WriteLine(" * Mode {0}: \t({1}px x {2}px) @ {3}fps", i, modes[i].width, modes[i].height, modes[i].fps);
            }

            // Select a Mode
            Console.WriteLine("Select a Mode (Write a number or just press ENTER to select the mode 0");
            int selected = -1;

            while (selected == -1)
            {
                string input = Console.ReadLine();

                // Default Input
                if (input == "")
                {
                    selected = 0;
                    break;
                }

                // Numeric input : Check that the input is valid
                if (int.TryParse(input, out selected))
                {
                    if (selected > modes_count - 1 || selected < 0)
                    {
                        selected = -1;
                        Console.SetCursorPosition(0, 2 + modes_count); Console.Write(new string(' ', Console.WindowWidth));
                        Console.SetCursorPosition(0, 3 + modes_count); Console.Write(new string(' ', Console.WindowWidth));
                        Console.SetCursorPosition(0, 2 + modes_count);
                        Console.WriteLine("Bad entry: there is only {0} modes fo this device. Enter a number equal or lower than {1}.", modes_count, modes_count - 1);
                    }
                }
                else
                {
                    selected = -1;
                    Console.SetCursorPosition(0, 2 + modes_count); Console.Write(new string(' ', Console.WindowWidth));
                    Console.SetCursorPosition(0, 3 + modes_count); Console.Write(new string(' ', Console.WindowWidth));
                    Console.SetCursorPosition(0, 2 + modes_count);
                    Console.WriteLine("Bad entry: you must write an integer equal or lower than {0}", modes_count - 1);
                }
            }

            // Return the selected VideoMode
            _device.SetVideoMode(StreamType.DEPTH, modes[selected]);
            _device.SetVideoMode(StreamType.COLOR, modes[selected]);
            return(modes[selected]);
        }