Home Creators Posts Import Register Favorites Logout

Content

HAHA! Very excited about this!! Nathan just put together a python script to get google's mediapipe face-tracking data into blender! [quick edit- to help with any troubleshooting, if you're posting about having a problem, including your OS, whether you had problems installing python/the libraries, and a screenshot of the command terminal (both what you put in, and what it said), very much increases the odds we can help you :) ]

It's not useful for everything, but for some things, it's an absolute life saver.Get the Face Tracker Python Script here at Eat The Future.Here's a text version of what I cover in the video (along with some easy-to-copy-and-paste text):

FOR INSTALLATION:Make sure Python is installed for your system(you might have to uninstall any out-of-date versions)Open a command prompt and install the libraries, one at a time, using:

pip install numpy

pip install opencv-python

pip install mediapipe

Create an environment variable:PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATIONwith the variable itself beingpythonAnd finally, download the script linked above (and as seen in the video) from the Eat The Future github page.

TO USE THE TOOL (probably best explained in the video, honestly)

 For Orthographic Mode:

Open a command prompt, and drag in the python script

Make sure there's a space. 

Drag in the video to be tracked.

Another Space. 

Set the Destination for the mdd file (I usually drag in the video again, and change the filetype to ".mdd")Mine looks like this:

Hit Enter, and off it goes!

For Perspective Mode:

The same thing, but just one more bit of information. 

Open a command prompt, and drag in the python script

Make sure there's a space.

Decide whether you want to use Field of View (FOV) or the camera settings (Sensor Size and Focal Length)For FOV, put 

--fov ##(replace "##" with the estimated field of view)

For Focal Length, put

--focal_len ##/##(replace "##" with the sensor size and focal length, respectively)Add a space. 

Drag in the video to be tracked.

Another Space.

Set the Destination for the mdd file (I usually drag in the video again, and change the filetype to ".mdd")  

Mine looks like this

Hit Enter, and off it goes!

Anyways!! We hope this is useful to someone out there! At some point we'll be releasing it to a wider audience, but in the meantime just wanna make sure it works for all you here!And unfortunately, as I say in the video, while we super want this to work on your machine, there's a lot of variables to account for, so no promises. That said- I've been able to successfully install it on every windows machine I've tried, so I'm optimistic! 

Files

Automatic Face Tracking

Nathan put together a python script to get google's mediapipe data into blender! Check out the patreon post for all the links and such. https://www.patreon.com/posts/68138545 0:00 Introduction 4:54 Installation 5:20 Installing Python 6:55 Installing Libraries 7:31 Creating Environment Variable 7:54 Download Script 8:15 How To Use 13:17 Perspective Mode 15:40 Closing Thoughts

Comments

HD-4884

Any updates on this ? :) Love your work btw!

Sawyer Anderson

This is so cool!!! Would it be possible to repurpose something from this to do an automatic 3D camera solve? I always have trouble getting it done correctly.

Robin Ruud

So cool! Do you think it is detailed enough to drive another face rig? Could you copy Ryan Gosling's acting?

IanHubert

Oh! You mean to animate the camera instead of the head? I think it might be tricky to use that way- you might be able to use constraints to cancel out the rotation of the main empty and apply it to a camera instead... (AND ACTUALLY, for my first attempt, without the tool, I used blender's motion tracker on just a head, and was able to get exactly that result! It's just a bit more hands-on).

IanHubert

Ah yeah! The video texture carries quite a bit of the weight, but if you can figure out how to translate the data, you could totally drive a different face rig! It's fun to watch the results in grey solid-shaded mode. My guess is it might be... quick, but uncanny.

IanHubert

I hope so!! My biggest reservation putting this out is it's ALMOST useful enough for a lot of things, but not 100% of the way there, so I know it's gonna be a little frustrating.

Lorenzo Coluccia

some deepfake tool seems to be pretty good on face tracking, on github there is this tool that is called "DeepFaceLive" that work great, maybe it's opensource and you can see what they have done

Lorenzo Coluccia

ohhhh, maybe from SparkAR (the tool to make the instagram filters) you can take mesh data and other things

IanHubert

Yeah! There's a lot of stuff out there implementing the same technology, I just wasn't able to find a way to save any of it into a mesh sequence you can work with in blender :D

Sean Sevestre

You lads are legends for this, will definitely play around with this for a new project

_us.studio

