Code Monkey home page Code Monkey logo

Comments (4)

jorgejgnz avatar jorgejgnz commented on August 22, 2024

I have never used MediaPipe Hand Tracking but I will try to explain in detail how to add support to new devices and hand tracking data sources.

HPTK Input module requires an array with fixed length and fixed order where each item contains the position and rotation of each bone. InputController will postprocess these values and will apply them to master hand according to the rig mapping specified in InputModel.

The class of the items of the afforementioned array is AbstractTsf which contain position, rotation, scale and space of application (world or local). It's called AbstractTsf as it contains the spatial information of a Transform but without being connected to any gameobject.

The class InputDataProvider contains and update the array that is accessed by Input module (InputDataProvider.bones). InputModel.inputDataProvider contains the reference to a component that inherits InputDataProvider class.

To add support to a new device is required to create a new script that inherits from InputDataProvider and that overrides its function UpdateData.

InputController will call UpdateData function every frame, before accessing the array. InputController will update position and rotation for InputModel.wrist and will only update rotation for the rest of bones.

This is the ordered list of bones:

0 - wrist
1 - forearm

2 - thumb0
3 - thumb1
4 - thumb2
5 - thumb3

6 - index1
7 - index2
8 - index3

9 - middle1
10 - middle2
11 - middle3

12 - ring1
13 - ring2
14 - ring3

15 - pinky0
16 - pinky1
17 - pinky2
18 - pinky3

19 - thumbTip
20 - indexTip
21 - middleTip
22 - ringTip
23 - pinkyTip

In your overrided UpdateData function you will have to go through InputDataProvider.bones and read or calculate, at least, the world position and rotation of wrist (.bones[0]) and the world or local rotation of the rest of bones.

What if your hand tracking data source provide data for less bones? You can bypass that item so it will keep its original values or you can also pass constant values for position and/or rotation.

What if your hand tracking data source provide offseted rotations? Add a variable (Quaternion) to your InputDataProvider and apply it to every obtained rotation. Then tweak this variable from Inspector until the bone rotations is correct in master hand.

Examples of InputDataProviders
OVRSkeletonTracker
RelativeSkeletonTracker

I hope this has been helpful to you :)

from hptk.

f6ra07nk14 avatar f6ra07nk14 commented on August 22, 2024

Thank you for your prompt reply. :)

In brief, the simple way is that I just need to inherit the class InputDataProvider, and re-implement the function UpdateData to make it provide the Transforms of each bone.
I already known how to convert the hand joints provide by MediaPipe Hand Tracking to the above ordered list of bones (Oculus version).

How about the camera (like MainCamera or ARCamera) works with the HPTK? or I can ignore this question.
In my case, because my camera was fixed at the same place, unlike Oculus, Oculus has 6 DOF to dynamically track the Head-mounted display.

from hptk.

jorgejgnz avatar jorgejgnz commented on August 22, 2024

CoreModel component in HPTKCore prefab contains a reference to the camera that represents the point of view (PoV) of the player. This is access by any AvatarController when its AvatarModel.followsCamera is enabled. AvatarController will move AvatarMovel.headSight. This headSight transform and the transform of both hands drive the rest of the parts of the body, including the shoulders. The shoulders are required to calculate the direction of HandModel.ray when ProxyHandModel.rays is enabled.

If you want to use hand rays or other body parts of the avatar in your app and the camera will represent the PoV of the player, then you should pass the camera to CoreModel.trackedCamera and make sure that AvatarModel.followsCamera is enabled.

If your camera won't follow the PoV of the player (mobile AR or desktop applications), leave CoreModel.trackedCamera empty and AvatarModel.followsCamera disabled.

AvatarModel and AvatarController may receive changes in the future.

from hptk.

f6ra07nk14 avatar f6ra07nk14 commented on August 22, 2024

Thanks! 👍

from hptk.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.