Giter Club home page Giter Club logo

strongtrack's Introduction

StrongTrack v0.8

There is a 0.9 preview branch here . Functionality such as webcam support is not fully functioning in this build.

Download the windows 10, (64 bit only) version of 0.8 here (google drive. 114 MB zip).

Example projects for UE4 and Blender may be found at the bottom of the page.

Hi there! Here you can find code for StrongTrack, a tool for landmark annotation and finding coefficents for facial animation. If installing python/libraries (see below) is intimidating and you're running a windows 10 (with a 64 bit installation...which it probably is) I recommend trying the exectuable linked above. This executable consists of the code contained within this reposititory passed through pyinstaller for packaging. I'm working on a full install process for windows/mac/linux to further lower the barrier to entry but this may take a while.

This tool is still at an early stage of development by a non-professional. Although I have put it through its paces as thoroughly as I can, you use this software at your own risk (see license for more)

Screenshot

0.8 Release Notes

  • Pretrained model that allows for the ability to 'guess' landmarks for the whole face or mouth seperately, rather than manual placement.
  • Initial webcam support for recording and streaming animation as well as record and reopen video.
  • Removal of non function eye tracking to avoid confusion (eye tracking to be added in 0.9 or 1.0 depending on development of pretrained model).
  • Improved UI feedback for certain actions such as training or alerts when creating duplicate files.
  • Better automatic enabling and disabling of buttons/options that would lead to crashes if pressed at times prior to intended time.
  • Improved handling of video with different frame rates
  • Option to open 'previous model' instead of having to manually selected each time when using a previously prepared model
  • Minor bug fixes and UI clean up.
  • New default training assets with texturing

Overview

This a python based tool for finding coefficients for facial animation from RGB video. Coefficients can be exported as a numpy save file (for importing into Blender for example) but can also stream into Unreal Engine (or elsewhere) via OSC.

This solution is made up of two core components; Facial landmark tracking and a decomposition to produce coefficients. For landmark tracking this respository includes a method to train and refine a model based on your own footage. Once you are satisfied with the landmark tracking you have each subject pull a number of distinct poses (neutral, smile, jaw open etc) and store these as key poses that are then used as the basis for the decomposition into coefficients. Landmarks from someone half smiling with their mouth open would be decomposited into a result with a 0.5 smile, 0.5 jaw open for example. These coefficients are what is then exported out to a save file or streamed (or both).

Requirements

  • Python3
  • Unreal Engine 4.25 or above (if using UE4)

As well as these python libraries

  • OpenCV (for media and rendering)
  • Dlib (facial landmark tracking and training)
  • Sklearn (linear regression/decomposition for coefficients)
  • Numpy
  • PythonOSC
  • XML elementree
  • PyQT5 (for GUI)

Installation and running

Assuming you have python and the libraries listed above installed correctly run python strongtrack.py If you have using the executable nagivate to the 'executable' and run 'strongtrack.exe'.

You'll be presented with a GUI interface where you can pick a video to analyse as well as the option to create a new model or load up a previously created model. Only once a model has been created or loaded will the video and annotation tool appear.

The project name you enter/use is used to set aside different training data and keyposes for multiple faces. XML files, model files and keyposes are created in the 'projects' directory.

Workflow pt 1 - Landmark placement.

Video the subject pulling a series of keyposes. Neutral, jaw fully open, closed smile, lips funnel, lip pucker, brow up, brow down, eye closed. These keyposes are useful for quickly training a landmark model. As of ver 0.5 this tool is stil very much built for mostly stationary faces so if possible a head mounted camera is strongly recommended, but footage with a mostly stationary subject will still work.

Upon opening this video with StrongTrack you'll be presented with the video alongside a generic unmatched set of facial landmarks. Scrolling the video and entering landmarks is only possible when the video is paused. Pause the video with the SPACE KEY at the neutral pose and place the landmarks at the corresponding place upon the face. It's important you start with a neutral frame because this will enable you to later use the N key whenever you want to return the lips to a neutral pose, which is a great time saver.

