Tutorial: Camera Solving for Moving Objects

May 16, 2012
tags: Mocha, Blog


We’ve had a few requests to make companion written tutorials alongside our video tutorials.  
So for those who prefer reading step-by-step instructions, rather than examples where you have to hit pause all the time, this is for you.
When doing camera solves in mocha v3, the most common workflow is to track planar areas in your shot that are not moving, so you can define how the camera is moving relative to the non-moving objects in the shot.
This is fine for when you need to insert non-moving or animated objects that are relative to your camera, but sometimes you are looking to replace objects that are moving in the shot, or attach things to them.
Mocha handles this process by still solving the camera how you normally would with static areas, but then you can track any moving planes and export those planes based on your camera solve.  
In the surfing shot below we want to add a particle stream to the surf board.  We need to track the non-moving background first and then get 3D surface data for the surfboard itself.

The footage we are using is courtesy of Rubberball footage supplied by artbeats.com.
You can grab a small sample from this footage to follow along here.

Let’s take a look at how this is achieved.

The Process

First of all you want to track your static (non-moving) objects to define a camera.  You will need to define more than one plane for moving (xyz) cameras, and at least 1 plane for cameras that are fixed, but can Pan, Tilt and Zoom (PTZ).

To reiterate, “static” in this sense does not mean a locked-off shot with no motion.  Static means anything in the shot that is not moving, such as a floor or wall.  To solve for a camera we need to determine how that camera is moving relative to stationary objects in the shot.

Where possible, it is good to get as much information as you can (without overdoing it).
In this shot, we are using 2 portions of the sky using the Add Spline to Layer tool to create a second shape in the layer.
001 – Draw shapes in static planar areas
Before we track we also need to animate the shape to avoid the movement of the man and the surfboard.  This is necessary because we are going to do an unlinked track.  We could also just mask out the man and the surfboard by drawing layers over the sky-tracking layer, but animating the shape is faster in this instance.
002 – Adjust shapes to avoid foreground motion
So we can have the splines in the layer not moving while we track, we can set our Link to Track option to None.  This means that as the footage plays back, anything passing underneath our spline “Search Areas” will be tracked, without having to move the spline as well.

This is very useful when we have long pans and don’t want to keep animating the shapes back on screen.

003 – Choose “None” from Link to Track so that the splines don’t move.
We can then set our parameters and start tracking the sky.  I have gone with:
  • Motion: Check Translation, Scale and Rotation
  • Min % Pixels Used: 90% (The higher the number the more accurate the track, but the slower the tracking)
  • Input Channel: Auto Channel 
004 – Tracking Parameters
I always recommend having the grid on while you track so you can see if the track is drifting, but for tracks like this you can also turn on the Stabilize viewer in the view controls so that the area you are tracking stays still.

005 – Stabilize view (Not the same as the stabilize module)
Once you have finished tracking the static areas of the scene and you have determined you have a good track, you can then move to solving the shot.
In this case I know it is a Pan, Tilt, Zoom (PTZ) shot, so I have chosen that option, along with zooming checked to cover some of the subtle zoom in the shot.

006 – Solving for PTZ with Zooming turned on

Once we have solved the camera, we can export it out for the scene, but if we want to get the surfboard, we need to track that first.
We do this by drawing a shape around some texture detail on the surfboard.

007- Drawing shapes on the surfboard

We also draw a new shape in the layer with the Add Spline to Layer tool to cover the front area of the surfboard so we have as much detail as possible.  Again, we could just draw one shape and then mask out the arm, but you can do it either way.

008 – Adding another shape to the surfboard layer

Just so we can see how the track is going, you can then move the corners the surface to line up with the general position of the surfboard.  This is a useful visual aid when tracking.

009 – Setting up the surface so the grid lines up with the surfboard

We can then set up the parameters for the track.  This is a Perspective track, so we want to make sure that is turned on:

  • Motion: Check Translation, Scale, Rotation, Shear and Perspective
  • Min % Pixels Used: 90% (The higher the number the more accurate the track, but the slower the tracking)
  • Input Channel: Auto Channel 

