Example #1
0
        public void Evaluate(int SpreadMax)
        {
            if (leapcontroller != null && leapcontroller.IsConnected && leapcontroller.IsServiceConnected && leapcontroller.Devices.Count > 0)
            {
                FDevice.SliceCount     = 1;
                FController.SliceCount = 1;
                FFrame.SliceCount      = 1;

                FDevice[0]     = leapdevice;
                FController[0] = leapcontroller;
                FFrame[0]      = leapcontroller.Frame(0);
                leapdevice     = leapcontroller.Devices[0];
            }
            else
            {
                FDevice.SliceCount     = 0;
                FController.SliceCount = 0;
                FFrame.SliceCount      = 0;
            }
            if (FReinit[0] || FirstFrame)
            {
                if (leapcontroller != null)
                {
                    leapcontroller.Dispose();
                }
                leapinit();
                FirstFrame = false;
            }
            GlobalScale            = FScale[0];
            GlobalZMul             = (FMirror[0]) ? -1 : 1;
            AgeCorrectionThreshold = FAgeThreshold[0];
        }
Example #2
0
        static void Main(string[] args)
        {
            CustomListener listener = new CustomListener();
            Controller controller = new Controller();
            controller.AddListener(listener);

            Console.ReadKey();
            controller.Dispose();
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.Title = "Leap Mousion v2.0";
            Console.WriteLine("Leap Mousion v2.0 by TangoChen    :)\r\n------------------------------------\r\nBlog: TangoChen.com\r\nYoutube Channel: www.youtube.com/tan9ochen\r\n--------------------\r\nTwitter:\ttwitter.com/tangochen\t@TangoChen\r\n微博(Weibo):\tweibo.com/tangochen\t@TangoChen\r\n--------------------\r\nPress any key to exit...\r\n--------------------");

            // Create a sample listener and controller
            SampleListener listener = new SampleListener();
            Controller controller = new Controller();

            foreach (string arg in args)
            {
                switch (arg.Substring(0, 1).ToLower())
                {
                    case "l": // L = Set isLeftHanded = true;
                        listener.isLeftHanded = true;
                        break;
                    case "s": // Scale
                        float.TryParse(arg.Substring(1), out listener.moveScale);
                        break;
                    case "r": // Reverse Orientation
                        /*
                         * It won't just reverse the horizontal axes but also change the fingerIndex...
                         * So this is used when the device get reversed horizontal axes
                         * and you don't want to click the [Reverse Orientation] inside the [Leap Motion Controller Settings] or
                         * rotate the device...
                         */
                        listener.isReversed = true;
                        break;
                    case "c": // Click-Only
                        listener.isClickOnly = true;
                        break;
                }
            }

            Console.WriteLine(
                "Speed: " + listener.moveScale.ToString() +
                "\r\nClick-Only: " + listener.isClickOnly.ToString() +
                "\r\nReversed: " + listener.isReversed.ToString() +
                "\r\nLeft Handed Mode: " + (listener.isLeftHanded ? "Enabled" : "Disabled") +
                "\r\n--------------------"
                );

            // Receive frames of tracking data while in the background
            controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);

            // Have the sample listener receive events from the controller
            controller.AddListener(listener);

            // Keep this process running until any key is pressed
            Console.ReadKey(true); //System.Diagnostics.Process.Start("pause"); Won't work...

            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }
        static void Main(string[] args)
        {
            ReportingListener listener = new ReportingListener(new Reporter());
            Controller controller = new Controller();
            controller.AddListener(listener);

            Console.WriteLine("Listening! Press any key when you're finished to exit.");
            Console.ReadKey();

            controller.RemoveListener(listener);
            controller.Dispose();
        }
Example #5
0
        public AppModel()
        {
            var controller = new Controller();
            var listener = new FrameListener();
            controller.AddListener(listener);

            AppDomain.CurrentDomain.ProcessExit += (o, e) =>
            {
                controller.RemoveListener(listener);
                listener.Dispose();
                controller.Dispose();
            };

            listener.FrameArrived += listener_FrameArrived;
        }