Left mouse click to move individual points and right click to move face groups (jaw, eye, nose etc). The W key welds the lips together as a time saver. Points in white move points around them with a drop off in influence.

Once you're happy with the placement add this to the training set with the F KEY. For this initial entry the model will then train the predictor automatically.

Head to the next frame (jaw open preferably because it is the most different) and repeat. Carry on in this manner, hitting the T KEY whenever you want to train the model. As the model becomes more accurate, less and less manual placement should be necessary.

Use the W key to weld lip centre together or N key to return mouth points to neutral. These are useful timesavers.

Hitting ESC will quit the viewer.

Workflow pt 2 - Morph targets/shapekey export.

Once you are happy with the accuracy of landmark placement you can assign keyposes for the decomposition algorithm to use to produce animation data. You should use the same footage of 'extreme' poses (neutral, jaw open, smile, funnel etc) as used in the landmark training for similar reasoning; the more different poses are, the easier it is to produce data from them.

Using the dropdown list in the control panel, assign different frames as representing different key poses, making sure to hit 'set keypose' each time. Whenever you hit 'set keypose' a datafile called 'PROJECTNAME_keyposes.npy' will be created/modified.

Once this file has been created you can proceed with the remaining two buttons on the control panel; Export to Txt and Stream OSC. It's best to commit as many different poses to the file as possible, though not all are necessary. The more provided the more accurate animation can be generated.

Workflow pt3 - Usage

To export animation ensure you're happy with the landmark tracking model and the keypose set. Open the video file you want to animate with and select the landmark model. The corresponding keypose set with be selected automatically based off the filenames. As part of this session you can continue to update and train the landmark training with the source footage to account for particular face shapes. Indeed, this will almost certainly be required if not using headmounted cameras.

