Camera Matrix in Computer Vision


Camera Matrix in Computer Vision

Maria
Hey Anna, I was watching this video about the camera matrix in computer vision. It's such a core concept, but the way they break it down is really helpful.

Anna
Oh, absolutely! I've always struggled with how a 3D world point ends up on a 2D image. Does it start with something simple like the pinhole camera model?

Maria
Exactly. Real cameras are complicated with lenses and apertures, so they use the pinhole model as a simplification. It's just a point aperture, so each point on the sensor gets light from only one direction. Keeps things simple and reasonably accurate.

Anna
So the pinhole model avoids blurriness from a larger aperture, but real cameras use lenses to reduce that blur. And lenses introduce errors like radial distortion, but those can be corrected later, right?

Maria
Yes, exactly. Tangential distortion is usually small enough to ignore with good cameras. So the pinhole model is a great starting point. Now, they set up a coordinate system where the camera looks along the positive z-axis, and the image plane is aligned with x and y.

Anna
I remember that from graphics too, though sometimes the camera looks down negative z. But I guess it's just a sign convention. So the aperture is at the origin, and the image plane is at focal length F behind it?

Maria
Right. The focal length is the distance between aperture and image plane. And with similar triangles, you get the basic relationship: -U over -F equals X over Z. That's the foundation for the intrinsic matrix.

Anna
And they talk about how changing the focal length changes the image, but if you also change the sensor size proportionally, you get the same image. So it's the ratio that matters, not absolute values.

Maria
Exactly! So you can introduce a scaling factor k to convert from millimeters to pixels. Typically, k is pixels per millimeter, so you get the focal length in pixels. And then you can incorporate an offset if the sensor isn't perfectly centered.

Anna
Yeah, that offset is u0 and v0 in pixels. And they write the equations in matrix form, which looks like the intrinsic matrix but missing a row and a shear term.

Maria
The shear term is for non-rectangular sensors, but for an ideal pinhole camera it's not present. And the missing third row comes from using homogeneous coordinates.

Anna
Ah, homogeneous coordinates! They add an extra dimension to handle points at infinity and to combine rotation and translation into one matrix multiplication.

Maria
Right. In Euclidean coordinates, you do rotation and translation separately. But with homogeneous coordinates, you can put both in a 4x4 matrix. And the intrinsic matrix becomes 3x4, with the bottom row being [0, 0, 1, 0]? Wait, let me think.

Anna
Actually, the intrinsic matrix is 3x3 in homogeneous form. They had the equation with the tilde, meaning equivalence up to scale. So it's [f_x, 0, u0; 0, f_y, v0; 0, 0, 1] times the 3D point in camera coordinates.

Maria
Yes, that's it. But that's just the intrinsic part. To go from world coordinates to camera coordinates, you need the extrinsic matrix. That's the rotation and translation that transforms world points into the camera's coordinate system.

Anna
And they explained that if you know the camera's position and orientation in world coordinates, you build a camera-to-world matrix. Then the world-to-camera matrix is just its inverse.

Maria
Precisely. The inverse is easy to compute for these rigid transformations: transpose the rotation and negate the translation. So the extrinsic matrix takes world points to camera points, and then the intrinsic matrix projects them onto the image.

Anna
And combining them gives the full camera matrix, which maps from 3D world homogeneous coordinates directly to 2D image homogeneous coordinates. That's the final form they showed.

Maria
Right. The camera matrix includes both intrinsic and extrinsic parameters. And in practice, you'd calibrate it to find these parameters for a specific camera-lens combination. That's for another video, I guess.

Anna
This was a really clear explanation. Starting from the simple pinhole, adding pixels, offsets, and then the extrinsic transformations. It all makes sense now.

Maria
I agree. And the important takeaway is that the camera matrix is fundamental for mapping 3D scenes to 2D images. It's used in everything from 3D reconstruction to augmented reality.

Anna
Absolutely. Next time I see a camera matrix, I'll think of the pinhole model and similar triangles. Thanks for walking through it with me!

Ask anything
We've read this whole study set, so questions about it get the best answers.