Example #6
0
        static void Main(string[] args)
        {
            Controller controller = new Leap.Controller(); // initialize the leap controller

            while (!controller.IsConnected)
            {
            }                                                                                                     // wait for it to connect

            PhaseModulationProvider pmProvider = new PhaseModulationProvider(440, (440f / 2f), 0.5f, 0.5f, 0.2f); // initialize the pm oscillator

            MixingSampleProvider mixer = new MixingSampleProvider(new[] { pmProvider });

            mixer.ReadFully = true;

            SynthController synthController = new SynthController(pmProvider, 0.1f);                       // initialize the object that controls the synth with leap

            WaveOut audioOut = new WaveOut();                                                              // hear things

            audioOut.Init(mixer);                                                                          // give it the oscillator

            audioOut.Play();                                                                               // play it

            RenderWindow window = new RenderWindow(new VideoMode(200, 200), "Test Window, Please Ignore"); // make the sfml window

            window.Closed += (object sender, EventArgs e) =>                                               // so I can close it
            {
                RenderWindow w = sender as RenderWindow;
                controller.Dispose();
                w.Close();
            };

            window.KeyPressed += (object sender, KeyEventArgs e) =>
            {
                if (e.Code == Keyboard.Key.Escape)
                {
                    RenderWindow w = sender as RenderWindow;
                    w.Close();
                }
            };

            while (window.IsOpen) // main loop
            {
                synthController.HandleFrame(controller);
                window.DispatchEvents();
                window.Clear();
                window.Display();
            }
        }
Example #7
0
        static void Main(string[] args)
        {
            Controller controller = new Leap.Controller(); // initialize the leap controller

            while (!controller.IsConnected) { } // wait for it to connect

            PhaseModulationProvider pmProvider = new PhaseModulationProvider(440, (440f / 2f), 0.5f, 0.5f, 0.2f); // initialize the pm oscillator

            MixingSampleProvider mixer = new MixingSampleProvider(new[] { pmProvider });

            mixer.ReadFully = true;

            SynthController synthController = new SynthController(pmProvider, 0.1f); // initialize the object that controls the synth with leap

            WaveOut audioOut = new WaveOut(); // hear things

            audioOut.Init(mixer); // give it the oscillator

            audioOut.Play(); // play it

            RenderWindow window = new RenderWindow(new VideoMode(200, 200), "Test Window, Please Ignore"); // make the sfml window

            window.Closed += (object sender, EventArgs e) => // so I can close it
            {
                RenderWindow w = sender as RenderWindow;
                controller.Dispose();
                w.Close();
            };

            window.KeyPressed += (object sender, KeyEventArgs e) =>
            {
                if (e.Code == Keyboard.Key.Escape)
                {
                    RenderWindow w = sender as RenderWindow;
                    w.Close();
                }
            };

            while (window.IsOpen) // main loop
            {
                synthController.HandleFrame(controller);
                window.DispatchEvents();
                window.Clear();
                window.Display();
            }
        }
Example #8
0
        public static void Main()
        {
            // Create a sample listener and controller
            var listener = new LeapListener();
            var controller = new Controller();

            // Have the sample listener receive events from the controller
            controller.AddListener(listener);

            // Keep this process running until Enter is pressed
            Console.WriteLine("Press Enter to quit...");
            Console.ReadLine();

            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }
        public static void Main()
        {
            // Create a sample listener and controller
            SampleListener listener = new SampleListener();
            Controller controller = new Controller();

            // Have the sample listener receive events from the controller
            controller.AddListener(listener);

            // Keep this process running until Enter is pressed
            Console.WriteLine("Press Enter to quit...");
            Console.ReadLine();

            //used to keep things running when set to windows application build mode.
            while (listener != null)
            {

            }
            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }
