text
stringlengths
0
1.11k
Haz clic aquí para ver la página del índice de la documentación para tu plataforma de preferencia.
In this tutorial, you learn how to build a custom hand pose from scratch by constructing a thumbs up pose for both hands. Since custom hand poses rely on information about your physical hand, like finger position and wrist orientation, custom hand poses aren’t supported for controllers and controller driven hands. For a detailed explanation of how pose recognition works, see Hand Pose Detection.
To try pose recognition in a pre-built scene, see the PoseExamples or DebugGesture scenes.
Note
Hand poses can also rely on velocity and rotation data, which aren't used in this tutorial but are described in Hand Pose Detection.
Thumbs up pose detection image
An outline of the parts that define a thumbs up pose. The pose is a combination of two different shapes (thumb curl open and all fingers closed) and a transform orientation (wrist up).
Before you begin
Complete Getting Started with Interaction SDK.
Get hand transform data
Hand tracking provides transform data about your hands, like which direction your wrist is facing. To access that data, each hand needs a TransformFeatureStateProvider component.
Open the Unity scene where you completed Getting Started with Interaction SDK.
Under Hierarchy, select OVRCameraRig > OVRInteraction > OVRHands > LeftHand > HandFeaturesLeft.
Under Inspector, add a TransformFeatureStateProvider component.
Repeat these steps for OVRCameraRig > OVRInteraction > OVRHands > RightHand > HandFeaturesRight.
Set finger thresholds
Finger thresholds define when a finger is in a specific state (ex. curled or open). For the thumbs-up pose, you’ll use the default thresholds included with Interaction SDK. To save time, you’ll copy them from a sample scene.
In a separate Unity window, open the PoseExamples sample scene found under Samples/Scenes/Examples/PoseExamples.unity so you can copy the finger thresholds from it.
Under Hierarchy, select OVRCameraRig > OVRInteraction > OVRHands > LeftHand > HandFeaturesLeft.
Under Inspector, select the three vertical dots at the top of the FingerFeatureStateProvider component.
Copying component
A list appears.
In the list, select Copy Component.
Return to the Unity scene you’re using for this tutorial.
In your Unity scene, under Hierarchy, select LeftHand > HandFeaturesLeft.
Under Inspector, select the three vertical dots at the top of the Joints Radius Feature component.
A list of options appears.
In the list, select Paste Component as New.
The FingerFeatureStateProvider component you copied is added to HandFeaturesLeft as a new component.
In the FingerFeatureStateProvider component, set the Hand property to the hand you want to track, LeftHand.
Repeat these steps for RightHand > HandFeaturesRight.
Create an empty GameObject
A pose is contained in an empty GameObject that has a list of unique components, so you need to make an empty GameObject.
Under Hierarchy, add an empty GameObject by right-clicking and selecting Create Empty.
Name the GameObject ThumbsUpPoseLeft.
Under Inspector, add the following components:
ShapeRecognizerActiveState
TransformRecognizerActiveState
ActiveStateGroup
ActiveStateSelector
SelectorUnityEventWrapper
Repeat these steps for the right hand, naming that GameObject ThumbsUpPoseRight.
Define the shapes of the pose
All of the shapes required for a pose are stored in the hand’s ShapeRecognizerActiveState component. The thumbs up pose includes two shapes. The first shape checks that all the fingers are fully closed, and the second shape checks that the thumb is fully extended. Both must be true for the SDK to consider the thumbs up shape as true.
However, a shape doesn’t define a pose on its own because shapes don’t track velocity or the hand’s orientation in space.
Under Hierarchy, select the ThumbsUpPoseLeft GameObject you created in the previous section.
Under Inspector, in the ShapeRecognizerActiveState component, set the Hand property to LeftHand to track the shape of the left hand.
Set Finger Feature State Provider to the HandFeaturesLeft GameObject. This allows the ShapeRecognizerActiveState component to access the state of all five fingers on the left hand so it can compare them to the shapes you define.
Properties
In the Shapes property, click the + twice to add two elements to the list.
Set Element 0 to the FingersAllClosedShapeRecognizer asset by clicking the circle in the property’s textbox and searching for FingersAllClosed. This is the first shape of the pose.
Set Element 1 to the ThumbUpShapeRecognizer asset. This is the second shape of the pose.
Repeat these steps for the ThumbsUpPoseRight GameObject.
Define the pose orientation
Since pose shapes don’t track the orientation of the hand, currently your pose is active whenever your thumb is extended and the other fingers are closed, regardless of which way your hand is rotated. To define the correct orientation, a pose uses the TransformRecognizerActiveState component.