Unit 2 - Notes
Unit 2: Camera Geometry and 2-D Projective Geometry
1. Camera Models and Geometry
1.1 Pinhole Cameras
The pinhole camera is the simplest mathematical model used to describe the geometric mapping from 3D space to a 2D image plane.
- Concept: A light-proof box with a small hole (the center of projection). Light rays from a 3D object pass through this point and project an inverted image onto the image plane (the back of the box).
- Geometry: If the center of projection is at the origin and the image plane is at (where is the focal length), a 3D point projects to a 2D point on the image plane.
- Equations: By similar triangles, the projection equations are:
- Virtual Image Plane: To avoid dealing with inverted images, we often mathematically place a "virtual" image plane in front of the camera center at , ensuring the image is upright.
1.2 Cameras with Lenses
Real cameras use lenses to gather more light than a tiny pinhole allows, reducing exposure time and diffraction.
- Thin Lens Equation: Relates the focal length , the distance to the object , and the distance to the image plane :
- Depth of Field: Because of the lens aperture, only objects at a specific distance are perfectly in focus. The range of distances where the image is acceptably sharp is the depth of field.
- Lens Distortions:
- Radial Distortion: Light rays bend more near the edges of the lens than at the optical center, leading to barrel or pincushion distortion. Corrected using polynomial models (e.g., ).
- Tangential Distortion: Occurs when the lens and image sensor are not perfectly strictly parallel.
1.3 CCD Cameras
Charge-Coupled Device (CCD) cameras digitize the light falling on the image plane.
- Sensor Array: The image plane consists of a rectangular grid of photosensitive elements (pixels).
- Digitization: Involves spatial sampling (pixels) and quantization (analog light intensity to digital pixel value).
- Pixel Coordinates: Real sensors have a physical pixel size (e.g., and mm/pixel). The projection onto a CCD involves translating coordinates from the optical center (principal point, ) to the top-left corner of the image array.
- Color representation: Most CCDs capture color using a Bayer filter mosaic, interpolating raw data to get RGB values for each pixel.
2. Advanced Camera Models
2.1 General Projective Cameras
The general projective camera model describes the full mapping from 3D world coordinates to 2D image pixel coordinates using a projection matrix, .
- Equation: , where is a 3D point in homogeneous coordinates , and is the 2D pixel coordinate .
- Decomposition ():
- Intrinsic Parameters (): A upper triangular matrix describing internal camera geometry.
Where are focal lengths in pixel units, are the coordinates of the principal point, and is the skew coefficient (often zero). - Extrinsic Parameters (): A matrix describing the camera's pose in the 3D world. is a rotation matrix, and is a translation vector.
- Intrinsic Parameters (): A upper triangular matrix describing internal camera geometry.
2.2 Affine Cameras
Affine cameras are a simplification of the projective camera model where the center of projection is assumed to be at infinity. This implies that light rays are parallel (orthographic or parallel projection).
- Mathematical Representation: The last row of the projection matrix is .
- Types of Affine Cameras:
- Orthographic Projection: Drops the Z-coordinate.
- Weak Perspective (Scaled Orthographic): Assumes all points on a 3D object are at roughly the same depth . Magnification is uniform across the object.
- Characteristics: Parallelism is preserved (parallel lines in 3D remain parallel in the 2D image). Perspective effects (farther objects appearing smaller) are ignored.
3. Camera Calibration
Camera calibration is the process of estimating the intrinsic () and extrinsic () parameters of a camera, as well as lens distortion coefficients.
- Purpose: Required for 3D reconstruction, metric measurements from 2D images, and stereo vision.
- Methodology (Zhang's Method): The standard modern technique involves taking multiple images of a known planar pattern (e.g., a checkerboard) from different angles.
- Detect feature points (corners) in the 2D images.
- Establish correspondences between 3D world points (known from the checkerboard geometry) and 2D image points.
- Compute a closed-form solution for the parameters.
- Refine the parameters (including non-linear lens distortion) using optimization techniques like Levenberg-Marquardt to minimize the reprojection error.
- Direct Linear Transform (DLT): A fundamental algorithm used in calibration to solve for the camera matrix given a set of known 3D-2D point correspondences.
4. 2-D Projective Geometry
4.1 Planar Geometry
Planar geometry deals with points and lines on a 2D plane. In standard Euclidean geometry, we encounter issues like parallel lines never intersecting, which requires special case handling. Projective geometry resolves these exceptions.
4.2 Projective Spaces ()
- Projective space extends Euclidean space by adding "points at infinity."
- is the 2D projective plane. In , every pair of distinct lines intersects at exactly one point (parallel lines intersect at a point at infinity).
- is the 3D projective space, used to represent our 3D world in computer vision.
4.3 Representation in Projective Coordinates
Projective geometry relies heavily on homogeneous coordinates.
- Points: A 2D point in Cartesian coordinates is represented as a 3-vector or, more generally, where . To convert back to Cartesian, divide by : .
- Points at Infinity (Ideal Points): Represented as . These indicate direction rather than a finite location.
- Lines: A line is represented by the 3-vector .
- Point-Line Duality: In , points and lines are mathematically interchangeable.
- A point lies on a line if and only if (the dot product is zero).
- Intersection of two lines : The point of intersection is given by the cross product: .
- Line through two points : The line is given by the cross product: .
5. Homography and its Properties
5.1 Definition
A Homography (or projective transformation) is an invertible mapping from a projective plane to a projective plane that maps straight lines to straight lines.
- Mathematical formulation: Given a 2D point in image 1 and its corresponding point in image 2, the homography is a matrix such that:
(Note: This equality is up to a non-zero scale factor, usually written as ). - Degrees of Freedom (DoF): The matrix has 9 entries, but because it is defined up to a scale factor, it has 8 degrees of freedom.
5.2 Properties of Homography
- Collinearity Preserved: Points that lie on a line in the first image will map to points that lie on a line in the second image.
- Cross-Ratio Invariance: The cross-ratio of four collinear points is preserved under projective transformations.
- Composition: The product of two homographies is another homography ().
- Invertibility: Since it is a bijective mapping, the inverse exists and maps back to .
5.3 Estimation
To compute a homography , we need at least 4 point correspondences between two images (none of which are collinear). Each point correspondence provides 2 linear equations. Using the Direct Linear Transform (DLT) algorithm and Singular Value Decomposition (SVD), we can solve for the 8 unknowns.
6. Applications
6.1 Image Stitching (Panoramas)
When multiple images are taken from the exact same camera center but looking in different directions, or if the scene is perfectly planar, the images are related by homographies.
- Process:
- Detect feature points (e.g., SIFT, SURF) in both images.
- Match features to find correspondences.
- Compute the Homography matrix using RANSAC to reject outliers.
- Warp one image into the coordinate frame of the other using .
- Blend the overlapping regions to create a seamless panoramic image.
6.2 Perspective Correction
Also known as document scanning or "keystone correction."
- When a camera captures a rectangular object (like a building facade, a painting, or a document) from an angle, perspective distortion causes it to appear as a trapezoid.
- Process: By selecting the four corners of the distorted trapezoid in the image and defining their desired coordinates as a perfect rectangle, a homography can be computed. Applying this homography to the image warps it, making the object appear as though it were photographed perfectly straight-on.
6.3 Rectification
Rectification is a crucial preprocessing step in stereo computer vision.
- Concept: Given two images of the same scene taken from different positions, searching for corresponding points (to compute depth) usually requires searching across the entire 2D image.
- Epipolar Geometry: Simplifies this search to a 1D line (the epipolar line).
- Rectification Process: Homographies are applied to both images to project them onto a common image plane. This warps the images such that corresponding epipolar lines become perfectly horizontal and collinear. Consequently, to find a matching point in the right image for a pixel in the left image, one only needs to search along the same horizontal row, drastically speeding up depth estimation algorithms.