Example #10
0
        void Read( ref SampleListener Listener, ref Controller Controller)
        {
            // Have the sample listener receive events from the controller
            Controller.AddListener(Listener);

            while (!StopRead)
            {
                //Do thing here
                //The listener class is gathering our data
            }

            // Remove the sample listener when done
            Controller.RemoveListener(Listener);
            Controller.Dispose();
            Listener.Dispose();
        }
Example #11
0
        public static List<List<Frame>> LoadListListFrame(string path)
        {
            List<List<Frame>> listListF = new List<List<Frame>>();
            Stream readStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
            IFormatter formatter = new BinaryFormatter();
            List<List<byte[]>> listListB = (List<List<byte[]>>)formatter.Deserialize(readStream);
            readStream.Close();

            Controller control = new Controller();
            for (int i = 0; i < listListB.Count; i++)
            {
                List<Frame> listF = new List<Frame>();
                for (int j = 0; j < listListB[i].Count; j++)
                {
                    Frame f = new Frame();
                    f.Deserialize(listListB[i][j]);
                    listF.Add(f);
                }
                listListF.Add(listF);
            }
            control.Dispose();

            return listListF;
        }
Example #12
0
 public static Frame LoadFrame(string path)
 {
     byte[] frameData = System.IO.File.ReadAllBytes(path);
     Controller control = new Controller();
     Frame f = new Frame();
     f.Deserialize(frameData);
     control.Dispose();
     return f;
 }
 void Exit()
 {
     controller.RemoveListener(listener);
     controller.Dispose();
 }
Example #14
0
        static void Main(string[] args)
        {
            // Create a sample listener and controller
            GestureListener listener = new GestureListener();
            Controller controller = new Controller();

            listener.Gestures.GestureReceived += Gestures_GestureReceived;

            // Have the sample listener receive events from the controller
            controller.AddListener(listener);

            // Keep this process running until Enter is pressed
            Console.WriteLine("Press Enter to quit...");

            while (true)
            {
                var key = Console.ReadKey(true);

                if (key.Key == ConsoleKey.Enter)
                {
                    break;
                }

                switch (key.Key)
                {
                    case ConsoleKey.D1:
                        listener.Gestures.StartTraining();
                        Console.WriteLine("Training...");
                        break;

                    case ConsoleKey.D2:
                        listener.Gestures.StopTraining();
                        Console.WriteLine("Recorded gesture.");
                        break;

                    case ConsoleKey.D3:
                        var model = listener.Gestures.FinishTrainingSession();
                        Console.WriteLine("Enter a name for this gesture:");
                        var name = Console.ReadLine();
                        model.Name = name;
                        Console.WriteLine(String.Format("Completed training of gesture {0}.", name));
                        break;

                    case ConsoleKey.D4:
                        listener.Gestures.StartRecognition();
                        Console.WriteLine("Recognizing...");
                        break;

                    case ConsoleKey.D5:
                        listener.Gestures.StopRecognition();
                        break;
                }
            }

            // Remove the sample listener when done
            controller.RemoveListener(listener);
            controller.Dispose();
        }
Example #15
0
        public void Read(string path)
        {
            RecordListener listener = new RecordListener();
            listener.Initialization(numOfFramesPerRead, this);
            Controller controller = new Controller();
            controller.AddListener(listener);

            actualNumOfReads = 0;
            Console.WriteLine("Press enter to start reading frames to file " + path);
            Console.ReadLine();
            state = RecorderState.Idle;

            while (state != RecorderState.Saving)
            {
                Console.WriteLine("num: " + (actualNumOfReads + 1) + " in " + numOfReads);
                if (!isAuto)
                {
                    Console.ReadLine();
                }
                state = RecorderState.Reading;
                Console.WriteLine("Reading...");

                while (state == RecorderState.Reading)
                {
                    if (numOfFramesPerRead == 0)
                    {
                        Console.ReadLine();
                        listener.GetSequence();
                    }
                }
                while (state == RecorderState.Storing) { }
            }

            while (state != RecorderState.Saving) { }

            Utils.SaveListListFrame(sequencesToRead, path);

            controller.RemoveListener(listener);
            controller.Dispose();
        }