Self-Driving Cars
Topic 6 · Part 2: Seeing the road · ⏱ about 2 h

Sensors and the Camera Model

What each sensor on a self-driving car measures and where it fails, how a camera turns the 3D world into pixels (the pinhole model, intrinsics and extrinsics), the car's camera in the simulator with perfect labels, and turning the camera view into a bird's-eye view.

Softmaxima Simulator StudioTry this topic's code in the Studio: it opens with the camera and trained networks project, ready to run.Open
Show:
In this topic
Beginner

In plain words

A camera turns the 3D world into a flat picture: far things look small and high up, near things big and low down. If you know how high the camera is and how it is tilted, you can turn that back around and say where on the road each pixel is.

By the end of this topic you will be able to explain how a camera sees the road, and find where on the road a point in the image is.

Start with: the demo Try it: the car's camera, with perfect labels.

Beginner

The sensors on a self-driving car

SensorMeasuresStrengthsWeaknesses
Cameracolour images, 30–60 per secondcheap, high resolution, reads signs, lights and lane paintno direct distance; struggles in darkness, glare, heavy rain
Lidardistance to millions of points per second, by timing laser pulsesaccurate 3D shape, works at nightexpensive; no colour; affected by heavy rain, fog and snow
Radardistance and speed of objects, using radio wavesworks in any weather; measures speed directlycoarse resolution; confused by metal objects such as signs
GPS (GNSS)position on Earthglobal, simpleonly a few metres accurate alone; fails in tunnels and between tall buildings
IMUacceleration and rotation ratevery fast, needs nothing outside the carsmall errors add up quickly (drift)
Wheel encoders, ultrasonicwheel rotation; distance to very near objectscheap; useful for parkingshort range; wheel slip

No sensor is good at everything, so real cars use several and combine them (sensor fusion, Part 3). Some companies rely mainly on cameras; most robotaxis add lidar and radar. This part of the course focuses on the camera, because learning to see from images is where deep learning matters most.

Intermediate · Maths

The pinhole camera model

A camera maps a point in 3D to a pixel. In the simplest model, light from the point passes through one tiny hole and lands on the sensor. Using camera coordinates with Z pointing forward along the camera's axis, X to the right and Y down, a point (X, Y, Z) lands on pixel

u=f XZ+cx,v=f YZ+cyu = f\,\frac{X}{Z} + c_x,\qquad v = f\,\frac{Y}{Z} + c_y

Dividing by Z, the distance along the axis, is what makes far things look small. f is the focal length in pixels, and (cx, cy) is the image centre. These are the camera's intrinsics, usually written as a matrix K:

K=(f0cx0fcy001),f=W/2tan⁡(FOV/2)K = \begin{pmatrix} f & 0 & c_x\\ 0 & f & c_y\\ 0 & 0 & 1\end{pmatrix}, \qquad f = \frac{W/2}{\tan(\text{FOV}/2)}

The extrinsics say where the camera sits on the car and which way it points: in our car, 1.4 m above the road, 1.6 m ahead of the rear axle, tilted 4° down. A point in the car's frame is first moved and rotated into the camera's frame, then projected with K. Real lenses also bend straight lines a little (lens distortion); calibration, usually by photographing a printed checkerboard from several angles, measures K and the distortion. Our simulated camera is perfect, so no calibration is needed.

Try it

Try it: the car's camera, with perfect labels

The car drives itself with an autopilot. Switch the view to see the labels the simulator knows for every pixel, and try different weather. Cars, pedestrians and traffic lights each get a box, taken from the pixels they actually cover, so hidden parts are not counted.

Interactive: this part runs in your browser.

Try it

Try it: field of view, height and pitch

A wide field of view sees more of the road at the sides but makes everything smaller. A higher camera sees further over other cars. Watch where the road point 20 m ahead lands.

Interactive: this part runs in your browser.

Beginner

From the camera to a bird's-eye view

Lane lines that are parallel on the road meet at a point in the camera image, which makes them awkward to measure. If the road is flat and we know the camera's intrinsics and extrinsics, we can reverse the projection: for every cell of a top-down grid on the road, compute which pixel sees it, and copy that pixel's colour. This is inverse perspective mapping, and it gives a bird's-eye view where lane lines are parallel again and distances are in metres.

The trick only works for things on the road surface. A car or a pedestrian is not flat, so it gets stretched into a long smear. That is fine for lane finding, which is the next topic, and one reason why detecting objects needs different methods.

Check yourself

Quiz

1. Which sensor measures the speed of other cars directly and works in fog?

2. In the pinhole model, what happens to an object's size in the image if its distance doubles?

3. A 320-pixel-wide camera has a 90° field of view. What is its focal length in pixels?

4. Why does a car look smeared in a bird's-eye view made by inverse perspective mapping?

Go deeper

📚 Further reading

Trusted, mostly free sources: official documentation, well-known textbooks and courses. When you want to confirm or go deeper on anything here, start with these.

Ready