< Return to Video

https://www.youtube.com/watch?v=InIuTtt7W3E&ab_channel=CGMatterhttps://www.youtube.com/watch?v=InIuTtt7W3E&ab_channel=CGMatter

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

more » « less
Video Language:
English (United States)
Duration:
10:59

English (United States) subtitles

Revisions