Heyyyy this is cool! Also Brian was the voice of a character in a little animated film I worked on!

Dyrgrip FX

Woooo... Nice! Gotta try it out during vacation. Thank you for this! :)

IanHubert

He's so good! Knocked it right out of the park :D

hot_stuff

wow ian should give Nathan a rise

Hans Jacob Wagner

Just the YouTube fix I needed 🤣 it'll be interesting to see what you'll use it for - I'll definitely wait for Nathan's wrapped up installer.

PlanetAlexanderProjects

Do you think you could take Ryan Gosling's face, slap on some bleached hair and stick it on a hunky body in a denim jacket?

Luigi

Thank you so much for share this with us. Can’t wait to try it

hot_stuff

why does it send me to notes when i hit enter

Ophir Kutiel

see if windows is set to open .py files by defult with the txt editor instead of python if that dosent work try typing in the cmd python then space and then the script and videos

James Wright

I apologize if I heard incorrectly, but I think you said in the video that it pulls data from Google to identify things like faces, hands, arms, etc. If that is true, would it be possible to expand this plugin to become a suitless mocap tool? You know, for those of us that don't have the funds at present for a Rokoko.

Joshua O'Brien

This is a pretty cool tool, I’m expirementing with an idea that this can be used for adding decals and surface imperfections but also to see if this tracked head can be parented to a 3d scan of a person or cybernetic being, to get complex facial movements Like the ones in Akira. But great stuff, thanks

Olle Stjerne

Really cool, and easy to do as well! I tried it on my bearded face and it worked like a charm. Hard to figure out the focal length and sensor on the iPhone front camera, perhaps there is a handy excel somewhere!

Ian Letarte

Dang this is fantastic. Also this is what I get for being a Lunix user that is not a terminal wiz D:

Second Dune

Mac user reporting in: Tried to do the install this morning but ended up blocked by mediapipe install on MacOS. I'm sure it can be figured out but its unfortunately not as simple as installing with pip. That said, it's pretty straightforward to use a VM (UTM, VirtualBox) running Linux and follow your instructions. You just pass the video over to the VM, do the processing there, and then bring the resulting mdd file back over to Blender. If I figure anything easier out, I'll share. Thanks Nathan and Ian, this is AWESOME.

Josh Bailey

Ooooh, this may be perfect for an upcoming project. Thanks again Ian & Nathan!

Nathan Vegdahl

