private uint getPlaybackOrClosestUserID()
 {
     if (Fubi.isPlayingSkeletonData())
     {
         return(FubiUtils.PlaybackUserID);
     }
     return(Fubi.getClosestUserID());
 }
Ejemplo n.º 2
0
        public void autoCalibrateMapping(bool leftHand)
        {
            uint id = Fubi.getClosestUserID();

            if (id > 0)
            {
                FubiUtils.SkeletonJoint elbow    = FubiUtils.SkeletonJoint.RIGHT_ELBOW;
                FubiUtils.SkeletonJoint shoulder = FubiUtils.SkeletonJoint.RIGHT_SHOULDER;
                FubiUtils.SkeletonJoint hand     = FubiUtils.SkeletonJoint.RIGHT_HAND;

                if (leftHand)
                {
                    elbow    = FubiUtils.SkeletonJoint.LEFT_ELBOW;
                    shoulder = FubiUtils.SkeletonJoint.LEFT_SHOULDER;
                    hand     = FubiUtils.SkeletonJoint.LEFT_HAND;
                }

                float  confidence;
                double timeStamp;
                float  elbowX, elbowY, elbowZ;
                Fubi.getCurrentSkeletonJointPosition(id, elbow, out elbowX, out elbowY, out elbowZ, out confidence, out timeStamp);
                if (confidence > 0.5f)
                {
                    float shoulderX, shoulderY, shoulderZ;
                    Fubi.getCurrentSkeletonJointPosition(id, shoulder, out shoulderX, out shoulderY, out shoulderZ, out confidence, out timeStamp);
                    if (confidence > 0.5f)
                    {
                        double dist1 = Math.Sqrt(Math.Pow(elbowX - shoulderX, 2) + Math.Pow(elbowY - shoulderY, 2) + Math.Pow(elbowZ - shoulderZ, 2));
                        float  handX, handY, handZ;
                        Fubi.getCurrentSkeletonJointPosition(id, hand, out handX, out handY, out handZ, out confidence, out timeStamp);
                        if (confidence > 0.5f)
                        {
                            double dist2 = Math.Sqrt(Math.Pow(elbowX - handX, 2) + Math.Pow(elbowY - handY, 2) + Math.Pow(elbowZ - handZ, 2));
                            MapH = (float)(dist1 + dist2);
                            // Calculate all others in depence of maph
                            MapY = 250.0f / 550.0f * MapH;
                            MapW = MapH / m_aspect;
                            MapX = -100.0f / (550.0f / m_aspect) * MapW;
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
    // Called for rendering the gui
    void OnGUI()
    {
        // AA: Position the depth image so the user can see the kinect output
        if (!m_disableTrackingImage && (!m_disableTrackingImageWithSwipeMenu || !m_swipeMenuDisplayedLastFrame))
        {
            // Debug image
            GUI.depth = -4;
            GUI.DrawTexture(new Rect(25, Screen.height - m_yRes / m_factor - 25, m_xRes / m_factor, m_yRes / m_factor), m_depthMapTexture);
            //GUI.DrawTexture(new Rect(Screen.width-m_xRes/m_factor, Screen.height-m_yRes/m_factor, m_xRes / m_factor, m_yRes / m_factor), m_depthMapTexture);
        }



        //AA: add the GUI elements
        int shift = 42;

        GUI.Box(new Rect(5 + shift, 25, Screen.width / 3 - 130, Screen.height - 50), "FILTERS");

        m_bUseSimpleAverage = GUI.Toggle(new Rect(45 + shift, 50, 200, 30), m_bUseSimpleAverage, " SIMPLE AVERAGE 10");

        m_bUseMovingAverage = GUI.Toggle(new Rect(45 + shift, 90, 200, 30), m_bUseMovingAverage, " MOVING AVERAGE");

        m_bUseSimpleAverage5 = GUI.Toggle(new Rect(45 + shift, 130, 200, 30), m_bUseSimpleAverage5, " SIMPLE AVERAGE 5");

        m_bDblMovingAverage = GUI.Toggle(new Rect(45 + shift, 170, 200, 30), m_bDblMovingAverage, " DOUBLE MOV AVERAGE");

        m_bUseExpSmoothing = GUI.Toggle(new Rect(45 + shift, 210, 200, 30), m_bUseExpSmoothing, " EXP SMOOTHING");

        m_bUseDblExpSmoothing = GUI.Toggle(new Rect(45 + shift, 250, 200, 30), m_bUseDblExpSmoothing, " DOUBLE EXP SMOOTHING");

        m_bUseAdaptive = GUI.Toggle(new Rect(45 + shift, 290, 200, 30), m_bUseAdaptive, " ADAPTIVE DBL EXP");

        m_bUseMedian = GUI.Toggle(new Rect(45 + shift, 330, 200, 30), m_bUseMedian, " MEDIAN");

        m_bUseCombination1 = GUI.Toggle(new Rect(45 + shift, 370, 200, 30), m_bUseCombination1, " SIMPLE AVG + Median");

        m_bUseCombination2 = GUI.Toggle(new Rect(45 + shift, 410, 200, 30), m_bUseCombination2, " DBL MOV AVG + Median");

        m_bUseNone = GUI.Toggle(new Rect(45 + shift, 450, 200, 30), m_bUseNone, " NONE");


        if (GUI.Button(new Rect(50 + shift, Screen.height - 75, 150, 30), "Clear"))
        {
            WriteableAreaResize();
            fv.DrawCircle();
        }

        // If some button has been pressed OR this is the first exection
        if (GUI.changed)
        {
            LoadFilters();

            if (fm.filters.Count == 1)
            {
                m_principalCursor = 0;
            }
        }

        int count = 0;

        if (m_bUseSimpleAverage)
        {
            GUI.Label(new Rect(15 + shift, 45, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (m_bUseMovingAverage)
        {
            GUI.Label(new Rect(15 + shift, 85, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (m_bUseSimpleAverage5)
        {
            GUI.Label(new Rect(15 + shift, 125, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (m_bDblMovingAverage)
        {
            GUI.Label(new Rect(15 + shift, 165, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (m_bUseExpSmoothing)
        {
            GUI.Label(new Rect(15 + shift, 205, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (m_bUseDblExpSmoothing)
        {
            GUI.Label(new Rect(15 + shift, 245, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (m_bUseAdaptive)
        {
            GUI.Label(new Rect(15 + shift, 285, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (m_bUseMedian)
        {
            GUI.Label(new Rect(15 + shift, 325, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (m_bUseCombination1)
        {
            GUI.Label(new Rect(15 + shift, 365, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (m_bUseCombination2)
        {
            GUI.Label(new Rect(15 + shift, 405, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (m_bUseNone)
        {
            GUI.Label(new Rect(15 + shift, 445, 30, 30), m_colorTextureDictionary[fm.colors[count].ToString()]);
            count++;
        }

        if (prevScreenWidth != Screen.width || prevScreenHeight != Screen.height)
        {
            // Resize writeable area, redraw the circle
            WriteableAreaResize();
            prevScreenWidth  = Screen.width;
            prevScreenHeight = Screen.height;
            fv.DrawCircle();
        }

        //AA: Draw the writeable area
        fv.Apply();
        for (int i = 0; i < fv.m_filterOutputTexture.Count; i++)
        {
            GUI.DrawTexture(new Rect(fv.filterOutputLocX, fv.filterOutputLocY, fv.filterOutputWidth, fv.filterOutputHeight), fv.m_filterOutputTexture[i]);
        }


        // Cursor
        m_gotNewFubiCoordinates = false;
        if (Fubi.isInitialized())
        {
            // Take closest user
            uint userID = Fubi.getClosestUserID();
            if (userID != m_currentUser)
            {
                m_currentUser             = userID;
                m_lastCalibrationSucceded = false;
            }
            if (userID > 0)
            {
                if (!m_lastCalibrationSucceded)
                {
                    m_lastCalibrationSucceded = calibrateCursorMapping(m_currentUser);
                }
                FubiUtils.SkeletonJoint joint    = FubiUtils.SkeletonJoint.RIGHT_HAND;
                FubiUtils.SkeletonJoint relJoint = FubiUtils.SkeletonJoint.RIGHT_SHOULDER;

                // Get hand and shoulder position and check their confidence
                double timeStamp;
                float  handX, handY, handZ, confidence;
                Fubi.getCurrentSkeletonJointPosition(userID, joint, out handX, out handY, out handZ, out confidence, out timeStamp);
                if (confidence > 0.5f)
                {
                    float relX, relY, relZ;
                    Fubi.getCurrentSkeletonJointPosition(userID, relJoint, out relX, out relY, out relZ, out confidence, out timeStamp);
                    if (confidence > 0.5f)
                    {
                        // AA: Filtering should happen here for the hand and relative joints separately
                        // If true, use the smoothed joints for calculating screen coordinates
                        fm.UpdateJointFilters(new Vector3(handX, handY, handZ), new Vector3(relX, relY, relZ));

                        for (int i = 0; i < fm.filters.Count; i++)
                        {
                            if (m_bUseJointFiltering)
                            {
                                //Debug.Log ("Prehand " + new Vector3(handX, handY, handZ) + " relJoint " + new Vector3(relX, relY, relZ));
                                Vector3 handPos     = fm.joints[i];                             // filter.Update(new Vector3(handX, handY, handZ), Filter.JOINT_TYPE.JOINT);
                                Vector3 relJointPos = fm.relativeJoints[i];                     //filter.Update(new Vector3(relX, relY, relZ), Filter.JOINT_TYPE.RELATIVEJOINT);
                                //Debug.Log ("hand " + handPos + " relJoint " + relJointPos);
                                handZ = handPos.z;
                                handY = handPos.y;
                                handX = handPos.x;

                                relZ = relJointPos.z;
                                relY = relJointPos.y;
                                relX = relJointPos.x;
                                m_relativeCursorPosition = fm.relativeCursorPosition[i];
                            }
                            // AA: End

                            // Take relative coordinates
                            float zDiff = handZ - relZ;
                            float yDiff = handY - relY;
                            float xDiff = handX - relX;
                            // Check if hand is enough in front of shoulder
                            if ((yDiff > 0 && zDiff < -150.0f) || (Mathf.Abs(xDiff) > 150.0f && zDiff < -175.0f) || zDiff < -225.0f)
                            {
                                // Now get the possible cursor position
                                // Convert to screen coordinates
                                float newX, newY;
                                float mapX = m_mapping.x;
                                newX = (xDiff - mapX) / m_mapping.width;
                                newY = (m_mapping.y - yDiff) / m_mapping.height;         // Flip y for the screen coordinates

                                // Filtering
                                // New coordinate is weighted more if it represents a longer distance change
                                // This should reduce the lagging of the cursor on higher distances, but still filter out small jittering
                                float changeX = newX - m_relativeCursorPosition.x;
                                float changeY = newY - m_relativeCursorPosition.y;

                                if (changeX != 0 || changeY != 0 && timeStamp != m_timeStamp)
                                {
                                    float changeLength = Mathf.Sqrt(changeX * changeX + changeY * changeY);
                                    float filterFactor = changeLength;         //Mathf.Sqrt(changeLength);
                                    if (filterFactor > 1.0f)
                                    {
                                        filterFactor = 1.0f;
                                    }

                                    // Apply the tracking to the current position with the given filter factor
                                    // AA: Filtering should happen here for joint-to-relativejoint (VECTOR) filtering
                                    // AA: filtering code

                                    Vector2 tempNew = new Vector2(newX, newY);

                                    fm.UpdateVectorFilters(m_relativeCursorPosition, tempNew, filterFactor);
                                    // If true, use the calculated factor for smoothing, else just use the new
                                    if (m_bUseVectorFiltering)
                                    {
                                        m_relativeCursorPosition = fm.vectors[i]; //filter.Update(m_relativeCursorPosition, tempNew, filterFactor);
                                    }
                                    else                                          // Just give equal weight to both
                                    {
                                        m_relativeCursorPosition = filter.Update(m_relativeCursorPosition, tempNew, 0.5f);
                                    }

                                    // AA: Calculate all filters
                                    // fm.UpdateVectorFilters(m_relativeCursorPosition, tempNew, filterFactor);

                                    m_timeStamp = timeStamp;

                                    // Send it, but only if it is more or less within the screen
                                    if (m_relativeCursorPosition.x > -0.1f && m_relativeCursorPosition.x < 1.1f &&
                                        m_relativeCursorPosition.y > -0.1f && m_relativeCursorPosition.y < 1.1f)
                                    {
                                        MoveMouse(m_relativeCursorPosition.x, m_relativeCursorPosition.y, i);

                                        // Each filter must store it's own value of relative position, absolute and previous absolute positions
                                        fm.relativeCursorPosition[i] = m_relativeCursorPosition;
                                        fm.absPixelPosition[i]       = m_absPixelPosition;
                                        fm.prevAbsPixelPosition[i]   = m_previousAbsPixelPosition;

                                        DrawFilterOutputs(i);
                                        m_gotNewFubiCoordinates      = true;
                                        m_lastCursorChangeDoneByFubi = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // AA: FUBI does not move mouse if the confidence value is too low

        if (!m_gotNewFubiCoordinates)           // AA: this only executes when input is coming from mouse
        {
            // Got no mouse coordinates from fubi this frame
            Vector2 mousePos = Input.mousePosition;
            // Only move mouse if it wasn't changed by fubi the last time or or it really has changed
            if (!m_lastCursorChangeDoneByFubi || mousePos != m_lastMousePos)
            {
                //AA: Old code for cursor placement
                m_relativeCursorPosition.x = mousePos.x / (float)Screen.width;
                m_relativeCursorPosition.y = 1.0f - (mousePos.y / (float)Screen.height);
                // Get mouse X and Y position as a percentage of screen width and height
                MoveActualMouse(m_relativeCursorPosition.x, m_relativeCursorPosition.y, true);
                m_lastMousePos = mousePos;
                m_lastCursorChangeDoneByFubi = false;
            }
        }
    }
Ejemplo n.º 4
0
        private void updateFubi()
        {
            if (clearRecognizersOnNextUpdate)
            {
                Fubi.clearUserDefinedRecognizers();
                if (Fubi.getNumUserDefinedCombinationRecognizers() == 0 && Fubi.getNumUserDefinedRecognizers() == 0)
                {
                    button3.IsEnabled = false;
                }
                clearRecognizersOnNextUpdate = false;
            }

            if (switchSensorOnNextUpdate)
            {
                Fubi.switchSensor(new FubiUtils.SensorOptions(new FubiUtils.StreamOptions(), new FubiUtils.StreamOptions(), new FubiUtils.StreamOptions(-1, -1, -1),
                                                              (FubiUtils.SensorType)Enum.Parse(typeof(FubiUtils.SensorType), sensorSelectionComboBox.SelectedItem.ToString())));
                switchSensorOnNextUpdate = false;
            }

            label1.Content = "User Count : " + Fubi.getNumUsers().ToString();

            // Update Fubi and get the debug image
            int width = 0, height = 0;

            FubiUtils.ImageNumChannels channels = FubiUtils.ImageNumChannels.C4;
            FubiUtils.ImageType        type     = FubiUtils.ImageType.Depth;

            uint renderOptions = 0;

            if (shapeCheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.Shapes;
            }
            if (skeletonCheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.Skeletons;
            }
            if (userCaptionscheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.UserCaptions;
            }
            if (localOrientCheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.LocalOrientCaptions;
            }
            if (globalOrientCheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.GlobalOrientCaptions;
            }
            if (localPosCheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.LocalPosCaptions;
            }
            if (globalPosCheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.GlobalPosCaptions;
            }
            if (backgroundCheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.Background;
            }
            if (swapRAndBcheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.SwapRAndB;
            }
            if (fingerShapecheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.FingerShapes;
            }
            if (detailedFaceCheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.DetailedFaceShapes;
            }
            if (bodyMeasuresCheckBox.IsChecked == true)
            {
                renderOptions |= (uint)FubiUtils.RenderOptions.BodyMeasurements;
            }

            FubiUtils.DepthImageModification depthMods = (FubiUtils.DepthImageModification)Enum.Parse(typeof(FubiUtils.DepthImageModification), comboBox1.SelectedItem.ToString(), true);

            if (checkBox3.IsChecked == true)
            {
                Fubi.getRgbResolution(out width, out height);
                channels = FubiUtils.ImageNumChannels.C3;
                type     = FubiUtils.ImageType.Color;
            }
            else
            {
                Fubi.getDepthResolution(out width, out height);
                channels = FubiUtils.ImageNumChannels.C4;
                type     = FubiUtils.ImageType.Depth;
            }

            // Display the debug image
            if (width > 0 && height > 0)
            {
                WriteableBitmap wb = image1.Source as WriteableBitmap;
                if (wb != null && (wb.Width != width || wb.Height != height || wb.Format.BitsPerPixel != (int)channels * 8))
                {
                    wb            = null;
                    image1.Width  = width;
                    image1.Height = height;
                    buffer        = new byte[(int)channels * width * height];
                }
                if (wb == null)
                {
                    PixelFormat format = PixelFormats.Bgra32;
                    if (channels == FubiUtils.ImageNumChannels.C3)
                    {
                        format = PixelFormats.Rgb24;
                    }
                    else if (channels == FubiUtils.ImageNumChannels.C1)
                    {
                        format = PixelFormats.Gray8;
                    }
                    wb            = new WriteableBitmap(width, height, 0, 0, format, BitmapPalettes.Gray256);
                    image1.Source = wb;
                }

                Fubi.updateSensor();
                Fubi.getImage(buffer, type, channels, FubiUtils.ImageDepth.D8, renderOptions, depthMods);

                int stride = wb.PixelWidth * (wb.Format.BitsPerPixel / 8);
                wb.WritePixels(new Int32Rect(0, 0, wb.PixelWidth, wb.PixelHeight), buffer, stride, 0);
            }

            //Check postures for all users
            for (uint i = 0; i < Fubi.getNumUsers(); i++)
            {
                uint id = Fubi.getUserID(i);
                if (id > 0)
                {
                    bool changedSomething = false;
                    // Print postures
                    if (checkBox1.IsChecked == true)
                    {
                        // Only user defined postures
                        for (uint p = 0; p < Fubi.getNumUserDefinedRecognizers(); ++p)
                        {
                            if (Fubi.recognizeGestureOn(p, id) == FubiUtils.RecognitionResult.RECOGNIZED)
                            {
                                // Posture recognized
                                if (!currentPostures.ContainsKey(p) || !currentPostures[p])
                                {
                                    // Posture start
                                    textBox1.Text     += "User" + id + ": START OF " + Fubi.getUserDefinedRecognizerName(p) + " -->\n";
                                    currentPostures[p] = true;
                                    changedSomething   = true;
                                }
                            }
                            else if (currentPostures.ContainsKey(p) && currentPostures[p])
                            {
                                // Posture end
                                textBox1.Text     += "User" + id + ": --> END OF " + Fubi.getUserDefinedRecognizerName(p) + "\n";
                                currentPostures[p] = false;
                                changedSomething   = true;
                            }
                        }

                        if (PredefinedCheckBox.IsChecked == true)
                        {
                            for (int p = 0; p < (int)FubiPredefinedGestures.Postures.NUM_POSTURES; ++p)
                            {
                                if (Fubi.recognizeGestureOn((FubiPredefinedGestures.Postures)p, id) == FubiUtils.RecognitionResult.RECOGNIZED)
                                {
                                    if (!currentPostures1[p])
                                    {
                                        // Posture recognized
                                        textBox1.Text      += "User" + id + ": START OF" + FubiPredefinedGestures.getPostureName((FubiPredefinedGestures.Postures)p) + "\n";
                                        currentPostures1[p] = true;
                                        changedSomething    = true;
                                    }
                                }
                                else if (currentPostures1[p])
                                {
                                    textBox1.Text      += "User" + id + ": --> END OF " + FubiPredefinedGestures.getPostureName((FubiPredefinedGestures.Postures)p) + "\n";
                                    currentPostures1[p] = false;
                                    changedSomething    = true;
                                }
                            }
                        }

                        if (changedSomething)
                        {
                            textBox1.ScrollToEnd();
                        }
                    }

                    // Print combinations
                    for (uint pc = 0; pc < Fubi.getNumUserDefinedCombinationRecognizers(); ++pc)
                    {
                        // Only user defined postures
                        if (checkBox2.IsChecked == true)
                        {
                            if (Fubi.getCombinationRecognitionProgressOn(Fubi.getUserDefinedCombinationRecognizerName(pc), id) == FubiUtils.RecognitionResult.RECOGNIZED)
                            {
                                // Posture recognized
                                textBox2.Text += "User" + id + ": " + Fubi.getUserDefinedCombinationRecognizerName(pc) + "\n";
                            }
                            else
                            {
                                Fubi.enableCombinationRecognition(Fubi.getUserDefinedCombinationRecognizerName(pc), id, true);
                            }
                        }
                        //else
                        //    Fubi.enableCombinationRecognition(Fubi.getUserDefinedCombinationRecognizerName(pc), id, false);
                    }

                    for (uint pc = 0; pc < (uint)FubiPredefinedGestures.Combinations.NUM_COMBINATIONS; ++pc)
                    {
                        if (checkBox2.IsChecked == true && PredefinedCheckBox.IsChecked == true)
                        {
                            if (Fubi.getCombinationRecognitionProgressOn((FubiPredefinedGestures.Combinations)pc, id) == FubiUtils.RecognitionResult.RECOGNIZED)
                            {
                                // Posture recognized
                                textBox2.Text += "User" + id + ": " + FubiPredefinedGestures.getCombinationName((FubiPredefinedGestures.Combinations)pc) + "\n";
                            }
                            else
                            {
                                Fubi.enableCombinationRecognition((FubiPredefinedGestures.Combinations)pc, id, true);
                            }
                        }
                        //else
                        //    Fubi.enableCombinationRecognition((FubiPredefinedGestures.Combinations)pc, id, false);
                    }
                    if (checkBox2.IsChecked == true)
                    {
                        textBox2.ScrollToEnd();
                    }
                }
            }

            uint closestId = Fubi.getClosestUserID();

            if (closestId > 0)
            {
                // For printing the user orientation
                //float[] mat = new float[9];
                //float confidence;
                //double timeStamp;
                //Fubi.getCurrentSkeletonJointOrientation(closestId, FubiUtils.SkeletonJoint.Torso, mat, out confidence, out timeStamp);
                //float rx, ry, rz;
                //FubiUtils.Math.rotMatToRotation(mat, out rx, out ry, out rz);
                //label1.Content = "UserOrient:" + String.Format("{0:0.#}", rx) + "/" + String.Format("{0:0.#}", ry) + "/" + String.Format("{0:0.#}", rz);


                if (controlMouse)
                {
                    float x, y;
                    FubiMouse.applyHandPositionToMouse(closestId, out x, out y, leftHandRadioButton.IsChecked == true);
                    label2.Content = "X:" + x + " Y:" + y;
                }

                if (checkBox4.IsChecked == true)
                {
                    FubiPredefinedGestures.Combinations activationGesture = FubiPredefinedGestures.Combinations.WAVE_RIGHT_HAND_OVER_SHOULDER;
                    // TODO use left hand waving
                    if (Fubi.getCombinationRecognitionProgressOn(activationGesture, closestId, false) == FubiUtils.RecognitionResult.RECOGNIZED)
                    {
                        if (controlMouse)
                        {
                            stopMouseEmulation();
                        }
                        else
                        {
                            startMouseEmulation();
                        }
                    }
                    else
                    {
                        Fubi.enableCombinationRecognition(activationGesture, closestId, true);
                    }
                }
            }
        }