Closed tomleader closed 3 years ago
@sgowroji ok,I create a codepen demo(under chrome) : https://codepen.io/tomleader/pen/XWMaZqr
allow webcam permission, then click the top-right button. Then you can see a box in the center of canvas and you move your head and the box also move by your motion;
how the demo run:
Question: How to set the right size of the box? (eg, if I come closer to the webcam, my head & the box should looks bigger, when I move away the box should look smaller). In threejs, we can set the box size by : 1. set the perspective camera & object's z-position value; 2. set the object's scale value;
This sounds like a question about the various face transforms used, in this case the one which maps 3d (x,y,z) landmark points to world-space (or something approximating a 3d world-space, but with relative scaling) coordinates. The expert on these sorts of transforms is kostyaby@, so reassigning to him.
Hey @tomleader,
What you need is Face Geometry module for JS, which currently not supported (please see #1457 for details). It'll be available eventually; however, unfortunately, I don't think this is a top priority for the MediaPipe Team at the moment.
In the meantime, you may give a go to the library suggested in this comment; it seems to be placing a mesh inside a THREE.PerspectiveCamera
quite nicely
@kostyaby thanks but that library use THREE.OrthographicCamera...I think I'll wait for the Face Geometry module for js.
Hmm, interesting. I could find a PerspectiveCamera
in this example. Maybe its support is limited, but that example definitely works somehow :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you.
Closing as stale. Please reopen if you'd like to work on this further.
@tomleader did you find a work around ? Can you post an updated codepen ? I'd love to use MediaPipe and ThreeJS (or BabylonJS)
Yes, I correctly import your code in my usecase but I agree for this "paralax effect" it's better to have a static cube and a dynamic camera that retrieve it's corrdinte from MediaPipe landmarks. But I don't know how t odo that :-)
it seems @vivien000 did it but the code is way more complexe https://github.com/vivien000/trompeloeil
Hi everyone. Are there any solutions in JS today to use face mesh points detected by mediapipe for placing 3D models on the face? I'm working on a project where I'm using mediapipe in react. I was able to successfully render my Glb 3D model on the face but I would like to try to place it in a specific point of the detected mesh. I also use a second model to simulate the occlusion of the face and this seems to fit the face perfectly. How can I find the coordinates of this point?
in threejs camera fov is vertical fov so zbox = screenheight0.5/Math.tan(camera.fov0.5*Math.PI/180)
We know that: send a image/video to facemesh, then we can get an key point landmarks object array like[{x:0,y:0,z:0},...] sometimes we use Three.js to build some 3d or AR object around the face(which means the object's position&scale == face's position & scale), I can use the x&y to calculate the 3d position (x,y) but the z value I can not figure out how to use. The short question is ,input a landmark object array, a perspective camera, how can I get the 3d object (x,y,z) & scale, is there some examples?