Kinect Demo

Kinect Unity3D Demo

The kinect Demo package is a package to be used in Unity3D. This demo allows you to fully integrate your kinect (v1 or v2) with unity3D as long as you use theReh@panel protocol to send its information. There is a tool (Reh@panel) that sends the kinect information using this protocol.

Developed by: Tatiana Vieira, Yuri Almeida

Importing the package

  1. Create a new project
  2. Import the package KinectDemo.unitypackage
    1. Assets -> Import package -> Custom Package

Requirements to use the package

  1. Make sure you have the Kinect SDK installed – Kinect v1 or Kinect v2.
  2. Plug in your leapmotion to the PC
  3. Make sure that it is sending information by UDP to port 1202 (To change this port see below).
    1. You can use the Reh@panel to do this

Testing the scene

  1. Open the Scene
    1. Neurehab -> Demo Kinect-> Scenes -> KinectDemo
  2. Make sure you fulfill all the requirements
  3. Press Play
The data is accessed through the KinectUnity.cs script. If you open this script, in the UpdateAvatar function you will notice that the Kinect prefab values are updated there.
public void UpdateAvatar()
{
  if ((Head != null)
    Head.transform.rotation = Body.transform.rotation * //reference object
      GenericDeviceData.GetRotation(KinectBones.head.ToString()) * //rotation that comes from kinect (world rotation)
      _initialRotations[(int) KinectBones.head]; //initial rotation of the head inside unity
...
}
To be able to access any data that the Kinect is sending, you will need to know two things: the label of the information you want to access and the type of that information. Then, using the KinectUnity.cs script, you can find all this information by accessing the GenericDeviceData Dictionaries as shown below:
GenericDeviceData.Get[INFORMATION_TYPE](“[INFORMATION_LABEL]”);
For example, to access the Kinect leftshoulder rotation value which is labeled as ‘leftshoulder’ and is of the type rotation, you can:
GenericDeviceData.GetRotation(“leftshoulder”);

Current Kinect protocol values

Information Label [INFORMATION_LABEL] Information Type [INFORMATION_TYPE]
bodyposition
headposition
rotation
neckposition
rotation
torsoposition
rotation
waistposition
rotation
leftshoulderposition
rotation
leftelbowposition
rotation
leftwristposition
rotation
rightshoulderposition
rotation
rightelbowposition
rotation
rightwristposition
rotation
lefthipposition
rotation
leftkneeposition
rotation
leftankleposition
rotation
righthipposition
rotation
rightkneeposition
rotation
rightankleposition
rotation
In the Rehapanel protocol, parameters are things that always present no matter if it is sending a position, rotation, value or bool. For more information on the Rehapanel read here.

To be able to access any parameters data that the Kinect is sending, you will need to know the parameter name. Then, using the KinectUnity.cs script, you can find all this information by accessing the GenericDeviceData.GetParameters(“parameterNameHere”) as shown below:
GenericDeviceData.GetParameters(“[PARAMETER_NAME]”)
For example, to access the Kinect closest body parameter which is labeled as “main”, you can do:
var isClosestBody = GenericDeviceData.GetParameter(“main”);
 

Current Kinect parameters

Name [PARAMETER_NAME] Description
IdThe GenericDeviceData ID.
MainTells if this GenericDeviceData is representing the closest body to the kinect Can be true or false

Media