When ready to export animation, either to file or OSC, it will take the form of 51 different values that combine to describe many different possible facial expressions. The names of the values can be found listed in the 'blenderimport' python script. Your model does not need to have all 51 shapes (all footage I've currently shared uses about 5-6), but the names do need to match.

These values are written to the text file as plain text as an array in the shape of (number of frames, 51). With OSC the values are streamed once a frame to 127.0.0.1 as a float array of length 51.

Workflow pt 4 - Refinement

Coming hopefully in 0.9. A process that draws on the animation analysis to make better targeted and full use of all available blend shapes/morph targets on a model.

Example project files

An Unreal Engine project (4.25 and above) can be found here (google drive. 4.6 MB zip). A Blender example project (created with 2.9) can be found here (google drive. 5.3 MB zip)

strongtrack's People

Contributors

rwsarmstrong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

strongtrack's Issues

IndexError: list index out of range after loading xml

Problem: program crashes after loading xml from the previous session

Steps:

  1. Train model
  2. Export
  3. Restart program
  4. Open webcam feed
  5. Load xml that was saved into \strongtrack\projects

could capture the error message:

updating for webcam
pausing
Division by zero was about to happen. Fix this.
XML file loaded successfully
model with values found
Keyposes extraction poses found and loaded
showing points first time
Traceback (most recent call last):
File "strongtrack.py", line 933, in loadModel
File "strongtrack.py", line 1071, in checkPredictor
File "render_functions.py", line 279, in drawFace
IndexError: list index out of range

projects.zip
If images are needed please tell me how can I share privately.

Program crashes when exporting to txt

Hello!

Just a small issue. When exporting to txt the program closes with no indication and nothing appears in the folder I directed the export to. Is it a lack of installed libraries or something else?

openVideo Dialog Shows No Files

The openVideo function shows only directories in Ubuntu 20.04 with PyQt 5.12.8.
This seems like a Qt issue. I worked around it by changing the filter (argument 4) to an empty string.
Now I am encountered many more bugs, like inability to create the model XML file because "projects" is an ambiguous file path relative to the working directory, which changes all the time when you load video files from different directories.

Possible use of android_ip_webcam for the video stream???

Hi Robert

There is a free android ip webcam that is quite easy to setup. As an indie film maker I am looking to make cg movies with no budget and trying to find a facial capture rig using plain old android smartphones. https://play.google.com/store/apps/details?id=com.pas.webcam

I can get this app working quite well on an old Samsung mini s3 I have lying around. Is it possible to get this video stream into strongtrack? My setup will be android to windows 10 running unreal engine and strongtrack.

Hoping I can build a facial capture rig using an android phone streaming to strongtrack.

Regards

Lee

Landmarks to blendshapes

Hi! First off, amazing tool! It's really great how well this works! However, I do have a question. How does this software convert landmark positions to blend shapes? I see that there is a calibration function and it works really well, but it would be really awesome to know how that works!

Summer

Error while exporting to .txt

While trying to export to .txt after doing everything in the tutorial I am getting this error "IndexError: index 2 is out of bounds for axis 0 with size 2"

I tried with a different video and different model and they both give me this error

https://imgur.com/a/cCgxcps

Program crash

I would like to know if there are any specific version for Dlib?
I am getting the application crash even though I installed all the requirements and Dlib installed correctly.

This is what I am ghetting: (Windows 10)
Traceback (most recent call last):
File "strongtrack.py", line 18, in
ImportError: DLL load failed while importing dlib: A dynamic link library (DLL) initialization routine failed.
[23644] Failed to execute script strongtrack

FYI this is the executable version.

0.9 Key Pose options greyed out

Hi,
the landmark guessing and training is better in the 0.9 preview. However, with the windows 10 .exe I can't access the 'Key Poses' options because they are greyed out. The program indicates that I have sufficient landmarks.
Let me know what I should try. Thanks.

About ue4 Project

The ue4 project link you put in readme is a livelink example, not a osc example.Is there a osc example project like Youtube tutorial?

blendshape numbers

Hi,

first thanks for the tool, it's amazing.

I'm trying your windows 10 compiled version which seems to work fine.
However, when I export the data, I have this result :
testMOCAP.txt

I don't see any blendshape names, and also it seems there are only 50 blendshapes recorded per frame, not 51 as announced, if I'm correct.
My idea is to build a maxscript to be able to test these data into 3dsmax,
I can easily extract the blendshape from this file using the shapes order you let in the Blender file, but I would like to be sure the export is correct, and if there is one blendshape missing, which one is it ?

Thanks for your time

0.9 crash when setting initial neutral pose with F key

opens up just fine. Loads video just fine. Does a pretty good job guessing all placement. I set all markers where they should be for the initial neutral pose, hit F, and it crashes.

Here is the log dump. Seems like maybe an issue with Qt5Core.dll? I"m using Windows 10-64bit. And the latests version of Python and all pip installed components:

Log Name: Application
Source: Application Error
Date: 5/22/2021 6:37:38 PM
Event ID: 1000
Task Category: (100)
Level: Error
Keywords: Classic
User: N/A
Computer: Emo-Lappy-Dev
Description:
Faulting application name: strongtrack.exe, version: 0.0.0.0, time stamp: 0x5ffec122
Faulting module name: Qt5Core.dll, version: 5.15.2.0, time stamp: 0x5fa4dd3b
Exception code: 0xc0000409
Fault offset: 0x00000000000204e8
Faulting process id: 0x3df0
Faulting application start time: 0x01d74f62aa37ac04
Faulting application path: C:\Users\Eric\Downloads\strongtrack0.9\strongtrack0.9\strongtrack.exe
Faulting module path: C:\Users\Eric\AppData\Local\Temp_MEI126162\Qt5Core.dll
Report Id: 93a989fb-6f60-447d-a38d-f881fbf5aa99
Faulting package full name:
Faulting package-relative application ID:
Event Xml:



1000
0
2
100
0
0x80000000000000

8147


Application
Emo-Lappy-Dev



strongtrack.exe
0.0.0.0
5ffec122
Qt5Core.dll
5.15.2.0
5fa4dd3b
c0000409
00000000000204e8
3df0
01d74f62aa37ac04
C:\Users\Eric\Downloads\strongtrack0.9\strongtrack0.9\strongtrack.exe
C:\Users\Eric\AppData\Local\Temp_MEI126162\Qt5Core.dll
93a989fb-6f60-447d-a38d-f881fbf5aa99





Linux?

Is available on Linux OS?

Having Problems Running Script in Blender

Hi, whenever I try to run the script in Blender "Python Script Failed, Check The Message in the System Console. When I do I get the messages below:

Traceback (most recent call last):
File "E:\Projects\Mocap\Blender Project\Strongtrack08BlenderExample.blend\blender_import_strongtrack_data.py", line 7, in
File "C:\Program Files\Blender Foundation\Blender 2.92\2.92\python\lib\site-packages\numpy\lib\npyio.py", line 968, in loadtxt
fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
File "C:\Program Files\Blender Foundation\Blender 2.92\2.92\python\lib\site-packages\numpy\lib_datasource.py", line 269, in open
return ds.open(path, mode, encoding=encoding, newline=newline)
File "C:\Program Files\Blender Foundation\Blender 2.92\2.92\python\lib\site-packages\numpy\lib_datasource.py", line 615, in open
found = self._findfile(path)
File "C:\Program Files\Blender Foundation\Blender 2.92\2.92\python\lib\site-packages\numpy\lib_datasource.py", line 452, in _findfile
if self.exists(name):
File "C:\Program Files\Blender Foundation\Blender 2.92\2.92\python\lib\site-packages\numpy\lib_datasource.py", line 549, in exists
if os.path.exists(path):
File "C:\Program Files\Blender Foundation\Blender 2.92\2.92\python\lib\genericpath.py", line 19, in exists
os.stat(path)
ValueError: stat: embedded null character in path
Error: Python script failed, check the message in the system console

I looked at my .txt export file and everything looks like zeros in it. Maybe I am having a problem with my export? I am using the version that runs though Blender. When I run the compiled version it crashes when I try to export the txt file. I attached my exported .txt file to this message to maybe help decode it.

BlendTestExport2.txt

Segmentation fault(core drump) on ubuntu18.04

Screenshot from 2020-09-01 13-47-41
Hi, @rwsarmstrong, thanks for your job! When I try to implement this project on linux, there is a problem: Segmentation fault. It's seems that something goes wrong with pyqt5, but I can't find any solution for this. Can you help me with that? I installed pyqt5 with the code: pip install pyqt5

Exported txt wont apply to mesh

Hi, very new to this all. Just got an exported txt, but when trying to apply it to the model nothing happens. Is the mesh configured wrong or missing something? The face mesh is separate from the clothes and pretty much the exact same as the template mesh except for the fact that the teeth and tongue are not connected to it. (I am using a makehuman model by the way)
Screenshot (128)

Python 3 version specifics

Hi

I would love to showcase your app in a short film, but really want to ask for more explicit and verbose steps to install strongtrack for a non-dev. I am using a regular laptop based webcam with win 10.

Regards and please keep on going.

Lee

Landmark export :)

Your soft is really great and could be really usefull in production.
But for now, it's useless in prod, because of the blendshapes restriction and the format you use for export.

if you have an option to export the animation of the landmark points (in FBX by exemple), we could use it to drive rigs (blendshapes or joins) in maya or 3ds.

some of my work : https://www.youtube.com/watch?v=4rmUh7mlywc&t=12s

Strongtrack 0.8

Update on first run on Windows 10.

Got my ugly mug with various poses into strongtrack. Moved all markers on first neutral pose and hit T and the app crashed. Maybe I did something wrong, so I will try again.

I had a previous crash in 0.7 and got a glimpsse of the console just before it went away. Had something to do with a divide by zero error. Probably not related. I will try my ugly mug again and give some feedback. If I can send you more info, pls mention how to do that.

Thanks for the awesome work so far.

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.