Beispiel #1
0
        /// <summary>
        /// Driver
        /// </summary>
        /// <param name="args">
        /// A <see cref="System.String[]"/>
        /// </param>
        public static void Main(string[] args)
        {
            Console.WriteLine("----------------------------------------");
            Console.WriteLine("| Kinect.NET Wrapper Test              |");
            Console.WriteLine("----------------------------------------\n");

            // Try to get number of devices connected
            Console.WriteLine(" - Device Count: " + Kinect.DeviceCount);

            // Do more tests if there are devices present
            if (Kinect.DeviceCount > 0)
            {
                // Try to open a device
                Kinect k = new Kinect(0);
                Console.Write(" - Opening device 0...");
                k.Open();
                Console.WriteLine("Done.");

                // Try to set LED colors
                Console.WriteLine(" - LED Testing");
                string[] colors = Enum.GetNames(typeof(LEDColor));
                foreach (string color in colors)
                {
                    var c = (LEDColor)Enum.Parse(typeof(LEDColor), color);
                    Console.WriteLine("\t - Setting LED to Color: " + color);
                    k.LED.Color = c;
                    Thread.Sleep(3000);
                }

                // Try to control motor
                Console.WriteLine(" - Motor Testing");
                Console.WriteLine("\t - Setting tilt to 1 (should face all the way up)");
                k.Motor.Tilt = 1;
                Thread.Sleep(3000);
                Console.WriteLine("\t - Setting tilt to -1 (should face all the way down)");
                k.Motor.Tilt = -1;
                Thread.Sleep(3000);
                Console.WriteLine("\t - Setting tilt to 0 (should be back level)");
                k.Motor.Tilt = 0;
                Thread.Sleep(3000);

                // Close device
                Console.Write(" - Closing device 0...");
                k.Close();
                Console.WriteLine("Done.");
            }

            // Shutdown the Kinect context
            Kinect.Shutdown();

            // Pause...
            Console.ReadKey(true);
        }
Beispiel #2
0
 internal override void Destroy()
 {
     if (!Destroyed)
     {
         FPSTimer.Dispose();
         XKinect.LED.Color = LEDColor.BlinkGreen;
         XKinect.Close();
         StopARE.Dispose();
         BufferReleaseARE.Dispose();
         Destroyed = true;
     }
 }
Beispiel #3
0
        public static void Main()
        {
            int    LCD_RS       = 12;
            int    LCD_E        = 16;
            int    LCD_DATA4    = 6;
            int    LCD_DATA5    = 13;
            int    LCD_DATA6    = 19;
            int    LCD_DATA7    = 26;
            Thread updateThread = null;

            Console.WriteLine("Debug Hook v3");
            Console.ReadKey();

            Console.WriteLine("Initialisiere LCD");
            LCD LCD = new LCD(LCD_RS, LCD_E, LCD_DATA4, LCD_DATA5, LCD_DATA6, LCD_DATA7);

            LCD.InitializeLCD();

            /*
             * Console.WriteLine("Teste EmguCV");
             * String win1 = "Test Window"; //The name of the window
             * CvInvoke.NamedWindow(win1); //Create the window using the specific name
             *
             * Mat img = new Mat(200, 400, DepthType.Cv8U, 3); //Create a 3 channel image of 400x200
             * img.SetTo(new Bgr(255, 0, 0).MCvScalar); // set it to Blue color
             *
             * //Draw "Hello, world." on the image using the specific font
             * CvInvoke.PutText(
             *  img,
             *  "Hello Bibi",
             *  new System.Drawing.Point(10, 80),
             *  FontFace.HersheyComplex,
             *  1.0,
             *  new Bgr(0, 0, 0).MCvScalar);
             *
             * CvInvoke.Imshow(win1, img); //Show the image
             * CvInvoke.DestroyWindow(win1); //Destroy the window if key is pressed
             * Console.WriteLine("EmguCV Test abgeschlossen.");*/

            Console.WriteLine("Initialisiere Kinect.");
            Kinect kinect = new Kinect(0);

            Init(kinect);
            Console.WriteLine("Kinect initialisiert.");

            Console.WriteLine("Soll ein Servotest durchgeführt werden? [y/n]");
            if (Console.ReadKey().KeyChar.Equals("y"))
            {
                Console.WriteLine("Servotest wird ausgeführt.");
                ServoTest(kinect);
            }
            else
            {
                Console.WriteLine("Servotest wird übersprungen.");
            }

            Console.WriteLine("In welchem Modus soll die Tiefenkamera arbeiten?");
            for (int i = 0; i < kinect.DepthCamera.Modes.Length; i++)
            {
                Console.WriteLine(i + " - " + kinect.DepthCamera.Modes[i]);
            }
            var input_tiefe = Convert.ToInt32(Console.ReadLine());

            kinect.DepthCamera.Mode = kinect.DepthCamera.Modes[input_tiefe];
            Console.WriteLine("Tiefenkamera arbeitet im Modus " + kinect.DepthCamera.Mode);


            Console.WriteLine("In welchem Modus soll die Farbkamera arbeiten?");
            for (int i = 0; i < kinect.VideoCamera.Modes.Length; i++)
            {
                Console.WriteLine(i + " - " + kinect.VideoCamera.Modes[i]);
            }
            var input_rgb = Convert.ToInt32(Console.ReadLine());

            kinect.VideoCamera.Mode = kinect.VideoCamera.Modes[input_rgb];
            Console.WriteLine("Farbkamera arbeitet im Modus " + kinect.VideoCamera.Mode);

            Console.WriteLine("Erstelle Thread zum Updaten des Kinects.");
            updateThread = new Thread(delegate()
            {
                try
                {
                    kinect.UpdateStatus();
                    Kinect.ProcessEvents();
                }
                catch (ThreadInterruptedException e)
                {
                    return;
                }
                catch (Exception ex)
                {
                }
            });
            updateThread.Start();


            while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
            {
                Console.WriteLine("Tiefenkamera FPS: " + kinect.DepthCamera.Mode.FrameRate);
                Console.WriteLine("Farbkamera FPS: " + kinect.VideoCamera.Mode.FrameRate);

                LCD.SendMessage("X=" + Math.Round(kinect.Accelerometer.X, 2).ToString() + " Y=" + Math.Round(kinect.Accelerometer.Y, 2).ToString(), 1);
                LCD.SendMessage("Z=" + Math.Round(kinect.Accelerometer.Z, 2).ToString(), 2);
                Thread.Sleep(250);
                kinect.UpdateStatus();
            }

            Console.WriteLine("Programm beendet.");
            Console.ReadKey();
            LCD.Clear();
            LCD = null;
            kinect.Close();
            Kinect.Shutdown();
            kinect = null;
        }
 //Used to tidy up when application is exited
 void OnApplicationQuit()
 {
     Debug.Log("Application ending after " + Time.time + " seconds, closing kinect gracefully.");
     kinect.LED.Color = LEDColor.BlinkGreen;
     kinect.Close();
 }