Cameras and calibration
UAT 205 Sensors and Instrumentation Systems
Lesson
By the end of this module you will be able to
- Explain the pinhole camera model and intrinsics such as focal length in pixels and principal point
- Compute the effect of radial lens distortion on pixel position and ground distance
- Explain checkerboard camera calibration with Zhang's method
- Assess calibration with reprojection error and state the definition used
- Explain how photodiodes and ambient light sensors measure light, and size a transimpedance amplifier
Why this matters
The camera is the richest sensor on a drone, used for mapping, counting plants and visual navigation. But an image projects a 3D world onto a 2D plane through an imperfect lens. Without knowing the camera’s parameters and lens distortion, distances measured from images are wrong, maps curve and visual navigation drifts. The drone knowledge base’s camera and IMU calibration unit stresses that calibration is not a single number: it belongs to that specific camera, lens and resolution.
The pinhole camera model
The pinhole model assumes every ray passes through a single point, the centre of projection. A world point at lands on the image plane at (normalised coordinates), then converts to pixels using the focal length in pixels , where is the pixel size, and the principal point . These values are the intrinsics, written as the matrix (Hartley and Zisserman, 2004; Szeliski, 2022).
Lens distortion
Real lenses bend light unevenly across the image. The model of Brown (1966), used by OpenCV, has radial distortion and tangential distortion . Wide-angle drone lenses often have negative , called barrel distortion: the farther from the centre, the more the image is pulled inward, so straight lines near the edges curve.
Example 1 How far distortion moves points on the ground
A camera with 8.8 mm focal length, 3.3 µm pixels and a 4,000-pixel-wide image looks straight down from 100 m. The lens has , (hypothetical values).
FX = 8.8e-3 / 3.3e-6 # focal length in pixels
CX = 2000.0
K1, K2 = -0.12, 0.03
Z = 100.0 # m altitude
GSD = Z / FX # m per pixel at the image centre
print(f"fx {FX:.1f} px, GSD {GSD * 100:.2f} cm/px")
for X in (0, 10, 30, 50, 70):
x = X / Z
r2 = x * x
xd = x * (1 + K1 * r2 + K2 * r2 * r2)
u_ideal, u_real = FX * x + CX, FX * xd + CX
shift = u_ideal - u_real
print(f"X {X:>2} m: ideal u {u_ideal:7.1f}, distorted u {u_real:7.1f}, "
f"shift {shift:5.1f} px = {shift * GSD:.2f} m on the ground")
fx 2666.7 px, GSD 3.75 cm/px
X 0 m: ideal u 2000.0, distorted u 2000.0, shift 0.0 px = 0.00 m on the ground
X 10 m: ideal u 2266.7, distorted u 2266.3, shift 0.3 px = 0.01 m on the ground
X 30 m: ideal u 2800.0, distorted u 2791.6, shift 8.4 px = 0.32 m on the ground
X 50 m: ideal u 3333.3, distorted u 3295.8, shift 37.5 px = 1.41 m on the ground
X 70 m: ideal u 3866.7, distorted u 3770.4, shift 96.3 px = 3.61 m on the ground
At the centre of the image distortion has almost no effect, but near the edge points shift by nearly a hundred pixels, several metres on the ground. Without calibration, a map stitched from images warps into a bowl or dome.
Calibration with Zhang’s method
Zhang (2000) proposed a method using a planar pattern, such as a checkerboard, photographed in many poses. The software finds the square corners in every image, then solves for , the distortion coefficients and the board pose in each image so that the reprojected corners best match the detected ones. OpenCV’s calibration tutorial uses this method. Key points:
- Enter the number of inner corners and the square size in the correct units.
- Photograph the board all over the image, especially at edges and corners, where distortion is largest.
- Lock focus and resolution to match how the camera will be used.
The quality measure is the reprojection error, the difference between detected corners and corners reprojected with the estimated parameters. The drone knowledge base’s unit F16 warns that there are two definitions, RMS per point (divided by ) and RMS per component (divided by ), which differ by a factor of √2, so a report must always state the definition.
Example 2 Per-image reprojection error
Residuals (dx, dy) in pixels for four corners in five images (hypothetical, reduced from a real set with dozens of corners per image).
import math
import statistics as st
residuals = {
"img01": [(0.2, -0.1), (-0.3, 0.2), (0.1, 0.1), (0.0, -0.2)],
"img02": [(0.1, 0.3), (-0.2, -0.1), (0.2, 0.0), (-0.1, 0.2)],
"img03": [(1.8, -1.2), (2.1, 0.9), (-1.6, 1.5), (1.9, -1.4)],
"img04": [(-0.2, 0.1), (0.3, -0.2), (0.1, 0.2), (-0.1, -0.1)],
"img05": [(0.2, 0.2), (-0.1, 0.1), (0.0, -0.3), (0.2, -0.1)],
}
def rmse(pts, per_axis=False):
total = sum(dx * dx + dy * dy for dx, dy in pts)
return math.sqrt(total / (len(pts) * (2 if per_axis else 1)))
every = [p for pts in residuals.values() for p in pts]
print(f"all images: {rmse(every):.3f} px per point, {rmse(every, True):.3f} px per axis")
per_image = {k: rmse(v) for k, v in residuals.items()}
limit = 2 * st.median(per_image.values())
for k, v in per_image.items():
print(f"{k}: {v:.3f} px {'<- check this image' if v > limit else ''}")
kept = [p for k, pts in residuals.items() if per_image[k] <= limit for p in pts]
print(f"without flagged images: {rmse(kept):.3f} px per point")
all images: 1.031 px per point, 0.729 px per axis
img01: 0.245 px
img02: 0.245 px
img03: 2.252 px <- check this image
img04: 0.250 px
img05: 0.245 px
without flagged images: 0.246 px per point
A single abnormal image, for example a blurred one or one with misdetected corners, pulls the overall figure up several-fold. Look at that image before deciding to drop it, and check the result with a separate image set not used for calibration. A low reprojection error alone does not prove the calibration is right.
Light sensors: photodiodes and ambient light
A camera is a large array of light sensors, but drones also carry single light sensors: in LiDAR receivers (module 5), in optical-flow and obstacle sensors, and on top of multispectral cameras to measure sunlight. The basic element is the photodiode. Hamamatsu’s technical note on Si photodiodes describes it as a PN junction that produces a current when light falls on it; with the output shorted (the short-circuit current ) this current rises in proportion to the light over a wide range, which is why photodiodes are used for measurement.
Key characteristics from a photodiode datasheet:
- Photosensitivity (A/W): current produced per watt of light. It depends on wavelength, so the datasheet gives a spectral response curve; silicon responds from the ultraviolet to the near infrared
- Quantum efficiency (QE): the share of incoming photons that become electrons, with in nm (Hamamatsu equation 2-3)
- Dark current: the small current that flows with no light, which limits how dim a light can be measured and grows with temperature
- Response speed: set by the junction capacitance and the load, important for fast pulses such as LiDAR returns
To turn the tiny current into a voltage, the photodiode feeds an op-amp with a feedback resistor , a transimpedance amplifier; the note gives . Choose so the brightest expected light does not saturate the output.
Many products need light “as a person sees it”. An ambient light sensor puts a filter over the photodiode so its spectral response matches the human eye’s photopic curve and adds an ADC with a digital bus. TI’s OPT3001, for example, measures from 0.01 lux to about 83,000 lux, rejects more than 99% of infrared, and reports over I2C a 4-bit exponent and a 12-bit result , with . Lux is weighted to the human eye, so it is not the right unit for crop science. A multispectral survey needs the sunlight in each camera band instead: MicaSense’s downwelling light sensor (DLS) is mounted on top of the aircraft facing the sky, records the light in each of the camera’s bands throughout the flight, and is used together with a calibrated reflectance panel to correct images when clouds change the light in mid-flight.
Example 3 A photodiode amplifier and an ambient light sensor reading
A silicon photodiode with a photosensitivity of 0.45 A/W in the red band (660 nm) receives 20 µW of light and feeds a transimpedance amplifier with (values assumed). Then three OPT3001 register values are converted to lux.
S, WAVELENGTH = 0.45, 660 # A/W and nm, red band (assumed from a datasheet curve)
qe = S * 1240 / WAVELENGTH # Hamamatsu equation (2-3)
P_LIGHT, RF = 20e-6, 100e3 # W on the photodiode, feedback resistor Ω (assumed)
i_sc = S * P_LIGHT
print(f"quantum efficiency {qe:.0%}; photocurrent {i_sc * 1e6:.1f} µA; |Vout| = Isc x Rf = {i_sc * RF:.2f} V")
def opt3001_lux(exponent, mantissa): # TI OPT3001 equation 3
return 0.01 * 2 ** exponent * mantissa
for e, r in ((6, 3125), (0, 3125), (11, 4095)):
print(f"E = {e:>2}, R = {r}: {opt3001_lux(e, r):,.2f} lux")
quantum efficiency 85%; photocurrent 9.0 µA; |Vout| = Isc x Rf = 0.90 V
E = 6, R = 3125: 2,000.00 lux
E = 0, R = 3125: 31.25 lux
E = 11, R = 4095: 83,865.60 lux
About 85% of the red photons become electrons, and 20 µW of light gives 9 µA, which the amplifier turns into 0.9 V, a comfortable level for an ADC; in full sunlight the same might saturate, so the gain must be chosen for the brightest case. For the OPT3001, the same 12-bit result 3125 means 2,000 lux or only 31.25 lux depending on the exponent, so software must always read both fields; the largest code gives the 83,865.6 lux full scale listed in the datasheet. Neither reading says anything about the light in a particular crop band, which is why a multispectral survey relies on its band-matched DLS and reflectance panel rather than on a lux meter.
Module lab
Lab: camera calibration with OpenCV
- Print a checkerboard, measure the real square size with calipers and mount it on a flat, rigid board.
- Take at least 20 images in many poses, covering the whole image including the edges, with focus locked.
- Follow OpenCV’s calibration tutorial (or lab L11 in the drone knowledge base), recording , the distortion coefficients and the reprojection error with its definition.
- Use the code from Example 2 to find abnormal images, inspect the cause and recalibrate.
- Undistort one aerial image and compare straight lines near the edges before and after.
Common mistakes
Watch out
- Entering the square size in the wrong unit.
- Photographing the board only in the centre of the image.
- Changing resolution or zoom after calibration.
- Reporting reprojection error without its definition.
- Dropping high-error images without looking at the cause.
- Using lux to judge crop reflectance, or choosing a transimpedance resistor that saturates in full sun.
Summary
- The pinhole model projects points with and , the camera’s intrinsics.
- Real lenses have radial and tangential distortion, strongest at the image edges.
- Zhang’s method uses many images of a planar board to find intrinsics and distortion.
- Reprojection error must state its definition, be checked per image and be verified with an independent image set.
- A photodiode gives a current proportional to light (), turned into a voltage by a transimpedance amplifier; ambient light sensors report eye-weighted lux, while multispectral work needs band-matched sensors such as a DLS.
Check your understanding
- A 4.5 mm focal length with 1.5 µm pixels gives what ?
- A point at m, m with and lands at what pixel (ignoring distortion)?
- A photodiode with A/W receives 10 µW and feeds a transimpedance amplifier with . What is the size of the output voltage?
- An RMS of 0.5 px per point equals what RMS per component?
- Why must the checkerboard also appear near the image edges?
Answers
- px
- , so V
- px
- Distortion is largest at the edges; without data there, the estimate is inaccurate in that region.
Key formulas
| Pinhole projection | |
| Radial distortion | |
| Photodiode current and transimpedance output | |
| Reprojection RMSE per point |
Key references
- Zhang, Z. (2000). A flexible new technique for camera calibration. IEEE Transactions on Pattern Analysis and Machine Intelligence, 22(11), 1330–1334. link
- Brown, D. C. (1966). Decentering distortion of lenses. Photogrammetric Engineering, 32(3), 444–462.
- OpenCV. Camera calibration (Python tutorial). OpenCV 4.x documentation. link
- Hartley, R., & Zisserman, A. (2004). Multiple view geometry in computer vision (2nd ed.). Cambridge University Press. link
- Szeliski, R. (2022). Computer vision: Algorithms and applications (2nd ed.). Springer. link
- Hamamatsu Photonics. (n.d.). Si photodiodes [Technical note KSPD9001E]. link
- Texas Instruments. (2017). OPT3001 ambient light sensor (ALS) datasheet (SBOS681C). link
- MicaSense. (2023, January 11). What does RedEdge's downwelling light sensor (DLS) do for my data? MicaSense Knowledge Base. link
Further reading
Study the assigned knowledge units in advance, review media and take the module quiz
In class / field
Lab or field practice from worksheets with a safety checklist
Learning evidence: Checked worksheets and quiz results