Matching Maya camera with a real world camera

As part of a lighting assignment, I worked on with a small team to combine CG elements with a real life picture. The goal here was to go through the whole lighting pipeline. This involved: outside to take environment pictures, matching the virtual camera with the real one, setting up the correct render passes and composite this all in nuke. Since the camera matching was quite tricky I will go through the process of setting this up in this blog post.

When creating a scenes with a combination of photos and CG elements it is likely that you need to do some camera matching to get some convincing results. To do this correctly it is important to know the following variables.

What camera did you use?
What is your cameras crop factor (also known as: focal length multiplier) ?
The focal length you used to take your picture?
What is the horizon line in my picture?



Now in our 3d scene we need to create a new camera with the right focal length. Since our virtual camera uses the standard 35mm film camera lens, we probably need to do a calculation. In my case I used the PowerShot SX50 HS, which has the following specifications:

Sensor size = (6.17 x 4.55 mm)
Crop factor = 43.27 mm / sensor diagonal in mm
Crop factor = 43.27 / 7.70 = 5.62
Focal length camera for this photo= 17mm

With this information we can calculate the focal length for our virtual camera, we do this by multiplying the focal length (of this particular photo) with our crop factor.

17 * 5.62 = 95.54mm

So the correct focal length in Maya is 95.54mm. To calculate the aspect ratio divide your width with your height, in our case this results in 1.3333333

Now it is possible to correctly set up the CG camera. Enable film gate, enter the focal length, and aspect ratio. The last step is matching the image horizon with the horizon of your scene. After doing this you are ready to implement convincing CG elements to your scene.