-
>> Hey guys, welcome back to
another Blender 2.8 tutorial.
-
And today I'm going to be showing you
how to do 3D camera tracking all inside
-
of Blender without any add-ons necessary.
-
Now because 3D camera tracking is such a big
and broad topic, and there's a lot of techniques
-
in 3D camera tracking, I'm going to take
this tutorial and split it up into two parts.
-
So, in this first part we're going to be
dealing with footage that has tracking markers,
-
which makes it much easier to track.
-
And remember, our goal is to make
a camera object inside Blender
-
that matches the motion of the shot.
-
So, we want the camera to move in the same
way, and also have the same perspective.
-
And by doing a bunch of point tracks on our
footage, Blender can solve for our camera.
-
So, obviously in this shot,
we're going to choose
-
to track the markers on our sheet of paper.
-
In a harder shot, we're going to need to get
more creative with what we pick to track.
-
But in this case, we just have it really easy.
-
So, the first step is converting
this video into an image sequence.
-
And this step isn't entirely necessary, but
an image sequence doesn't have a frame rate
-
which ultimately gives us a lot more control.
-
So, when you can, it's always
best to work with image sequences.
-
But again, you don't have
to if you don't want to.
-
So, all we have to do is go into the movie clip
editor and then just import in our footage.
-
And now that it's imported, you see on the
right panel which you can click N to toggle,
-
you see a whole bunch of information
like the resolution, the frame rate,
-
and also the duration which is in frames.
-
And we want the settings in our
Blender project to reflect these.
-
For the video duration there's
two ways to do this.
-
We can either change it manually here to 139,
-
or we can click this button called set scene
frames, which does it for us automatically.
-
And now these both have the same frame duration.
-
Next, we need to match the frame rates.
-
And to do this, go to the output tab and
then look for the frame rate options.
-
Now in our case, we have a very
weird frame rate, which is 29.87,
-
and you see that's not an option here.
-
So, we're going to have to use custom.
-
And we can't just type in 29.87 because in
this case, it's just going to round up to 30.
-
Instead what we're going to do
is scale both of these by 100.
-
So, we have 2,987 over 100.
-
And you can think of this as division,
which gives us our correct custom framerate.
-
And also, we have the correct
resolution of 1080p by default.
-
Now we just go into compositing
and start setting up some nodes.
-
So, make sure that you have
nodes and auto render enabled,
-
so you can see what you're doing.
-
And we're going to take this render
layers node and delete it with X,
-
because we don't need it for this.
-
To bring in our footage, just click shift A to
add, and then go to input and then movie clip.
-
And this gives us our node.
-
And make sure that this is set to the
correct footage that we imported before.
-
And now, all we have to do is hook these two up.
-
And if we want to see what we're doing, we're
just going to also add in a viewer node,
-
and then just hook it up as well.
-
Now that we're done with the setup,
we're just going to go to the output tab,
-
and then set this export to jpeg.
-
And this isn't really the
highest quality format,
-
but it doesn't really matter for this tutorial.
-
And then we're just going to create
a new folder and set an output path.
-
And while we're still in EV, we can just
hit control F12 to render out our animation.
-
Now that we've converted into an image
sequence, we can start up a new Blender project.
-
Again, we're going to go
to the movie clip editor.
-
But this time we're going to
import in our image sequence.
-
And to import in an image sequence, just select
all your frames with A and then import them.
-
And remember that an image
sequence doesn't have a frame rate,
-
so we can just go to the output tab
and freely choose our frame rate.
-
So, I'm going to choose 30 frames per second.
-
And for the project duration, we're just
going to hit set scene frames again.
-
And that's going to automatically
take care of it for us.
-
Now notice that when we scrub through the
timeline, the footage is a bit choppy.
-
And to fix this, what you
have to do is click pre-fetch,
-
which loads this whole sequence into memory.
-
And now this is playing much more smoothly.
-
Remember that we get our camera solved
by just having a bunch of point tracks.
-
For the Blender camera solver, we
need to make sure that there's always
-
at least 8 trackers visible
during any frame in the shot.
-
So, the name of the game is getting as
many high quality trackers as possible.
-
We want trackers that last for a long
time and have a very low average error.
-
And to help us with this, we want to make sure
-
that we're using the best
settings for our trackers.
-
The first thing we need to
pick is a motion type.
-
And there's a lot of options.
-
Like location, for example, which tracks
the location of a pattern between frames.
-
But in this case, it probably makes
the most sense to use perspective.
-
Because our markers are kind of getting
perspective warped as the camera is moving.
-
We can also enable normalize, which is going to
help Blender ignore some subtle lighting changes
-
that might have thrown off our track otherwise.
-
This does take some more time to
compute, but generally it is worth it.
-
Lastly, in the tracking settings extra, we're
going to pick a correlation value of 0.9.
-
This number is basically just a
threshold that the tracker needs
-
to meet during every frame, so it doesn't stop.
-
So, when this value is zero, it's just going
to ignore any error and just keep tracking.
-
And instead, if this number is 1, it needs
to be 100% confident during every frame
-
that it's correct, or otherwise
it's immediately going to terminate.
-
So, 0.9 is a very high value which
demands a very high accuracy,
-
but it does give us a little bit of wiggle
room, so it's not stopping constantly.
-
And now we can begin adding in
trackers with control click.
-
And in the tracking panel, we get
a zoomed in window of our tracker,
-
which lets us make fine adjustments
and center it.
-
We can also scale up this tracker with S, so
our whole feature is inside the bounding box.
-
Now, there's also a second hidden
bounding box, which we can show with alt S,
-
and this is called the search box.
-
The search box just defines where we're going
to search for our pattern between each frame.
-
So, a larger search box means it's
going to search a larger area,
-
but that's also more computationally expensive.
-
For this shot, the camera isn't
moving around very quickly,
-
so we can keep this search box rather small.
-
Once we're happy with everything,
we can begin tracking manually
-
by hitting alt and then right arrow.
-
This is how we track frame by frame, and
you see that it's sticking on very well.
-
To center this tracker to the view, you can just
hit L and that's going to lock it to the center.
-
And after doing a few more frames manually, we
can have it go through the rest of the footage
-
by just hitting control T, and
it tracks all the way to the end.
-
And of course, we can also check how
good this tracker is throughout the shot.
-
Once we're happy with this tracker, we can just
lock it by hitting control L. And this means
-
that we're done with the tracker and
we can't accidentally move it and mess
-
with the key frames or anything like that.
-
So, now we go back to the first
frame with shift, left arrow,
-
and we have to do the rest of the trackers.
-
Now, this isn't going to take as long
because we can do all of them at once.
-
So, I'm just going to pick a couple trackers.
-
We don't need to do every single feature.
-
Let's do something like 10.
-
When you set up all your trackers, you
can just select all of them with A.
-
And then we're just going to hit control
T, and they're going to track all together.
-
Then we can just hit control
L to lock all of them.
-
And now it's finally time
to work on our camera solve.
-
So, just go over to the solve panel, and
you see a whole bunch of options here,
-
so we're just going to take them one at a time.
-
For the tripod option, we're
going to keep this disabled
-
because this shot has a free moving camera.
-
It's not locked to a tripod,
and it's not a nodal pan.
-
Now, for key frame and key frame A and B
options, what this basically lets us do is
-
when we do our camera solve, we pick some
range that we deem to be very accurate,
-
and then it's just going to extrapolate that.
-
So, key frame A and B is
basically defining this range.
-
Now in this case, we don't really know what we
should pick for key frame A and key frame B,
-
so we're just going to let Blender decide
by enabling this key frame check box.
-
And now we can click solve camera motion and
Blender is going to solve for our camera.
-
And we get some number, which
is our solve error.
-
Which generally, we want to
make as small as possible.
-
A solve error under 1 is somewhat
okay, but if we can get it
-
under 0.5, then that's pretty good.
-
Basically, we want to get this
value as close to zero as possible.
-
And as a result, our solve is
going to become better and better.
-
The first thing we can do to lower our solve
error, is go over to the refine options.
-
And you see that we have
a whole bunch of choices.
-
We are going to choose the focal length,
and K1 and K2 option, so that Blender tries
-
to calculate what the focal
length was in the shot.
-
That's essentially how zoomed in we were.
-
And also, the lens distortion,
which are these K1 and K2 numbers.
-
And then we can just click
solve camera motion again.
-
Another trick for lowering our solve error, is
to go into clip display and then enable info.
-
And this is going to give us
information about the error
-
of each individual tracker that we had.
-
Obviously, what we want to
do is find the tracker
-
with the highest error, and then just delete it.
-
We then click solve camera motion again
and we should have a lower solve error.
-
So, let's say that we're happy with this now,
and we want to incorporate it into our 3D scene.
-
All we have to do is click setup tracking scene.
-
And already this is looking very wrong.
-
But that's because we just didn't
set up our world orientation.
-
The first thing we do is select three trackers
on this table, and set this to be our floor.
-
We can also pick one of these trackers in
particular, and set this to be the world origin.
-
So, everything is going to
be centered from this point.
-
We can then pick any two trackers and
choose a distance, and then pick set scale
-
so that the distance between these two points
is defined to be however many units we put in.
-
Lastly, to set up the X and Y
axis, with respect to the origin,
-
all we have to do is select a tracker to the
left of the origin, and then click set X axis,
-
and then we pick a new tracker below
the origin and click set Y axis.
-
And now you see our camera solve
is behaving how we expected.
-
We can see our results by going
into the rendered view in cycles.
-
The plane becomes transparent, because
it's set to be a shadow catcher.
-
However, there are no shadows.
-
To fix this, all we have
to do is select our plane
-
and bring it into the foreground collection.
-
We can also go to the background
layer that was set
-
up when we did our camera
solve, and we can delete it.
-
And now you see that everything
is working out as we expect.
-
We're now going to go into compositing
and set up our nodes before we render.
-
And you see, we already have this whole network.
-
That again, is set up by default when
you selected set up tracking scene.
-
I'm just going to delete this with X, and
show you how to make a custom node setup.
-
We're going to click shift data add.
-
And then we need our movie
clip for the background,
-
and then our render layers for the foreground.
-
And we can then overlay these two,
just using an alpha over node.
-
And then finally, we're just
going to add a composite node,
-
and also a viewer node so
we can see what we're doing.
-
And so far, you see that we have the
background but not our 3D objects.
-
And that's because we didn't
render anything yet.
-
So, I'm just going to go to the first
frame, and then hit F12 to render.
-
And then you see that our
render layers node updates,
-
and then everything works out as it should.
-
Finally, in the output tab I'm going to
set this to render as a jpeg sequence,
-
which we can save in a new folder.
-
And now, all we have to do is hit
control F12 to render out the animation.
-
And that is the basics of 3D
camera tracking in Blender 2.8.
-
So, in the next video I'm going to be
going over much more difficult footage.
-
But also, we're going to get much more in
depth about how the 3D camera tracker works.
-
So, thank you guys for watching and
I'll see you guys in the next one.