While the previous chapter surveyed various sensor types used in robotics, vision sensors warrant special attention due to their unique ability to capture rich, high-dimensional information about the environment. A single camera image can contain information about object identity, pose, color, texture, and spatial relationships—information that would require multiple specialized sensors to obtain otherwise. However, extracting useful information from camera images requires understanding how three-dimensional scenes are projected onto two-dimensional image planes, and how we can calibrate cameras to enable accurate measurements.
This chapter explores the mathematical foundations of camera models, from the basic pinhole model to modern RGB-D sensors, and presents practical methods for camera calibration that enable quantitative vision-based perception. In Section 6.1 we introduce the principles of image formation and the mathematical models that describe how cameras capture images. Next, in Section 6.2, we derive the perspective projection equations and discuss practical considerations such as lens distortion. Then, we will discuss an increasingly popular type of camera, RGB-D cameras, in Section 6.3, which provide both color and depth information. Finally, in Section 6.4 and Section 6.5, we derive the mathematical model for perspective projection and present methods for camera calibration, which is essential for using these models in practice.
6.1 Digital Cameras and Image Formation
Modern cameras consist of a sensor that captures light and converts the resulting signal into a digital image. Light falling on an imaging sensor is usually picked up by an active sensing area, integrated for the duration of the exposure††margin: The duration of exposure is usually expressed as the shutter speed, such as , , or of a second. , and then passed to a set of sense amplifiers.
6.1.1 Image Sensors
The two main kinds of sensors used in digital cameras today are charge-coupled devices (CCD) and complementary metal-oxide-semiconductor (CMOS) sensors. A CCD chip is an array of light-sensitive picture elements called pixels, and can contain between 20,000 and several million pixels total. We can think of each pixel as a light-sensitive discharging capacitor that is to in size. While complementary metal oxide semiconductor (CMOS) chips also consist of an array of pixels, they are quite different from CCD chips. In particular, along the side of each pixel are several transistors specific to that pixel. CCD sensors have typically outperformed CMOS for quality-sensitive applications such as digital single-lens-reflex cameras, while CMOS sensors are better for low-power applications. However, today, CMOS sensors are standard in most digital cameras.
6.1.2 Image Formation
Rays of light reflected by an object tend to be scattered in many directions and may consist of different wavelengths. Averaged over time, the emitted wavelengths and directions for a specific object can be precisely described using object-specific probability distribution functions. In particular, the light reflection properties of a given object are the result of how light is reflected, scattered, or absorbed based on the object’s surface properties and the wavelength of the light. For example, an object might look blue because blue wavelengths of light are primarily scattered off the surface while other wavelengths are absorbed.
Cameras capture images by sensing reflected light rays on a photoreceptive surface such as a CCD or a CMOS sensor. Since light reflecting off an object is generally scattered in many directions, exposing a planar photoreceptive surface to these reflected rays would result in many rays being captured at each pixel, which would lead to blurry images. A solution to this issue is to add a barrier in front of the photoreceptive surface that only lets some of the rays pass through an aperture, as we show in Figure 6.1. The earliest approach to filtering light rays in this way was to have a small hole in the barrier surface. We refer to cameras with this type of filter as pinhole cameras.
6.2 Camera Models
6.2.1 Pinhole Camera Model
A pinhole camera has no lens but rather a single small aperture. Light from the scene passes through this pinhole aperture and projects an inverted image onto the image plane, as we show in Figure 6.2. While modern cameras do not operate in this way, we can use the principles of the pinhole camera to derive useful mathematical models.
We start by defining several useful references to help develop the mathematical pinhole camera model. First, the camera reference frame is centered at a point, , that is at a focal length, , in front of the image plane, as we show in Figure 6.2. We define this reference frame, with directions , such that the axis is coincident with the optical axis that points toward the image plane. We denote the coordinates of a point in the camera frame by . When a ray of light is emitted from a point, , and passes through the pinhole at point , it gets captured on the image plane at a point . Since these points are all collinear, we can deduce the following relationships between the coordinates and :
for some . This leads to the relationship:
From the geometry of the camera, we can see that where is the focal length, such that we can rewrite these expressions as:
| (6.1) |
Therefore, we can compute the position of the pixel on the image plane that captures a ray of light from the point .
6.2.2 Thin Lens Model
One of the main issues with having a fixed pinhole aperture is that there is a trade-off associated with the aperture’s size. A large aperture allows a greater number of light rays to pass through, which leads to image blurring. A small aperture lets through fewer light rays, but the resulting image is darker. As a solution, lenses focus light by refraction and can be used to replace the aperture, avoiding the need for these trade-offs.
We can develop a mathematical model for lenses similar to the pinhole model by using properties from Snell’s law. Figure 6.3 shows a diagram of the most basic lens model, which is the thin lens model††margin: The thin lens model assumes no optical distortion due to the curvature of the lens. . Snell’s law states that rays passing through the center of the lens are not refracted, and those that are parallel to the optical axis are focused on the focal point, labeled . In addition, all rays passing through are focused by the thin lens on the point . We develop a mathematical model similar to Equation 6.1 from the geometry of similar triangles:
| (6.2) |
where again the point has coordinates , its corresponding point, , on the image plane has coordinates , and is the focal length. Combining these two equations yields the thin lens equation:
| (6.3) |
Note that in this model, and for a particular focal length, , a point, , is only in sharp focus if the image plane is located a distance from the lens. In practice, an acceptable focus is possible within some range of distances referred to as depth of field or depth of focus. Additionally, if approaches infinity, light would focus a distance of away from the lens. Therefore, this model is essentially the same as a pinhole model if the lens is focused at a distance of infinity.
6.2.3 Radial Distortion
The pinhole camera model provides a nominal camera model for which it is relatively straightforward to develop a mathematical model of the perspective projection. However, in practice, this model is not a perfect representation of the imaging process. One effect that is not captured by the pinhole model is radial distortion, which is an effect seen in real lenses where either barrel distortion or pincushion distortion will affect the real pixel coordinates. We show images of barrel and pincushion distortion in Figure 6.4.
There are methods we can use to correct for image distortion. A simple and efficient way is to model the relationship between the ideal pixel coordinates, , and the distorted pixel coordinates, , as:
| (6.4) |
where is the radial distortion factor, are the pixel coordinates of the image center, and is the square of the distance between the ideal pixel location and the center of distortion. Note that differs across cameras and needs to be predetermined through calibration.
6.3 RGB-D Cameras
While traditional cameras capture color information through RGB channels, RGB-D cameras additionally provide depth information for each pixel, creating a 2.5D representation of the scene. These sensors have become increasingly important in robotics due to their ability to provide both appearance and geometric information in a single, compact package.
6.3.1 Depth Sensing Technologies
RGB-D cameras employ various technologies to capture depth information alongside color:
Structured light.
These sensors project a known infrared pattern onto the scene and use triangulation to compute depth from the pattern’s deformation. The original Microsoft Kinect exemplifies this approach, projecting a speckle pattern that is captured by an IR camera offset from the projector. Structured light sensors provide high accuracy at close range (0.5 to 4 m) but struggle in bright ambient light conditions.
Time-of-flight (ToF).
ToF cameras emit modulated infrared light and measure the phase shift of the reflected signal to determine distance. These sensors offer good accuracy across their operating range and work well in varying lighting conditions, though they typically have lower resolution than structured light sensors and can suffer from multipath interference.
Stereo infrared.
Some RGB-D cameras, such as the Intel RealSense D-series, use stereo vision with infrared cameras and an optional IR pattern projector. This approach combines the robustness of stereo vision with active illumination to handle textureless surfaces.
6.3.2 Applications in Robotics and Practical Considerations
RGB-D cameras have enabled significant advances in several robotics applications, particularly in structured indoor environments. For indoor navigation and mapping, RGB-D sensors are ideal when GPS is unavailable and lighting can be controlled. They provide dense 3D point clouds at frame rate, enabling real-time obstacle avoidance and map building, with popular SLAM systems like RGB-D SLAM and ElasticFusion leveraging these sensors for creating detailed 3D maps. In object manipulation tasks, RGB-D cameras excel by providing both the object’s appearance and its precise 3D geometry, allowing robots to identify objects using color and texture while planning grasps based on accurate depth information. The relatively high accuracy at close range (typically 0.5 to 4 m) makes them well-suited for tabletop manipulation and pick-and-place operations.
However, several practical considerations limit their use. Most consumer RGB-D sensors operate effectively only between 0.5 and 5 meters, with accuracy degrading quadratically with distance—millimeter accuracy at one meter may degrade to several centimeters at maximum range. Material properties significantly affect performance: transparent and highly reflective surfaces cannot be measured, while dark materials may return weak signals leading to missing depth values. RGB-D cameras also require careful calibration between the color and depth sensors, which are typically offset from each other, and factory calibration may not suffice for high-precision applications. Additionally, multiple RGB-D cameras can interfere with each other’s IR projectors, and ambient infrared light (such as sunlight) makes outdoor use challenging. Despite these limitations, RGB-D cameras offer an attractive balance of cost, size, and capability for many indoor robotics applications, providing rich 3D perception without the computational complexity of stereo matching or the cost of laser scanners.
6.4 Perspective Projection and Coordinate Transformations
The pinhole camera model can be used to mathematically define relationships between points in the scene and points on the image plane. Our objective is to derive a mathematical model that maps a point expressed in world frame coordinates to a point on the image plane in pixel coordinates. We accomplish this by combining two transformations: from world frame to camera frame coordinates (), and from camera coordinates to image coordinates ().
6.4.1 Camera Frame to Image Coordinates ()
The first step we consider is how to map a point in the scene expressed in camera frame coordinates, , to the corresponding point on the image plane, , using the pinhole camera model. In the referenced item, we presented the pinhole camera equations:
| (6.5) |
where , , and is the focal length of the pinhole camera††margin: We generally do not include the term of simply because is a fixed value. .
Note that the quantities and are coordinates in the camera frame, but it is often desirable to express the point in terms of pixel coordinates. Pixel coordinates are generally defined with respect to a reference frame in the lower corner of the image plane to avoid negative coordinates. We show this new reference frame in Figure 6.5, where we define the image center, , with coordinates , where is the notation we use to denote a coordinate with respect to this new reference frame.
In this new reference frame, we map the point to the coordinates by:
| (6.6) |
Finally, given the number of pixels per unit distance, we can map these new coordinates to pixel coordinates. In particular, we map the point to pixel coordinates by:
| (6.7) |
where , , , , and and are the number of pixels per unit distance in image coordinates.
Note that the transformation from the point in camera frame coordinates to in pixel coordinates given by Equation 6.7 is not linear. However, we can represent this transformation as a linear mapping††margin: Expressing the perspective projection as a linear map will simplify the mathematics later on. through an additional change of coordinates. In particular, we will express the points and in homogeneous coordinates.
For a two-dimensional point or a three-dimensional point in Euclidean space, we represent the point in homogeneous coordinates by the transformation:
| (6.8) |
for any . These new coordinates are called homogeneous coordinates because we can choose the scaling factor, , arbitrarily as long as . We transform a set of homogeneous coordinates back by:
| (6.9) |
We will denote when a point is described in homogeneous coordinates using the superscript . For example, we express the point in camera frame coordinates with in homogeneous coordinates by:
and we can express the pixel coordinate in homogeneous coordinates by:
by choosing and substituting the expressions from Equation 6.7. With the expression of these points in homogeneous coordinates, we can see that their relationship is transformed from the nonlinear relationship in Equation 6.7 to the linear relationship:
| (6.10) |
Often, in practice, we also add a skewness parameter, ††margin: The skewness parameter generally ends up being close to zero. , and we can write this linear relationship in the more compact form:
| (6.11) |
We refer the matrix in Equation 6.11 as the camera matrix or matrix of intrinsic parameters because it contains the five parameters that define the fundamental characteristics of the camera from the perspective of the pinhole camera model. While these parameters may be specified by the camera manufacturer, we often estimate them in practice by performing a camera calibration.
6.4.2 World Frame to Camera Frame ()
We can express a point, , in the scene (see Figure 6.2) either in terms of camera frame coordinates, , or world frame coordinates, . While we discussed the use of the pinhole model to map coordinates to pixel coordinates, , in the previous section, in this section we discuss the mapping between the camera and world frame coordinates of the point , as we show in Figure 6.6.
From Figure 6.6, we can write as:
| (6.12) |
where is the vector from to , expressed in camera frame coordinates, and is the vector from to , expressed in camera frame coordinates. However, the vector is the same vector as , just expressed with respect to a different coordinate frame. The coordinates are related by a rotation:
| (6.13) |
where is the rotation matrix relating the camera frame to world frame defined as:
| (6.14) |
where , , and are the unit vectors that define the camera frame and , , and are the unit vectors that define the world frame. To summarize, we can map the point to camera frame coordinates by:
| (6.15) |
where is the vector in camera frame coordinates from to and is the rotation matrix defined in Equation 6.14. Similar to the previous section, we can equivalently express this transformation for the case where the points and are expressed in homogeneous coordinates:
| (6.16) |
6.4.3 Complete Projection Pipeline ()
The objective of the perspective projection task is to find a way to mathematically relate the position of a point in world frame coordinates, denoted , to the corresponding pixel coordinates, , on the image plane. With the relationship from Equation 6.16 that we developed for mapping to the camera frame coordinates, , and the relationship in Equation 6.11 for mapping to pixel coordinates, , we can now define the direct mapping from to . In particular, combining the two transformations together yields:
which we can simplify to:
| (6.17) |
In Equation 6.17, is the homogeneous coordinate representation of and is the homogeneous coordinate representation of . Recall that the matrix is the matrix of intrinsic camera parameters, and the matrix contains extrinsic parameters††margin: Extrinsic parameters describe the camera’s position and orientation relative to the points in the scene. . Note that the total number of degrees of freedom is 11, where 5 are from the intrinsic parameters that define , 3 are from the rotation matrix, , and 3 are from the position vector, .
6.5 Camera Calibration
Before we can use camera models in practice, we need to determine the camera’s intrinsic and extrinsic parameters. Camera calibration is the process of estimating these parameters, which is essential for quantitative computer vision applications. We present two main approaches: the Direct Linear Method for basic calibration, and auto-calibration for cases where calibration targets are unavailable.
6.5.1 Direct Linear Method
One approach is the direct linear calibration method, which requires a set of known correspondences, for .
Direct linear calibration: Step 1.
For direct linear calibration, the first step is to write each corresponding pair of points, and , in homogeneous coordinates and then use the expression in Equation 6.17 to write:
| (6.18) |
where we refer to as the projection matrix. Next, we use the correspondences to estimate the projection matrix, , and then later we can extract the intrinsic and extrinsic parameters from . A useful first step to determine is to rewrite it in terms of its rows:
| (6.19) |
where is the -th row of . By considering the rows of individually, we can write the relationship in Equation 6.18 as:
which by mapping the homogeneous coordinates, , back to the original coordinates, , yields the expressions:
or equivalently, by some algebraic manipulation, yields the expressions:
| (6.20) |
We can now combine these equations together in one large matrix equation:
| (6.21) |
where is a vector consisting of the stacked rows of and is a matrix of known coefficients determined by the quantities , , and . For a more concrete representation of how we define , the first couple rows are given by:
| (6.22) |
Note that we must have at least six correspondences, , to ensure that is uniquely defined. With this sufficient number of correspondences, we could ideally directly solve Equation 6.21. However, in practice, a more robust procedure is to build with more than 6 points, which gives an overdetermined set of equations that may not have a solution††margin: This is particularly true in real-world applications where noise corrupts the data. . Therefore, to compute , we formulate an optimization problem:
| (6.23) |
where the constraint is required to ensure that the optimization problem cannot be solved by trivially choosing for each . We call this optimization problem a constrained least-squares problem.
Example 6.5.1 (Constrained least-squares optimization).
The constrained least squares problem:
with and and is a finite-dimensional optimization problem. Consider the corresponding Lagrangian:
and the necessary optimality conditions:
We can write the first necessary optimality condition as , and therefore any that satisfies this condition must be an eigenvector of the matrix . Additionally, while all the eigenvectors satisfy this condition, the optimum is the eigenvector associated with the smallest eigenvalue. We can efficiently compute this eigenvector by using a singular value decomposition of and then choosing to be the column of associated with the smallest singular value, since .
Direct linear calibration: Step 2.
Once we have solved the optimization problem in Equation 6.23 to compute the vector , the projection matrix, , is completely defined. The next step in the camera calibration process is to extract the intrinsic and extrinsic camera parameters from the matrix . For this step, we will express the matrix in terms of its columns:
where is the -th column of . We can factorize as:
| (6.24) |
by taking the first three columns of and performing a RQ factorization:
| (6.25) |
where is an orthogonal matrix and is an upper triangular matrix. Once is known, we can compute the vector by .
6.5.2 A Flexible Camera Calibration Method
The projection matrix, , is defined for a specific set of extrinsic parameters and . In practice, however, it might be desirable for us to estimate the camera’s intrinsic parameters from different images from different perspectives, and therefore with different projection matrices due to the varying extrinsic parameters. In this case, we can apply an alternative procedure55. Zhang, Z. “A Flexible New Technique for Camera Calibration.” IEEE Transactions on Pattern Analysis and Machine Intelligence 22, 2000. to the direct linear calibration method to extract the intrinsic parameters, .
We begin by assuming that the known points, , for each individual image lie on a plane. For example, the calibration scene might consist of a pattern, such as a checkerboard pattern, on a planar surface. In this case, we can assume that the world frame origin lies on the plane such that for all points on the plane. Since , we can simplify the relationship between and given by Equation 6.17 to:
| (6.26) |
with:
| (6.27) |
where is called the homography matrix††margin: The homography matrix maps points between two-dimensional planes while a projection matrix maps three-dimensional points to points on a two-dimensional plane. , is the simplified position of the point in world frame, written in homogeneous coordinates, and is the -th column of the rotation matrix, . Note that we can still estimate the homography matrix, , using the same procedure discussed earlier.
Next, we identify a set of constraints on the intrinsic parameter matrix, , by writing the homography, , as:
and noting that since and are orthonormal we have:
| (6.28) |
where is a symmetric matrix. We can therefore solve for the intrinsic camera parameters, , by using the constraints in Equation 6.28 to solve for the symmetric matrix and then backing out the parameters that define . To compute the matrix from the constraints in Equation 6.28, we can employ several useful tricks. The main trick is to notice that even though consists of nine parameters, it is symmetric, and, therefore, we only need six parameters to specify it fully. Therefore, we reparameterize the matrix as a vector as:
| (6.29) |
This reparameterization is useful because it allows us to rewrite the expression as:
| (6.30) |
where:
and where is the -th element of the column vector and is the -th element of the column vector . With this reparameterization, we can rewrite the constraints in Equation 6.28 as:
or by combining them:
| (6.31) |
which is linear with respect to the unknowns vector . Importantly, while the homographies, , are different for each image due to the different extrinsic parameters, the intrinsic camera parameters represented by the vector are the same. Therefore, with images from the same camera, even with potentially different perspectives, we can stack the constraints in Equation 6.31 to give:
| (6.32) |
where . In the case where we include the skewness parameter, , in , there must be images in order to specify uniquely. Similarly to the approach for computing the projection matrix in the previous section, we can compute the vector as the solution to the constrained least squares problem:
| (6.33) |
Once we have computed , we can solve for the intrinsic camera parameters, , by leveraging the definition of . In particular, we compute the intrinsic parameters by:
| (6.34) |
where we can think of as a scaling parameter that accounts for the fact that there are five unknown camera intrinsic parameters but six degrees of freedom in .
Once we have extracted the camera intrinsic parameters, , from this procedure, given any new homography, , we can compute the extrinsic parameters by:
| (6.35) |
As one final step, we note that the matrix defined with column vectors , , and will not generally satisfy the orthonormality property of a rotation matrix. We can correct this issue by again using optimization methods to compute a valid rotation matrix that best corresponds to these column vectors:
| (6.36) |
where:
We solve this problem by choosing , where and are defined by the singular value decomposition of .
6.5.3 Camera Auto-Calibration
The direct linear transformation from Section 6.5.1 and Zhang’s flexible calibration method from Section 6.5.2 require point correspondences to calculate the intrinsic and extrinsic parameters. Auto-calibration offers an alternative approach that does not make this assumption by utilizing multiple views of a static scene to determine the camera’s intrinsic and extrinsic parameters. This approach leverages the fact that a camera’s intrinsic parameters remain constant across different views of the same scene. By identifying correspondences between points in multiple images, we can estimate the intrinsic matrix, , and extrinsic matrices, and , by bundle adjustment based on the static scene geometry. In total, the camera auto-calibration process consists of five key steps.
First, we use an algorithm such as scale-invariant feature transform (SIFT) to identify key points in the scene and their correspondence points across multiple images from different views. The SIFT algorithm is a computer vision method to detect, describe, and match local features in images. It is robust in detecting and describing local features in images, making it effective for finding correspondences under varying conditions. Details of the SIFT algorithm will be discussed in the following chapters.
Second, we use the correspondences between a pair of images to compute the fundamental matrix. The fundamental matrix, , relates corresponding points between a pair of images of the same scene††margin: The fundamental matrix describes the epipolar geometry between two image views. . For a pair of images of the same scene, the fundamental matrix, , satisfies:
| (6.37) |
where and are corresponding points in images and , respectively. We will discuss the fundamental matrix more in the context of stereo vision in Chapter 7.
To compute the fundamental matrix for the image pair, we first construct a point correspondence matrix, , where each row represents a correspondence between points in the two images. Let and be the coordinates of one set of matched points, and . We form each row of the matrix using one set of corresponding coordinates as:
| (6.38) |
From this point correspondence matrix, we then compute the fundamental matrix by solving the linear system using a singular value decomposition (SVD), where is the vectorized form of the fundamental matrix. We describe the specifics of this procedure in more detail in the referenced item.
Third, we compute the essential matrix, which is similar to the fundamental matrix in that it relates corresponding points in two images based on scene geometry. For two images, and , we define the essential matrix by the rotation matrix, , and translation vector, , relating the coordinate frames of the two images by:
| (6.39) |
where is the matrix representation of the cross product. Assuming the intrinsic matrix, , remains the same between the images, we can also define the essential matrix, , with respect to the fundamental matrix as:
| (6.40) |
Therefore, we can first compute the essential matrix from the previously computed fundamental matrix and the intrinsic parameter matrix, , and then we can compute the camera extrinsic rotation and translation parameters, and , by the singular value decomposition:
| (6.41) |
where . From this decomposition, there are two possible solutions for the camera extrinsic parameters:
| (6.42) | ||||||
where:
| (6.43) |
We can identify the correct solution by using each to compute the three-dimensional points from the two-dimensional matched correspondence points, as we describe in the next step. The extrinsic parameters, and , we should use are the ones that ensure that most of the three-dimensional points lie in front of both cameras, meaning they will have positive depth values.
The fourth step is to perform triangulation to compute the 3D points in the scene from the 2D image correspondence points. We define the projection matrix, , for an image as:
| (6.44) |
where again is the camera intrinsic matrix, is the rotation matrix, and is the translation vector. This projection matrix maps a 3D point in homogeneous coordinates into the 2D camera frame coordinates by:
| (6.45) |
Therefore, for matched points across two images, we can compute the 3D coordinates by solving the linear system:
| (6.46) |
where are the coordinates and , , and are the first, second, and third rows of the projection matrix, , for image , respectively, and are the coordinates and , , and are the rows of the projection for image . We can solve Equation 6.46 using a least squares method.
So far, we have used correspondences in pairs of images from the same camera of the same scene to estimate the image extrinsics, and , and computed estimates of the 3D scene points by triangulation. These computations require knowledge of the camera intrinsic matrix, , which is the quantity we are trying to estimate. We can leverage the previous steps to compute by using an iterative optimization-based procedure, where we begin with an estimate††margin: For example, we could start with an estimate by referencing the camera manufacturer’s data, or using some other simpler method. of and refine it until convergence. In particular, we refine the estimate of the camera intrinsics and extrinsics by solving the optimization:
| (6.47) |
where is an observed 2D point in image that corresponds to the -th 3D point, is the -th estimated 3D point, is the projection matrix for image , is the total number of triangulated 3D points, and is the total number of images. Note that each projection matrix is a function of the intrinsic parameters, which are constant across all images, as well as the extrinsic parameters for the image. We can optimize this cost function by applying a nonlinear method, such as Levenberg-Marquardt, to compute a new set of parameters. We then repeat the steps listed above, computing new extrinsics, triangulation points, and optimizing, until convergence.
6.6 RGB-D Camera Calibration
RGB-D cameras present additional calibration challenges beyond traditional cameras. In addition to calibrating the RGB camera using standard methods, we must also:
-
•
Calibrate the depth sensor’s intrinsic parameters
-
•
Determine the extrinsic transformation between RGB and depth sensors
-
•
Correct for systematic depth measurement errors
-
•
Account for the different fields of view and resolutions of the two sensors
Many manufacturers provide factory calibration, but applications requiring high accuracy often necessitate custom calibration procedures using specialized targets that are visible in both RGB and infrared.
6.7 Summary
This chapter presented the mathematical foundations of camera models and calibration techniques essential for vision-based robotics. Starting from the basic pinhole model, we developed the perspective projection equations that relate 3D world points to 2D image coordinates. We explored practical considerations including lens models and distortion, and extended our discussion to modern RGB-D sensors that provide both color and depth information. The calibration methods presented enable us to estimate the camera parameters necessary for quantitative vision applications. With calibrated cameras, we can now proceed to extract three-dimensional information from images, which we explore in the next chapter through stereo vision and structure from motion techniques.
To learn more.
For a deeper dive into camera models and calibration techniques, readers are encouraged to refer to the Foundations of Computer Vision textbook by Torralba et al. (2024)11. Torralba, Antonio, Isola, Phillip, Freeman, William T. Foundations of Computer Vision. The MIT Press, 2024. for a more in-depth discussion on image systems and camera models. For practical calibration algorithms and implementations, the OpenCV library66. Bradski, G. “The OpenCV Library.” Dr. Dobb's Journal of Software Tools, 2000. provides extensive resources and code examples. Interested readers can consult the works directly from Tsai (1987)22. Tsai, R. “A Versatile Camera Calibration Technique for High-accuracy 3D Machine Vision Metrology Using Off-the-shelf TV Cameras and Lenses.” IEEE Journal on Robotics and Automation 3(4), 323–344, 1987., Lowe (1999)33. Lowe, David G. “Object recognition from local scale-invariant features.” In Proceedings of the seventh IEEE international conference on computer vision, 1150–1157, 1999., and Triggs et al. (2000)44. Triggs, Bill, McLauchlan, Philip F, Hartley, Richard I, Fitzgibbon, Andrew W. “Bundle adjustment—a modern synthesis.” In Vision Algorithms: Theory and Practice: International Workshop on Vision Algorithms Corfu, Greece, September 21–22, 1999 Proceedings, 298–372, 2000. for further insights into the algorithms discussed.
6.8 Exercises
The starter code for the exercises provided below is available online through GitHub. To get started, download the code by running in a terminal window:
We denote Problems requiring hand-written solutions and coding in Python with
and
, respectively.
Problem 1: Camera Calibration: Extrinsics
In this exercise, you will implement the key parts of a method to compute the camera extrinsic parameters and . Specifically, you will use the steps in 6.5.1 to compute the homography matrix given a calibration image. Then, given the camera intrinsic matrix , you will use the method at the end of Section 6.5.2 to compute the extrinsics, and , for the image. For this exercise, you will use a chessboard with known dimensions to help with the camera calibration process. This is a convenient choice because it provides a high contrast and the grid corner features are easy to detect.
In the file ch06/exercises/camera_extrinsics.ipynb:
-
1.
First, implement the function generate_chessboard_3D_world_coordinates to compute a grid of 3D world coordinates that correspond to the grid corners of the chessboard. Note that we can choose to set all of the z-coordinates to be since we know the chessboard is a 2D plane. Then, implement the function generate_chessboard_2D_pixel_coordinates to compute the 2D pixel coordinates of the grid corners from an image using the function findChessboardCorners from the open-source computer vision package cv2.
-
2.
Second, implement the function compute_homography using the method from 6.5.1. Note that generally in 6.5.1 we are computing the projection matrix , but in this problem we have a slightly simplified problem of computing the homography matrix which just maps points between two 2D planes (since we know the chessboard grid points lie on a common plane). In other words, when using the approach from 6.5.1 rather than dealing with rows you should be considering rows of the homography matrix and be using the vectors . Once the homography matrix is available, implement the function compute_extrinsics using the method at the end of Section 6.5.2 to compute the extrinsics and given the intrinsic matrix . Additionally, implement the function transform_world_to_pixel to transform a point in the world frame into the pixel coordinates from the camera intrinsics and extrinsics. Run the provided code to see the result of your computations on some example chessboard images.
Problem 2: Camera Calibration: Intrinsics
In Problem 1, we provided the camera intrinsic matrix, . In this exercise††margin:
Note you will need to first complete Problem 1 since this will leverage some of that problem’s code.
, you will use the flexible calibration method described in Section 6.5.2 to compute the intrinsic matrix yourself.
Specifically, explore the notebook
ch06/exercises/camera_intrinsics.ipynb.
You will need to implement the function compute_intrinsics to compute the matrix from a list of homography matrices from different calibration images.
Practice · 3 notebooks
- Camera Extrinsics Open in Colab Source
- Camera Intrinsics Open in Colab Source
- Sift Feature Matching Open in Colab Source