WVR_GetHandTrackingData

WVR_EXPORT WVR_Result WVR_GetHandTrackingData(WVR_HandTrackerType trackerType, WVR_HandModelType modelType, WVR_PoseOriginModel originModel, WVR_HandTrackingData * skeleton, WVR_HandPoseData_t * pose = nullptr)

Use this function to get the hand tracking device.

Recommend calling this get hand pose API just after WVR_GetSyncPose to make sure hand model moving smooth.

Version
API Level 6
Parameters
  • trackerType: Specify the type of hand tracker. Refer to WVR_HandTrackerType.
  • modelType: Specify the type of hand model. Refer to WVR_HandModelType.
  • originModel: Specify the tracking universe of the origin tracking model. Refer to WVR_PoseOriginModel.
  • skeleton: The hand skeleton data WVR_HandTrackingData_t
  • pose: The hand pose state refer to WVR_HandPoseData_t
Return Value
  • WVR_Success: Successfully retrieved data.
  • Others: WVR_Result mean failure.

Inputs

enum WVR_HandTrackerType

The type of hand tracker device.

Version
API Level 6

Values:

WVR_HandTrackerType_Natural = 1
WVR_HandTrackerType_Electronic = 2
enum WVR_HandModelType

The type of the hand model.

Version
API Level 6

Values:

WVR_HandModelType_WithoutController = 1<<0
WVR_HandModelType_WithController = 1<<1
enum WVR_PoseOriginModel

The style of tracking origin.

Identifies which style of tracking origin the application wants to use for the poses it is requesting

Values:

WVR_PoseOriginModel_OriginOnHead = 0

The origin of 6 DoF pose is on head.

WVR_PoseOriginModel_OriginOnGround = 1

The origin of 6 DoF pose is on ground.

WVR_PoseOriginModel_OriginOnTrackingObserver = 2

The raw pose from tracking system.

WVR_PoseOriginModel_OriginOnHead_3DoF = 3

The origin of 3 DoF pose is on head.

Outputs - skeleton

struct WVR_HandTrackingData

The data structure of the hand tracker data that contains both hands.

Version
API Level 6

Public Members

int64_t timestamp
WVR_HandJointData_t right

The hand tracker data of right hand, refer to WVR_HandJointData_t.

WVR_HandJointData_t left

The hand tracker data of left hand, refer to WVR_HandJointData_t.

struct WVR_HandJointData

The data structure of one hand.

Version
API Level 6

Public Members

bool isValidPose

The label of valid(true)/invalid(false) pose.

float confidence

The hand confidence value.

uint32_t jointCount

Specify the size of the WVR_Pose_t array.

WVR_Pose_t *joints

The array of the WVR_Pose_t.

WVR_Vector3f_t scale

The hand scale value to WVR_Vector3f_t. The default is 1.

WVR_Vector3f_t wristLinearVelocity

The wrist linear velocity.

WVR_Vector3f_t wristAngularVelocity

The wrist angular velocity.

WVR_HandGraspState_t grasp
struct WVR_HandGraspState

The grasp state.

Version
API Level 16

Public Members

bool isGrasp

A grasp is happening or not, the binary version of strength.

float strength

Value from 0 to 1, with 1 represents a fully grasp.

enum WVR_HandJointValidFlag

The flags that indicate data validity of one hand joint.

Version
API Level 6

Values:

WVR_HandJointValidFlag_PositionValid = 1<<0
WVR_HandJointValidFlag_RotationValid = 1<<1

Outputs - pose - common

struct WVR_HandPoseData

The hands pose information.

Public Members

int64_t timestamp

The current time in milliseconds.

WVR_HandPoseState_t right

The pose state of right hand, refer to WVR_HandPoseState.

WVR_HandPoseState_t left

The pose state of left hand, refer to WVR_HandPoseState.

union WVR_HandPoseState
#include <wvr_hand.h>

The hand pose state.

Public Members

WVR_HandPoseStateBase_t base

Refer to WVR_HandPoseStateBase

WVR_HandPosePinchState_t pinch

Refer to WVR_HandPosePinchState

WVR_HandPoseHoldState_t hold

Refer to WVR_HandPoseHoldState

struct WVR_HandPoseStateBase

The common pose state information.

