none
Relative tracking of a kinect skeleton joint ? RRS feed

  • Question

  • Hello,

    Currently I am using Coding4fun ScaleTo() to track the right hand , like this :

    Joint scaledJoint = joint.ScaleTo(1920, 1080, .3f, .3f);
    System.Drawing.Point p = new System.Drawing.Point(Convert.ToInt32(scaledJoint.Position.X), Convert.ToInt32(scaledJoint.Position.Y));
    MouseLibrary.SetCursorPosition(p);

    I would like to improve this by using relative tracking of my right hand relative to my head. 

    For example, if I crouched down, the mouse cursor would not change because my head-hand relationship is the same.

    Any suggestions?

    Thanks,Peter

    Monday, March 26, 2012 8:18 PM

All replies

  • Hi,

    You could create a virtual screen its edges starts from you head as the zero based position of your virtual screen.

    To get your hand position relative to you zero based position (the head point) you can subtract your Position.X of your hand - Position.X of your head also the Y position and try to relative this point to the cursor point on the screen

    try this it get the screen point but by other way

    /// <summary>
    /// Updates the cursor position.
    /// </summary>
    /// <param name="hand">The hand.</param>
    /// <param name="head">The head</param>
    /// <Author>MOHAMED A. SAKR</Author>
    private void SetCursor(Joint hand, Joint head)
            {
                var point = _kinectSensor.MapSkeletonPointToDepth(head.Position, _kinectSensor.DepthStream.Format);
    
                float x = point.X;
                float y = point.Y;
                float z = point.Depth;
    
                x = (float)(x * _window.ActualWidth / _kinectSensor.DepthStream.FrameWidth);
                y = (float)(y * _window.ActualHeight / _kinectSensor.DepthStream.FrameHeight);
                x += ((float)(_window.ActualWidth * hand.Position.X * 4));
    
                y -= ((float)(_window.ActualHeight * hand.Position.Y * 3));
    
                Point cursorPoint = new Point(x, y);
            }


    Thanks,
    MOHAMED A. SAKR | Software Development Lead Engineer | EgyptNetwork
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Also try to Vote as Helpful

    • Proposed as answer by MohamedSakr Tuesday, April 3, 2012 8:38 AM
    Tuesday, April 3, 2012 8:37 AM
  • Can you exaplain   what this formula will do ?

    Using screen width =1920  , I got  x =2859 , which is off the screen.

    (1920*234/640 )+ (1920*.280*4)=2859

    I am looking for a formula that can scale the hand locatoin into a virtual box in a lower right quadrant.

    Thanks, Peter

    Tuesday, April 3, 2012 3:57 PM
  • if the x is outside the boundaries of the screen width you could enforce it to be at the boundaries

    Please make sure that you are using the formula well


    Thanks,
    MOHAMED A. SAKR | Software Development Lead Engineer | EgyptNetwork
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Also try to Vote as Helpful

    Wednesday, April 4, 2012 1:13 PM