Hello babylonJS community! We are struggling while doing an application using babylonJs + MediaPipe, i will appreciate all answers that may help us to get right direction!
What’s my goal?
- I am trying to use babylonJS paired with MediaPipe to render a video with models on top of it.
My output should be: Mobile camera video with rendered models on our fingers (nails). - Media pipe renders video in < video > element, < video > and < canvas > must be layered so canvas is on top of < video >. Or if there is a possible way to render a live video directly in canvas/WebGL (BabylonJS)
What’s the problem?
- I can not transform coordinates that mediaPipe returns to display them in BabylonJS at right place.
- What is best camera type for this solution?
- Should we use WebXR instead ?
- How to transform normalized x,y, z coords with Width/Height of < video element> into babylonJS scene
MediaPipe returns:
- normalized coords X,Y,Z relative to our screen (for each joint)
- World coords with the origin at the hand’s approximate geometric center.
MULTI_HAND_LANDMARKS
Collection of detected/tracked hands, where each hand is represented as a list of 21 hand landmarks and each landmark is composed of
x
,y
andz
.x
andy
are normalized to[0.0, 1.0]
by the image width and height respectively.z
represents the landmark depth with the depth at the wrist being the origin, and the smaller the value the closer the landmark is to the camera. The magnitude ofz
uses roughly the same scale asx
.MULTI_HAND_WORLD_LANDMARKS
Collection of detected/tracked hands, where each hand is represented as a list of 21 hand landmarks in world coordinates. Each landmark is composed of
x
,y
andz
: real-world 3D coordinates in meters with the origin at the hand’s approximate geometric center.MULTI_HANDEDNESS
Collection of handedness of the detected/tracked hands (i.e. is it a left or right hand). Each hand is composed of
label
andscore
.label
is a string of value either"Left"
or"Right"
.score
is the estimated probability of the predicted handedness and is always greater than or equal to0.5
(and the opposite handedness has an estimated probability of1 - score
).
Source: Redirecting