Lesson 3–Tutorial Adding Text box

In my previous lesson, I showed you how to allocate actions to your program, based on where you have put your hands on the screen. You could allocate actions to your hands being above your head etc..

In this tutorial I thought I would do some basic C# with you. All the tutorials available seem to concentrate on how to use the SDK but do not show you basic features such as text boxes. programming

This tutorial will show you how to included a text box and how to get it to update based on the previous lesson and your hand gestures. I hope this is useful to some of you beginners out there and I hope it will encourage you to try more within visual studio / visual studio express.

As with the previous lesson, you will need to have the following installed:

  • Kinect SDK BETA 2
  • Visual Studio Express / Visual Studio 2010 with C#
  • The sample file

Watch the video below to see how you can use the sample.

Kinect SDK–How to add in a text box

About Raymond David James Chambers

I am the Lead teacher of computing at Brooke Weston Academy in Corby Northamptonshire. Previously I was the head of IT/Computing at Uppingham Community College. In 2015 I won the Gold National Teaching award for Innovative use of technology. I also won the 2015 Young Game Bafta - Mentor award. I'm keen to help students achieve their best and like to give them opportunities to do this. I have a passion for teaching and I enjoy meeting other people and sharing their ideas. I have a keen interest in games development as well as developing the use of ICT in classrooms across the curriculum. In my spare time I teach Irish dancing. I have been Irish dancing since I was 11. My highest position was 14th at the world championships 3 years running and 2nd at the Great Britain Championships in 2006.
This entry was posted in Uncategorized. Bookmark the permalink.

4 Responses to Lesson 3–Tutorial Adding Text box

  1. Mohit says:

    I do not understand what exactly are you doing for the hand in new position instruction
    I mean why are you comparing handright.Position.X & head.Position.Y – 0.45?
    What is head.Position.Y – 0.45?
    Thank You

  2. rajacheers says:

    Hi Ray

    This video was helpful. I have exended it to understand many gestures.

    • raychambers says:

      Do you have any examples would be great to see how you’ve developed your code 🙂 will help others.


      • rajacheers says:

        Here is the code. I have commented it. If there is any confusion please contact me. A short description: Here gestures are used to control a camera. I have given this function as an extension to Ray’s video. This code works well and in a intuitive way to control a camera. Note that gesture understanding is only developed and connection to a real camera or a virtual camera is upto you.

        private void ProcessGesture(Joint head, Joint elbowleft, Joint elbowright, Joint hipcenter, Joint hipleft, Joint hipright, Joint shouldercenter,Joint shoulderleft, Joint shoulderright, Joint spine, Joint wristleft, Joint wristright, Joint handleft, Joint handright)
        // Speed control. Walking closer to kinect increases the speed. Range 2.5m to 1.5m.
        if (hipcenter.Position.Z > 2.5)
        textBox2.Text = “Too far”;
        if (hipcenter.Position.Z < 1.5)
        textBox2.Text = "Too close";
        double position = 250 – (Math.Round(hipcenter.Position.Z * 100));
        textBox2.Text = position.ToString(); // Speed indicated in textbox
        slider1.Value = position; // Slider represents the speed visually
        // Gesture for camera control
        if (handleft.Position.Y < 0 && handright.Position.Y < 0) // Both hands below waist
        if (head.Position.Z hipcenter.Position.Z + .2) // Bend backward
        txtinstructions.Text = “Tilt Up”;
        txtinstructions.Text = “Idle”; // Head staright and hands down
        else // some actions with hand
        if (handright.Position.Y > 0 && handleft.Position.Y shoulderright.Position.Y) // If stretched right side
        txtinstructions.Text = “Turn Right”;
        if (elbowright.Position.X 0 && handright.Position.Y shoulderleft.Position.Y)
        txtinstructions.Text = “Turn Left”;
        if (elbowleft.Position.X > shoulderleft.Position.X)
        txtinstructions.Text = “Pan Left”;
        if (handleft.Position.Y > 0 && handright.Position.Y > 0) // Both hands moving
        if (handleft.Position.Y > head.Position.Y && handright.Position.Y > head.Position.Y) // Both hands above shoulder
        txtinstructions.Text = “Fly”; // Move
        if (head.Position.Z hipcenter.Position.Z + .2)
        txtinstructions.Text = “Fly and Tilt Up”;
        if (elbowright.Position.X shoulderleft.Position.X)
        txtinstructions.Text = “Fly and Pan Left”;
        else // Both hands between shoulder and waist
        if (handleft.Position.Y > elbowleft.Position.Y && handright.Position.Y > elbowright.Position.Y)
        txtinstructions.Text = “Zoom out”; // hand stretched outside
        if (handleft.Position.Y < elbowleft.Position.Y && handright.Position.Y < elbowright.Position.Y)
        txtinstructions.Text = "Zoom in"; // hand bent down


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s