So, quick correction for anyone that sees this comment: OpenCV has nothing to do with Google, as far as I know. (I tried to communicate that to Ian, but I think I wasn't very clear... as is often the case with me, ha ha.) Mediapipe, on the other hand, is very much a Google thing, and in true Google fashion is essentially unsupported. Hence why I can't really offer support either since 99% of what this script does is just call Mediapipe to do everything.

Nathan Vegdahl

It's very unlikely that I'll be putting together any kind of easy installer for this, unfortunately. Unless someone else has some good tips on how to package a Python script with several external library dependencies into a single executable file, on multiple platforms.

Nathan Vegdahl

Mediapipe (Google's thing that this script uses) does have a module for pose tracking as well. But looking at their results, it doesn't look like it would be very useful for motion capture, unfortunately. Specifically, it doesn't track enough points, so it's essentially impossible to tell the curvature of the spine among other things: https://google.github.io/mediapipe/solutions/pose.html

Jostein Lie Svalheim

Oh, don't be so hard on yourself, Nathan. I'm sure Ian is 100% to blame.

Nathan Vegdahl

Ah! Good to know! Thanks for figuring that out.

The Water Lettuce Society

I kid you not, last night i was talking with my production crew about a film we are working on and how we could accomplish a change in eye color affect for when the characters get taken over by the villain. I suggested it would be possible to create/use a filter on our phones but that was looking to be a huge hassle exporting good quality video with the filter. This morning i wake up and find this new video and I think from what i saw in the video that this is going to be our golden ticket. Thank you so much Ian and Nathan. It always seems that you guys are able to come up with a solution whenever i’m struggling through a project.

John Abraham

You should look at Deepmotion. It's trackerless motion capture. The Corridor guys have used it in a few videos, namely the "first every CGI character" video.

Stephane Mélo

I'm an old dude, when I was young I thought we'd get flying cars before I die. But this, this, people, looks like the future to me. That's absolutely amazing. What a time to be alive, hey?

Nathan Vegdahl

Yeah, some of the AI-based mocap stuff out there is pretty interesting. I actually did some consulting for a company working on that. But so far my impressions haven't been very positive. Maybe it will get better as they figure more stuff out, but as it *currently* stands it has similar issues to this face tracking script: it works for doing certain limited kinds of things, but it's not really accurately tracking things in 3D, and tends to look a little funky especially from angles other than the one you shot it from. The Corridor Crew guys get away with it in that video since they're driving a character that's *supposed* to be floaty and weird anyway. You could also probably use it to drive e.g. distant background characters, since the mocap doesn't need to have good fidelity/accuracy for that. But overall, I'd say right now the marketing behind AI mocap is overselling it a *lot* as compared to what the tech is actually currently capable of. Again, might get better in the future. But right now it's pretty underwhelming outside of specifically crafted demos.

Nathan Vegdahl

Ah, cool! Hope it works out. The face tracking data that Google's Mediapipe library produces isn't super accurate, so I'm not sure how well it will work in practice. But sounds like it's worth a shot. (Having said that, tracking just eyes is a lot simpler, and could probably be done in 2D with other tools?)

XLR8Designers

I am super excited about this new tool for blender, that is so awesome. I have been looking everywhere for something that allows me to use this feature in multiple programs and making it for blender is a game changer. I also found something similar though it only works with after effects (windows only) and requires Element3D, https://news.productioncrate.com/download-crates-face-relighter-for-after-effects/ Cool tip: If you take the obj sequence into blender, add a seam, uv unwrap, you can copy the uv map and paste it to every obj frame in blender and then you can import it back into After Effects into Element3D and add things like rain distortion to make it look like rain is falling on the face. There is still that jitter problem that is mentioned in your video, but I loved that trick you showed about blurring the image (Wondering if that would help with this other tool). I hope this is useful for someone.

Noneya D Biznazz

I got an error ... "TypeError: Descriptors cannot not be created directly." Fixed it by doing \>pip install protobuf==3.20.* Running now, fingers crossed

Ophir Kutiel

that is really crazy!! thank you! any creative ideas on how to stick this mask nicelly onto a head model ?

Sebbir Visuals

I hope Blender is taking notes. Imagine if this became a stable build in addon to Blender

Clément Jolivet

I installed everything but when i launch the final command i just get this : Traceback (most recent call last): File "F:\RESSOURCES\BLENDER\face_track-master\face_track.py", line 73, in with mp.solutions.face_mesh.FaceMesh( File "C:\Users\Clément\AppData\Local\Programs\Python\Python310\lib\site-packages\mediapipe\python\solutions\face_mesh.py", line 94, in __init__ super().__init__( File "C:\Users\Clément\AppData\Local\Programs\Python\Python310\lib\site-packages\mediapipe\python\solution_base.py", line 253, in __init__ validated_graph.initialize( FileNotFoundError: The path does not exist.

hot_stuff

what did i do wrong i tried doing it for two days and still no luck why nathan whyyyy!!! C:\Users\pc>"C:\Users\pc\3D Objects\face_track-master (1)\face_track-master\face_track.py" "C:\Users\pc\3D Objects\face_track-master (1)\face_track-master\Please work.mov" "C:\Users\pc\3D Objects\face_track-master (1)\face_track-master\Please work.mdd" usage: face_track.py [-h] [--fov FOV] [--focal_len FOCAL_LEN] input_video output_mdd face_track.py: error: the following arguments are required: input_video, output_mdd C:\Users\pc>

Ophir Kutiel

did you try typing in the cmd python then space then all the rest ?

Ophir Kutiel

any way to normalize the head so it will stay still and ill have just the face expressions ? tnx

IanHubert

Ooo- not particularly cleanly (or in ways that would make much sense typed out, I suspect)- but you could try parenting a camera to the main empty behind the face, and at least see what it might look like? For something more stationary in world space, I'd duplicate that empty, bake the action, invert the rotation animation curves, then parent the original empty to the inverted empty, hopefully canceling out the overall head motion... I'm not sure if that'd work though (not near my computer, at the moment). If you have control over the shooting environment, just keeping the head super stationary (maybe setting up some supports) would probably work even better.

Rodeo's 3D Emporium

Reckon this data could be used to puppet another model, as a sort of makeshift face capture ?

IanHubert

Ah thanks, both of you! I'm trying to put together a list of problems folks might run into- these are great. :D

IanHubert

Dang! That's so close to working! The frustrating part of all this is I'm very ill-equiped to troubleshoot if stuff isn't working- but I've had that happen a few times when the formatting is wrong. Can you post what you're typing out??

Ophir Kutiel

tnx a lot for the reply .. i tried the inverted rotation location parenting .. it works for the location but for the rotation it didnt because the origin point of the face is at the camera so it turnes around that ..(hopefully this makes sense) .. i also tried stebelizing the footage before creating the mdd but it kinda worked .. guess shooting stable is my best bet... anyway this is really cool!!! trying to find a way to attache the face to a body .. tnx a lot

hot_stuff

it workkkkkkkked!!!!!!

hot_stuff

ophir and curd williams thank you!

Christian Clavet

This is really cool! Perhaps there could be a way to reproduce the motion and expression of the face on a character. So this script could become also "face motion capture" 😁

Steve Cypert

So everything works in 3.2 Windows until I load the .mdd and movie file. I get a Vertex Count Mismatch error. The face mesh size is unchanged and the full screen video appears within the mesh. Has anyone else encountered this problem? I've made several attempts using the face_mesh blend file.

IanHubert

Now THAT is a very weird error... it's a long shot, but is there any chance you moved the subsurface modifier above the MeshCache modifier? Cause that'd definitely do it.

Bombardier0

Thank you so much! I was starting to learn how to use protobuf and it was NOT VERY FUN

Noneya D Biznazz

I used Deepmotion for this clip I'm working on. The output animation is always wonky but after leveling up a bit in the graph editor it's not so horrible to fix. I imagine there's a lot less cleanup with the Rokoko suits, but until I can afford one, its better than the other things I've tried like Xbox Kinect or Mocap4All. https://www.youtube.com/watch?v=aD2smZXOFxM original output from Deepmotion: https://youtu.be/yuf-0ND3pCk

Noneya D Biznazz

Working on that problem too... attaching to body I mean. I am going to try to Deepmotion mocap a scene, then try to match it up with the face capture of that scene. I'm hoping I can find something that doesn't look like eldrich horror but I suspect I'll spend a week in the graph editor before I'm happy with it

Ophir Kutiel

Reporting back that the flipped rotation location works but it’s still shaky and not possible to attach to a body.. @Noneta D Biznazz wold love to know if u get anything working✌🏼

James Wright

Thanks. I will check it out. 👍

Steve Cypert

I compared my parameters to those on your video and everything looks the same.

Steve Cypert

I have it working on a different PC. Thank you.

Steve Cypert

After some experimenting, I found that by scaling the video to better focus on the face, the script was able to do its work.

Clément Jolivet

Just read your quick edit, here's a screenshot of the error, the same on my two machines on which the rest of the install went fine. Thanks a lot if you have any idea about the problem : https://i.ibb.co/x2KtSmq/Untitled-1.jpg. Typing Python before the command did the same result.

Will Tejeda

@Nathan maybe the new pyscript library would make install easier by turning this into a web app that would just run in anyones browser locally. I the ink the external libraries would just have to be hosted as wheels to make installing the dependencies easier ( if even needed, I’m not sure if pyodide already has support for media pipe on the backend )

Noneya D Biznazz

Ok, so its "kinda" working but I need to try again from the beginning to see if I learned anything along the way that will improve it. I fed footage to deepmotion and got back animation, then retargeted via the rokoko plugin to my model's rig, then I did the facetracker w/ focal length (completely guessing because I forgot what it was originally) and eyeballed the model's position, added IK to the head bone and bone-constraint-parented it to the big center face-tracking empty. The results, while not good, warrant another attempt before giving up on it. I think I may get better results with the default facetracking output, my focal length guessing may have made it a lot worse than just scaling it. https://youtu.be/VSDJGTwtVrg

Ophir Kutiel

Hey tnx for the update @Noneya D Biznazz .. it actually looks pretty good! I’ll have a go at it myself and will let u know if I find something new.. Tnx✌🏼

Noneya D Biznazz

Here's the original scene for comparison https://youtube.com/watch?v=6VZzzmaW_aA, it was atrocious trying to match up the end when he went into the stance so I'm expecting big movements to have to get a lot of fine tuning, but there were big patches where it kinda worked ok for a bit with only minor adjusting. I'll post the next attempt in a few days if it is forward progress

Noneya D Biznazz

This helped thank you. Couldn't figure out what was going on lol

knck

HI , Ian. Thanks for wonderful face tool!! I have a question, Is there way to export This moving face object? I exported this moving face at FBX , and Imported this , it is not moving, and just a stopping object, not animated.

Noneya D Biznazz

It was forward progress on a dead end street. I shouldn't have used the focal length option... Considering I'm trying to match up to a flat video, moving the face tracker in perspective is just making it more difficult. I think I have a better idea now what to do, 3rd time is the charm?

Ophir Kutiel

tnx for the update ... looking forward to c if u get anything in the 3rd one..

Noneya D Biznazz

Has anyone set up a place to pool info on this other than this thread?

Noneya D Biznazz

Ok so I got some measure of success... This is a quick dirty eevee render to show how it is goin so far... I still have a little blip to tweak here and there, https://youtu.be/49t0EwaRmIA Seems the secret is dick tracking lol Face track w/ plugin, NOT persective Get deepmotion mocap of the same video (I sped mine up from 60 to 100 fps and resampled at 30 fps for Deepmotion, less jittery and cheaper because your shot length is squished but when you expand the animation back to length you get keyframes every few frames instead of a keframe every frame, so it seems smoother) I used Rokoko's plugin to retarget to my character's rig. I retarget before doing the length rescale, do that on your character's keyframes afterward. In pose mode, select all the keyframes and scale by the inverse of whatever math you used to speed up your video (not the resample fps), then line up animation with the video. Should be pretty close Track the zipper on the pants using the same video you squeezed for deepmotion, unsquozen ofc, make empty from track, hip bone gets child of constraint to this empty head bone gets IK with the FaceMesh.Tracker empty as its target (or even better, a second empty parented to that one sitting behind it where you imagine the spine pivot would be), IK chain is just however far down the spine you think looks good, some scaling and finagling necessary, delete all location data from all bones you just want the rotation data only. I had to do some graph editor to deal with problems after the retargeting step, but this is normal for deepmotion. I am probably forgetting something, but this should get you most of the way there. Oh I had to render with ortho camera so the perspective on the model is pretty much not. I am going to try the more complex motion at the end of the scene next

high tim

Hi, Ian. When I ran cmd and put everything you showed. Cmd just opened the code, nothing happened.

Vitangelo

Am I the only getting parse error on input when trying the script? :( "face_track.py" "virgieinput.mov" "virgie.mdd" from the current folder gives me parsing error on video input and output (also tried absolute paths but no success)

Maddsketch

it's happening to me as well

Noneya D Biznazz

Ok, so its having trouble finding the solution_base.py file... so find that file in your system and copy the folder it belongs to and paste the copy of that folder into the location where your error message says it expects it to be. If that doesn't work try removing and reinstalling mediapipe ... you just want it to find those two files its looking for

Curd Williams-Hertz

My footage is always upsidedown when imported :/ anyone know how to fix this?

Boris

Ooh BDG!

Harvey Abrahams

When this gets fully polished please post the final results! Fingers crossed for Mac owners

Ziggy Gamble

Anybody else having issues with their face mesh NOT receiving lights when in perspective mode? I'm trying to have an HDRI/light/hologram shader light up the face mesh somewhat accurately but it never seems to be affected by it.

IanHubert

Only in perspective mode?? But it IS affected by the light when orthogonal? Cause that's bizarre! I can't think of anything that would make that happen!

Ziggy Gamble

Actually, it isn't receiving lights in ortho either which is interesting! Hmm. So if I have a spot on there or a hologram in front of the tracked face mesh, the face mesh is not affected by either. I'm wondering if it's a limitation of the mesh cache modifier?

Michel Kiwic

This is amazing! Thank you so much. Is there a way how to project the video texture on the facemesh and zero out the head movement and rotation? I would like to track one face on another - deepfake style... Thank you for any tips in advance.

Ben Catman

This is so great Ian. One question though - do you have any idea how to get around the problem of "wrong vertex count" when trying to model the base face mesh ? and do you guys have any idea how to apply the track to another face - mesh? Thank you so much for your work!!

Justin G Minich

For reasons I don't understand, the MDD file created only starts tracking on frame 73 of a 103 frame shot.

FILIPE FENNER

If i make a fight scene with photoscan characters, and use this techinique to put real footage faces on some scenes, it might work? Blend the photoscan character with the face footage

Wolfers

NATHAN! why are you so frellin awesome?