This project is read-only.

Event/Action when Gesture is recognised

Apr 15, 2014 at 10:55 AM
I'm trying to make several action when a (after several) gesture is recognized.
For example, when SwipeToRight is recognized, I want to send something on the serial Port.
But it didn't work.
Do I am on the good class ?

I put this code on the Kinect.Toolbox/Gesture/SwipeGestureDetector

Previons is declared the class : SerialToolbox Serial = new SerialToolbox();
        protected override void LookForGesture()
            // Swipe to right
            if (ScanPositions((p1, p2) => Math.Abs(p2.Y - p1.Y) < SwipeMaximalHeight, // Height
                (p1, p2) => p2.X - p1.X > -0.01f, // Progression to right
                (p1, p2) => Math.Abs(p2.X - p1.X) > SwipeMinimalLength, // Length
                SwipeMininalDuration, SwipeMaximalDuration)) // Duration
Maybe I don't put my code at the good place.
When it will work, I would like to add like 6-8 movements and send a different message on the serial port by a recognized movement.

Thank you.
Apr 17, 2014 at 8:03 AM
In fact, maybe it's the best place to call the writeSerial method, but when I use the debug mode, the program right brake when the swipe is detected.
And so I can see by step into the writeSerial method, the program try to send something but the serial port is closed at this moment.

Here is the writeSerial method :
            public void writeSerial(string dataToSend)
                // Makes sure serial port is open before trying to write
                    if (!(_serialPort.IsOpen)) _serialPort.Open();
                    Console.Write("data send");
                catch (Exception ex)
                    Console.WriteLine("Error opening/writing to serial port :: " + ex.Message, "Error!");
But normally the port is always open.
Let see here :
        private void buttonAll_Click(object sender, RoutedEventArgs e)
To test my serial communication I put several buttons. That way I don't have to reconnect my gesture all the time (and also because I can't do it at the moment, yet).

Do you have any idea, why the serial port is closed only at this moment ?

Thank you.