010 – Surfboard tracking parameters

You can then start tracking!

Once it is tracked you can immediately switch back to the camera solver module.
The great thing is once you have solved the static camera from the first step, you don’t need to resolve to export data for moving objects.  That all happens when you actually export.

In this case we are exporting out to After Effects.  If you want to use a different application you can export out to FBX if you have mocha Pro.

011 – Exporting to After Effects

Over in After Effects you need to go to the Edit menu and choose Paste mocha camera.  This option will only appear if you have installed the mocha 3D track importer for AE plugin from our website.  The plugin is free when you buy mocha AE V3 or mocha Pro V3 and it available here:

012 – Paste mocha camera option in the Edit menu in After Effects

 Once pasted, you will get a camera and 5 nulls; 1 null for each corner of your surface and a central null.  If the nulls are too large you can easily scale them down by just selecting them all and changing a single value in one of the nulls.

013 – The resulting nulls in After Effects
The great thing about being able to track surfaces like this is that you can adjust the surface relative to the same plane, and get different positions on your plane.  In this case, we want to centre our surface nulls around the tip of the surfboard, so we can shift the surface inside mocha accordingly.
014 – Moving the surface to a different area on the surfboard
Then when we export the 3d data again and paste back into After Effects, we get the nulls in the same position.
015 – The new nulls in the place where we want them

Trapcode Particular

The rest of this tutorial is related to linking a Trapcode Particular emitter up to the central mocha null, so if you just wanted to know how to track the moving objects you’re done!  
Carry on for seeing how I use Red Giant‘s great particle tool to make a trail linked to the 3d data.

First of all we want to add a new solid.  Either press CMD/Ctrl+Y to bring up the solid window or go to the menu and choose Layer | New > Solid.
Make sure the new solid is the same size as the composition and hit OK.

016 – New solid!  It’s like a meme, only for After Effects.

Then we want to apply the Trapcode Particular effect from the menu at Effect | Trapcode > Particular.  You could also choose another default particle system if you like, and similar processes would apply, but Particular has a lot of great controls.

You can choose to leave velocity on, but since the surfboard is moving, you can get a nice trail effect if you set velocity to zero.  Everything else can be left at default values until you want to tweak them.  See the settings below.

017 – Set velocity to zero

Now comes the mildly tricky part.  You can watch the video  if you need further clarification:

  1. Go to your layer panel and select mocha null 4 in your layers (or which ever null you want to drive your motion) and press P to show its position information
  2. Select your solid and navigate to the individual properties of the Particular effect applied to it
  3. Locate Position XY under the Emitter section of the Particular effect
  4. Alt-Click the Position XY stopwatch to open the expressions area
  5. Using the pick whip (See image below) drag from the Position XY in Particular to the Position value of your target mocha null.
018 – Pick whip dragging from Position XY to mocha null position

This will generate an expression in the Position XY value of the emitter.  It will look similar to this:

temp = thisComp.layer(“mocha null 4″).transform.position;
[temp[0], temp[1]]
This is just telling After Effects to assign the X, Y and Z values of the mocha null position to the value temp and then only use the first two values of it (X = temp[0] Y = temp[1]).
 Copy this expression for the next step using CMD/CTRL+C.

019 – Copy the expression create by pick whip

Next, alt-click the Position Z value in the Emitter section of Particular, and paste the expression you copied into the available expression field.

Rather than keeping the original expression however, remove this line:
[temp[0], temp[1]]

And replace it with this:

This expression does exactly the same thing as the previous expression, only this time it is only grabbing the Z value from the null position. There are other ways to code this, but this suits the purpose fine.

020 – Modifying Position Z expression to only get Z value from the mocha null

 If everything has worked correctly you should get a lovely trail of particles from the emitter, following along exactly in 3d space, driven by your tracked null from mocha.

021 – Whee!

Please check out the video at the start of the tutorial to see the complete run-through, and if you have any questions, feel free to ask in the comments, or on the forum at: forum.imagineersystems.com.


Join our email newsletter and keep up to date