#Hololens – Detect user hand interactions using #HoloToolkit (update!)

Hello!

During the last few months HoloToolkit has changed a lot. These changes make some of the examples that I have written as non-valid posts. In today’s post, I’ll quickly explain how to implement detection of hands with the current version of HoloToolkit.

We start with the basics with these steps

 

  1. Create a 3D project in Unity3D
  2. Configure project to support HoloLens projects
  3. Clean Scene elements
  4. Import HoloToolkit package
  5. Add
    1. HololensCamera
    2. SpatialMapping
    3. CursorWithFeedback
  6. Add Empty element, Managers
    1. Add existing scripts
      1. Gaze Managers
      2. Gaze Stabilizer
      3. Input Manager
  7. Add Empty element, HoloCollection
    1. Add 3D elements
      1. Cube
        1. Position, x:0 y:0 z:2
        2. Rotation, x:0 y:0 z:0
        3. Scale, x:0.3 y:0.3 z:0.3
      2. AnchorText (from HoloToolkit)
        1. Position, x:0 y:0.35 z:2
        2. Rotation, x:0 y:0 z:0
        3. Scale, x:0.3 y:0.3 z:0.3
  8. Into the Manager collection
    1. Add script Text Debug Manager (later on the post)
      1. Drag the Anchor Text (7.1.2) into the Anchor Debug Text Property

This is the process creating a basic Hololens project. Now let’s create a script that detects any of the user actions with his hands. This script will display these actions in the AnchorText which I have added to the collection of holograms in debug mode.

For this example, I will call the script “TextDebugManager.cs“. The same code is as follows

 

using HoloToolkit.Unity.InputModule;
using UnityEngine;

public class TextDebugManager : MonoBehaviour, IHoldHandler, IInputHandler
{

 public TextMesh AnchorDebugText;
 private string _debugTextHold = "";
 private string _debugTextInput = "";
 
 void Update()
 {
   UpdateText();
 }

 private void UpdateText()
 {
   if (AnchorDebugText != null)
     AnchorDebugText.text = string.Format(
       "Hold: {0}\nInput: {1}", _debugTextHold, _debugTextInput);
 }

 public void OnHoldStarted(HoldEventData eventData)
 {
   _debugTextHold = "OnHoldStarted";
 }

 public void OnHoldCompleted(HoldEventData eventData)
 {
   _debugTextHold = "OnHoldCompleted";
 }

 public void OnHoldCanceled(HoldEventData eventData)
 {
   _debugTextHold = "OnHoldCanceled";
 }

 public void OnInputUp(InputEventData eventData)
 {
   _debugTextInput = "OnInputUp";
 }

 public void OnInputDown(InputEventData eventData)
 {
   _debugTextInput = "OnInputDown";
 }
}

Within the class I implemented interfaces “IHoldHandle” and “IInputHandler“. Then be shown the operations be interfaces in the Update() of the script. In this way, we can implement a model of Debug PPP of Hololens in a quick way, and in this case, to capture the interactions of the user about the holograms.

Greetings @ TorontoEl Bruno

References

Advertisements

#HoloLens – How to detect hands using #HoloToolkit

Hi !

Someone ask me about the objective of the HandsManager script (part of HoloToolkit).So, if we take a HUD like the one in my previous post, we can use this HUD to display information about hands.

The next sample script shows the following hand information:

  • Hands detected
  • Hand pressed

clipboard02

I’ll create a complete project and I’ll share the project in GitHub.

Greeting @ Toronto

El Bruno

References

#HoloLens – Detectando manos con #HoloToolkit

Hola !

Alguien me preguntó como se podía utilizar el script HandsManager incluido en el HoloToolkit. Pues bien, partiendo de un HUD, como el que comenté en el post anterior, podemos utilizar un script para mostrar el estado de las manos.

El siguiente ejemplo muestra si hay manos detectadas en la escena y además si las mismas están en acción de presionar.

clipboard02

 

En cuanto pueda compilo un ejemplo completo y lo comparto en GitHub.

Saludos @ Toronto

El Bruno

References