Public Members

WVR_HandPoseType type

The current hand pose type.

struct WVR_HandPosePinchState

The pinch state.

Public Members

WVR_HandPoseStateBase_t base

Refer to WVR_HandPoseStateBase

WVR_FingerType finger

Which finger moves near or far to thumb, WVR_FingerType.

float strength

Value from 0 to 1, with 1 represents a full touch between fingers.

WVR_Vector3f_t origin

The pinch origin.

WVR_Vector3f_t direction

The pinch direction.

bool isPinching

A pinch is happening or not, the binary version of strength.

enum WVR_FingerType

The finger name.

Values:

WVR_FingerType_Thumb = 1

Represent thumb finger.

WVR_FingerType_Index = 2

Represent index finger.

WVR_FingerType_Middle = 3

Represent middle finger.

WVR_FingerType_Ring = 4

Represent ring finger.

WVR_FingerType_Pinky = 5

Represent pinky finger.

enum WVR_HandPoseType

The hand pose type definition.

Values:

WVR_HandPoseType_Invalid = 0

The hand pose type is invalid.

WVR_HandPoseType_Pinch = 1

The hand pose type is pinch.

WVR_HandPoseType_Hold = 2

The hand pose type is hold.

Outputs - pose - special

struct WVR_HandPoseHoldState

The hand hold state.

Public Members

WVR_HandPoseStateBase_t base

Refer to WVR_HandPoseStateBase.

WVR_HandHoldRoleType role

The role type of hand hold, refer to WVR_HandHoldRoleType.

WVR_HandHoldObjectType object

The object type of hand hold, refer to WVR_HandHoldObjectType.

enum WVR_HandHoldRoleType

The role type of hand hold.

Values:

WVR_HandHoldRoleType_None = 0

The role type of hand hold is none.

WVR_HandHoldRoleType_MainHold = 1

The role type of hand hold is main hold.

WVR_HandHoldRoleType_SideHold = 2

The role type of hand hold is side hold.

enum WVR_HandHoldObjectType

The object type of hand hold.

Values:

WVR_HandHoldObjectType_None = 0

The object type of hand hold is none.

WVR_HandHoldObjectType_Gun = 1

The object type of hand hold is a gun.

WVR_HandHoldObjectType_OCSpray = 2

The object type of hand hold is a OC spray.

WVR_HandHoldObjectType_LongGun = 3

The object type of hand hold is a long gun.

WVR_HandHoldObjectType_Baton = 4

The object type of hand hold is a baton.

WVR_HandHoldObjectType_FlashLight = 5

The object type of hand hold is a flashlight.

How to use

Sample function:

#include <wvr/wvr_hand.h>

if (WVR_StartHandTracking(WVR_HandTrackerType_Natural) == WVR_Success) {

    WVR_HandTrackingData skeleton = {};
    WVR_HandPoseData pose = {};
    if (WVR_GetHandTrackingData(WVR_HandTrackerType_Natural,
                            WVR_HandModelType_WithoutController,
                            WVR_PoseOriginModel_OriginOnHead,
                            &skeleton, &pose) == WVR_Success) {
        // get hand tracking data success
        switch (pose.left.base.type) {
            case WVR_HandPoseType_Pinch:
                LOGI("left hand shows pose");

                /* sample code of isPinching starts */
                if (pose.left.pinch.isPinching==true)
                    LOGI("pinch is happening"); // some interactions with user
                else
                    LOGI("no obvious pinch");
                /* sample code of isPinching ends */

                /* sample code of strength starts */
                if (pose.left.pinch.strength > info.pinchTHR) // thresholds from WVR_GetHandTrackerInfo() or customized
                    LOGI("pinch state ON");
                else if (pose.left.pinch.strength < info.pinchOff) // thresholds from WVR_GetHandTrackerInfo() or customized
                    LOGI("pinch state OFF");
                else
                    LOGI("pinch state keeps");
                /* sample code of strength ends */

                break;
            case WVR_HandPoseType_Hold:
                LOGI("left hand shows special pose - hold");
                break;
            default:
                LOGI("left hand shows no pose");
                break;
        }
    } else {
        // start hand tracking failed!
    }

    // WVR_StopHandTracking

} else {
    // start hand tracking failed!
}