{"id":439,"date":"2017-10-10T09:29:30","date_gmt":"2017-10-10T14:29:30","guid":{"rendered":"http:\/\/ciraldo.stream\/uwm-vfx2\/?page_id=439"},"modified":"2017-10-17T18:04:04","modified_gmt":"2017-10-17T23:04:04","slug":"face-tracking","status":"publish","type":"page","link":"https:\/\/ciraldo.stream\/uwm-vfx2\/topics\/face-tracking\/","title":{"rendered":"Face Tracking"},"content":{"rendered":"<h1>Face Tracking<\/h1>\n<p>[ <a href=\"https:\/\/ciraldo.stream\/uwm-vfx2\/topics\/face-tracking\/\">Lecture Notes<\/a> ] [ <a href=\"https:\/\/ciraldo.stream\/uwm-vfx2\/topics\/face-tracking\/lab\/\">Lab<\/a> ] [ <a href=\"https:\/\/ciraldo.stream\/uwm-vfx2\/topics\/face-tracking\/homework\/\">Homework<\/a> ]<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Face Tracking<\/strong> is a special type of motion tracking. After Effects tracks various <strong>facial features<\/strong>\u00a0and <strong>structures,<\/strong> and can also calculate a few <strong>&#8220;measurements&#8221;<\/strong> based on the tracking data, such as <strong>&#8220;mouth open amount,&#8221;<\/strong> <strong>&#8220;eyes closed amount,&#8221;<\/strong> and others.<\/p>\n<p>With\u00a0<a href=\"https:\/\/helpx.adobe.com\/after-effects\/using\/expression-basics.html#expression_controls_effects\" target=\"_blank\" rel=\"noopener\" class=\"broken_link\">Expression Controls<\/a> and a wee bit of <strong>expression script,<\/strong> we can also create some useful measurements of our own, such as <strong>&#8220;Face Center&#8221;<\/strong> or <strong>&#8220;Face Angle&#8221;<\/strong>.<\/p>\n<h2>Uses For Facial Tracking<\/h2>\n<p>The facial tracking feature was added to After Effects in 2015, so it&#8217;s still relatively new to AE. It was added along with an early release of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Adobe_Character_Animator\" target=\"_blank\" rel=\"noopener\">Adobe Character Animator<\/a> (which is an app used to <strong>animate cartoon characters faces<\/strong> in <strong>real-time<\/strong> using a <strong>webcam <\/strong>and an actor&#8217;s facial expressions, mouth movements, etc.)<\/p>\n<p>After Effects supports <strong>sending facial tracking data to Character Animator,<\/strong> so it seems this was one of their primary intended uses for Face Tracking. Even so, there are a few interesting things we can do with the feature strictly within AE, such as facial distortion, color correction, blemish removal, puppet pin control, and probably lots of things that haven&#8217;t even been thought of yet.<\/p>\n<h2>How To Do The Tracking<\/h2>\n<p>It&#8217;s pretty easy to do the actual tracking part. This process will give <strong>lots<\/strong> of track point <strong>position keyframes<\/strong>\u00a0for facial features that we can use later on.<\/p>\n<ol>\n<li><strong>Add a footage layer,<\/strong> one with a person&#8217;s face in it.<\/li>\n<li>Find a good\u00a0<strong>&#8220;rest pose,&#8221;<\/strong>\u00a0a frame of the footage in which the face\u00a0 as straight-facing and expressionless as possible.<\/li>\n<li><strong>Make a note<\/strong> of this frame by <strong>(a)<\/strong>\u00a0selecting the layer and then <strong>(b)<\/strong>\u00a0using the\u00a0<strong>Layer &gt; Add Marker<\/strong> menu command. (Now you should have a little gray triangle marker on the layer to remember where the\u00a0<strong>rest pose<\/strong>\u00a0is.)<\/li>\n<li><strong>Create a<\/strong> <strong>rough mask<\/strong> around the face to track. It can be a simple mask shape like a circle. (You basically just need to let AE know where the face is.)<\/li>\n<li>Select <strong>Animation &gt; Track Mask<\/strong> from the menu, or right-click on the mask and select <strong>Track Mask.<\/strong> The <strong>Tracker Panel<\/strong> will open so you can operate the tracking.<\/li>\n<li>In the Tracker Panel, choose\u00a0<strong>Face Tracking (Detailed Features)<\/strong> and then <strong>track forwards and backwards<\/strong> from the <strong>rest pose<\/strong> frame using the Tracker play controls.<\/li>\n<li><strong>AE will track the face.<\/strong> As it does so it will change your rough mask into one whose mask shape is auto-keyframed to tightly follow the contour of the face. Various <strong>tracking points<\/strong> will follow the movement of the eyes, nose, mouth, etc. A special-purpose effect called <strong>Face Track Points<\/strong> is added to the footage layer, and this is where the <strong>data from the track points gets stored<\/strong> as keyframes for later use.<\/li>\n<\/ol>\n<h2>What To Do With The Face Tracking Keyframes<\/h2>\n<h3>Snapchat Filter Stuff<\/h3>\n<p>You can do some simple Snapchat-filter-esque things right away by adding an\u00a0<strong>expression<\/strong>\u00a0<strong>to\u00a0the property to be controlled<\/strong> and using the <strong>expression pickwhip<\/strong>\u00a0to <strong>grab the code for a track point<\/strong> such as <strong>Nose Tip<\/strong>\u00a0for example.<\/p>\n<figure id=\"attachment_458\" aria-describedby=\"caption-attachment-458\" style=\"width: 778px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-458\" src=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-14.46.05.png\" alt=\"\" width=\"778\" height=\"149\" srcset=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-14.46.05.png 778w, https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-14.46.05-300x57.png 300w, https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-14.46.05-768x147.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption id=\"caption-attachment-458\" class=\"wp-caption-text\">Clown Nose Position Linked To Nose Tip<\/figcaption><\/figure>\n<h3>Effect Control Points<\/h3>\n<p>Some effects have one or more <strong>control points.<\/strong> For example, the\u00a0<strong>Bulge<\/strong> effect has a &#8220;bulge center&#8221;. You can place such effects directly on the\u00a0<strong>footage<\/strong> layer and link effect control points to track points as needed.<\/p>\n<figure id=\"attachment_460\" aria-describedby=\"caption-attachment-460\" style=\"width: 752px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-460\" src=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-15.01.06.png\" alt=\"\" width=\"752\" height=\"141\" srcset=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-15.01.06.png 752w, https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-15.01.06-300x56.png 300w\" sizes=\"auto, (max-width: 706px) 89vw, (max-width: 767px) 82vw, 740px\" \/><figcaption id=\"caption-attachment-460\" class=\"wp-caption-text\">Bulge Center Linked To Nose Tip<\/figcaption><\/figure>\n<h3>Adjustment Layers For Effects With No Control Points<\/h3>\n<p>For effects that <strong>don&#8217;t<\/strong> have control points (e.g., color correction stuff, blur, etc) you can add an <strong>Adjustment Layer<\/strong>\u00a0and link its <strong>position<\/strong> to a facial track point. Use a <strong>Mask<\/strong> on the Adjustment Layer to narrow its focus to the feature you&#8217;re tracking.<\/p>\n<figure id=\"attachment_461\" aria-describedby=\"caption-attachment-461\" style=\"width: 798px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-461 size-full\" src=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-15.06.33.png\" alt=\"\" width=\"798\" height=\"273\" srcset=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-15.06.33.png 798w, https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-15.06.33-300x103.png 300w, https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-15.06.33-768x263.png 768w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/><figcaption id=\"caption-attachment-461\" class=\"wp-caption-text\">An Adjustment Layer&#8217;s Position Linked To Right Pupil<\/figcaption><\/figure>\n<h2>Slight Detour: Extract &amp; Copy Face Measurements<\/h2>\n<p>To get some more detailed info about what the actor&#8217;s face is doing, click on the mask and then return to the Tracker Panel. Go to your\u00a0<strong>Rest Pose<\/strong> frame that you marked earlier, and click the\u00a0<strong>Set Rest Pose<\/strong> button in the Tracker Panel. Then click the\u00a0<strong>Extract &amp; Copy Face Measurements.<\/strong> This will create a <em>second<\/em> special-purpose effect called\u00a0<strong>Face Measurements<\/strong> with all sorts of keyframed properties within.<\/p>\n<figure id=\"attachment_468\" aria-describedby=\"caption-attachment-468\" style=\"width: 289px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-468\" src=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-16.02.18.png\" alt=\"\" width=\"289\" height=\"438\" srcset=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-16.02.18.png 289w, https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-16.02.18-198x300.png 198w\" sizes=\"auto, (max-width: 289px) 100vw, 289px\" \/><figcaption id=\"caption-attachment-468\" class=\"wp-caption-text\">Face Measurement Properties<\/figcaption><\/figure>\n<p>Note that some of these properties seem like they <strong>should<\/strong> <strong>be<\/strong> <strong>in terms of pixels<\/strong> but are <strong>instead<\/strong> <strong>in terms of percentage.<\/strong>\u00a0<\/p>\n<p>The 100% values are relative to the rest pose &#8212; pretty straightforward.<\/p>\n<p>But the <strong>non-100% property values<\/strong> are not so straight-forward to use: they&#8217;re actually a percentage of the <strong>width, in pixels, <\/strong>between the<strong> outer corners of the left and right eyes.<\/strong>\u00a0We have the track points for the eyes, but how do we get the <strong>width between the points?<\/strong><\/p>\n<h2>Getting The Distance Between Two Points<\/h2>\n<p>Let&#8217;s add a\u00a0<strong>Slider Control<\/strong>\u00a0effect to our <strong>tracked footage layer<\/strong> and call it\u00a0<strong>Eye Width.<\/strong><\/p>\n<figure id=\"attachment_469\" aria-describedby=\"caption-attachment-469\" style=\"width: 289px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-469\" src=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-16.10.56.png\" alt=\"\" width=\"289\" height=\"155\" \/><figcaption id=\"caption-attachment-469\" class=\"wp-caption-text\">A Slider Control Renamed To &#8220;Eye Width&#8221;<\/figcaption><\/figure>\n<p>Now add an expression to the Eye Width<strong> Slider property<\/strong>\u00a0and enter the following expression:<\/p>\n<pre>point1 = ; \/\/ Use expression pickwhip to grab the 1st point\r\npoint2 = ; \/\/ Same as above for the 2nd point\r\nlength(point1, point2);<\/pre>\n<p>The <strong>expression pickwhip<\/strong> should be used (not the <strong>parenting pickwhip.<\/strong>) Place the typing insertion point between the <strong>equals sign<\/strong> and the <strong>semi-colon<\/strong>\u00a0before using the pickwhip.<\/p>\n<figure id=\"attachment_470\" aria-describedby=\"caption-attachment-470\" style=\"width: 677px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-470\" src=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-16.16.36.png\" alt=\"\" width=\"677\" height=\"136\" srcset=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-16.16.36.png 677w, https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-16.16.36-300x60.png 300w\" sizes=\"auto, (max-width: 677px) 100vw, 677px\" \/><figcaption id=\"caption-attachment-470\" class=\"wp-caption-text\">Distance Between The Outer Corners Of The Eyes<\/figcaption><\/figure>\n<p>With this\u00a0<strong>Eye Width<\/strong> property in place, we can now do some conversions between percentage and pixels from the <strong>Face Measurements<\/strong> effect!<\/p>\n<h2>Expression Controls For Intermediate, Reusable Numbers<\/h2>\n<p>Now we&#8217;re starting to use expression controls to do some intermediate calculations on the face track points. Let&#8217;s create one for calculating the <strong>Mouth Offset Y<\/strong>\u00a0of the face. (This is the amount the mouth moves in the horizontal direction.)<\/p>\n<p>Add a Slider Control and rename it to\u00a0<strong>Mouth Offset Y Pixels<\/strong><strong>.<\/strong> Add the following expression to its <strong>Slider property:<\/strong><\/p>\n<pre>percentValue = ; \/\/ Pickwhip to a face measurement\r\neyeWidth = ; \/\/ Pickwhip to the Eye Width control\r\npercentValue * eyeWidth<\/pre>\n<p>Then use the pickwhip to make it look like below:<\/p>\n<figure id=\"attachment_472\" aria-describedby=\"caption-attachment-472\" style=\"width: 722px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-472\" src=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-16.35.29.png\" alt=\"\" width=\"722\" height=\"139\" srcset=\"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-16.35.29.png 722w, https:\/\/ciraldo.stream\/uwm-vfx2\/wp-content\/uploads\/2017\/10\/Screenshot-2017-10-17-16.35.29-300x58.png 300w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><figcaption id=\"caption-attachment-472\" class=\"wp-caption-text\">Converting From Percentage To Pixels<\/figcaption><\/figure>\n<p>Now we can use that\u00a0<strong>Mouth Offset X Pixels<\/strong> value elsewhere in our composition, perhaps to position a <strong>mustache.<\/strong><\/p>\n<h2>Angle Between Two Points<\/h2>\n<p>Sometimes you have <strong>two tracked<\/strong> <strong>points<\/strong> with [x, y] position data, but you need to use them to control a <strong>rotation<\/strong> property.<\/p>\n<p>This<strong>\u00a0<\/strong>expression, placed on any <strong>rotation property,<\/strong> will figure out the correct angle based on the two points you specify.<\/p>\n<pre>point1 = ; \/\/ &lt;-- Pickwhip the 1st point\r\npoint2 = ; \/\/ &lt;-- Same as above for second point\r\n\/\/ The following code uses trigonometry to calculate the angle.\r\ns = sub(point1, point2);\r\nradiansToDegrees( Math.atan2(s[1], s[0]) ) + 180;<\/pre>\n<h2>More Advanced Effects: Paint, Clone, Liquify, Mesh Deform<\/h2>\n<p>Sometimes we need to stabilize the whole face or just a feature in order to apply more complicated effects. The process looks like this:<\/p>\n<ol>\n<li>Stabilize Some Tracked Footage<\/li>\n<li>Sub-Comp The Stabilized Footage<\/li>\n<li>Apply The Effect To The Sub-Comp in an Outer Comp<\/li>\n<li>Sub-Comp The Effects Work<\/li>\n<li>Put the Effects-Work Sub-Comp in a Final Outer Composition<\/li>\n<li>Reverse the stabilization in this final comp (put the facial movement back.)<\/li>\n<\/ol>\n<h3>Stabilize Face Position<\/h3>\n<ul>\n<li>Add a 2D Point Control to store Average Face Position<\/li>\n<li>Average Point expression: <strong>(p1 + p2) \/ 2;<\/strong><\/li>\n<li>Add expression to footage anchor point to link it to the Average Face Position to stabilize position<\/li>\n<\/ul>\n<h3>Stabilize Face Angle<\/h3>\n<ul>\n<li>Angle Control to store Face Vertical Angle<\/li>\n<li>Angle Between Two Points Expression<\/li>\n<li>Add expression to footage rotation property to link it to <strong>negative<\/strong> of the\u00a0Face Vertical Angle (i.e., multiply it by -1)<\/li>\n<\/ul>\n<h3>Reverse The Stabilization In An Outer Comp<\/h3>\n<p>Drag the entire timeline of the sub-comp and the outer comp so that they&#8217;re both visible. Now you can <strong>use the expression pickwhip between comps!<\/strong><\/p>\n<ul>\n<li>Connect the outer comp&#8217;s <strong>position property<\/strong> to the <strong>Face Center<\/strong><\/li>\n<li>Connect the outer comp&#8217;s <strong>rotation property<\/strong> to the <strong>Face Vertical Angle<\/strong><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Face Tracking [ Lecture Notes ] [ Lab ] [ Homework ] &nbsp; Face Tracking is a special type of motion tracking. After Effects tracks various facial features\u00a0and structures, and can also calculate a few &#8220;measurements&#8221; based on the tracking data, such as &#8220;mouth open amount,&#8221; &#8220;eyes closed amount,&#8221; and others. With\u00a0Expression Controls and a &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/ciraldo.stream\/uwm-vfx2\/topics\/face-tracking\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Face Tracking&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":71,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-439","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-json\/wp\/v2\/pages\/439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-json\/wp\/v2\/comments?post=439"}],"version-history":[{"count":16,"href":"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-json\/wp\/v2\/pages\/439\/revisions"}],"predecessor-version":[{"id":484,"href":"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-json\/wp\/v2\/pages\/439\/revisions\/484"}],"up":[{"embeddable":true,"href":"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-json\/wp\/v2\/pages\/71"}],"wp:attachment":[{"href":"https:\/\/ciraldo.stream\/uwm-vfx2\/wp-json\/wp\/v2\/media?parent=439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}