Skip to main content
Open In Colab A planner needs the lane in meters, in the car’s own frame: how far the lane center lies to the side, and how sharply the road bends ahead. A forward-facing camera does not give either number directly. Parallel lane lines meet at the horizon, and a meter of road near the car covers many more pixels than a meter 30 m ahead. If the road is flat, a single homography maps every road pixel to its position on the ground. Warping the image with it gives a bird’s-eye view (BEV), a top-down picture of the road in which lane lines are parallel again and distances can be read in meters. This section builds that transformation for a simulated camera, finds the lane in the bird’s-eye view, and maps the lane back onto the camera image. The last part connects the warped image to the learned bird’s-eye grids of current driving stacks.

The road plane and its homography

The vehicle frame has xx pointing forward, yy to the left and zz up, with its origin on the road below the camera. The camera sits at height hh and is tilted down by the pitch angle ϕ\phi. A point P\mathbf{P} in the vehicle frame projects to the pixel p~∼KR(P−C),\tilde{\mathbf{p}} \sim K R (\mathbf{P} - \mathbf{C}), where KK holds the camera intrinsics, RR rotates the vehicle frame into the camera frame, and C=(0,0,h)\mathbf{C} = (0, 0, h) is the camera center. On a flat road every point has z=0z = 0, so P−C=Xex+Yey−h ez\mathbf{P} - \mathbf{C} = X \mathbf{e}_x + Y \mathbf{e}_y - h\, \mathbf{e}_z, and the projection becomes linear in (X,Y,1)(X, Y, 1): p~∼H[XY1],H=K[r1r2−h r3],\tilde{\mathbf{p}} \sim H \begin{bmatrix} X \\ Y \\ 1 \end{bmatrix}, \qquad H = K \begin{bmatrix} \mathbf{r}_1 & \mathbf{r}_2 & -h\, \mathbf{r}_3 \end{bmatrix}, where ri\mathbf{r}_i are the columns of RR. HH is a 3×33 \times 3 homography from the road plane to the image. Its inverse takes any road pixel back to meters on the ground. Pixels above the horizon have no road point, because their rays never meet the road in front of the camera. The simulated camera has a 1280 by 720 image, a focal length of 900 px, a height of 1.5 m and a pitch of 3°.
The camera image is drawn with the same homography. For each pixel, H−1H^{-1} gives the road point the pixel sees, and a function of (X,Y)(X, Y) paints asphalt, grass or white paint there. The lane is 3.7 m wide. Its left edge is a solid line, and its right edge is a dashed line with 3 m dashes and 9 m gaps. A second lane lies to the right. The car drives 0.3 m to the right of the lane center, and the road bends left with a radius of 150 m. A second image of a straight road is used below for calibration.
Simulated camera image of a two-lane road bending left, with a solid line on the left of the lane, a dashed line on the right, grass beside the road and sky above the horizon. The lane lines meet near the horizon at row 313, and the same meter of road shrinks with distance, so neither the curvature nor the car’s offset in the lane can be read from the image.

Calibrating the homography from four points

In the simulation HH is known. The height and pitch of a real camera are not known to the millimeter, so HH is usually calibrated on the road itself. On a straight, flat stretch, the centers of the two lane lines are 3.7 m apart, and points along them can be marked at known distances ahead. Four such points determine a homography. The direct linear transform solves for it from the eight linear equations the four pairs give. Here the points sit on both lines at 8 m and 30 m, and each is marked with half a pixel of error.
The error grows with distance. One pixel row covers about X2/(fh)X^2 / (f h) meters of road at distance XX: 5 cm at 8 m, 67 cm at 30 m and 1.2 m at 40 m. Half a pixel of error at the far points therefore moves the far end of the map by tens of centimeters, while the near end stays exact. This is one reason the bird’s-eye view below stops at 36 m.

Warping to the bird’s-eye view

The bird’s-eye view is a grid on the road, here from 6 to 36 m ahead and 6 m to each side, at 5 cm per pixel. A second matrix AA maps a grid pixel to its road point, so HAHA maps a grid pixel straight to the camera pixel that sees it. The warp fills each grid pixel by sampling the camera image at that position with bilinear interpolation. This is inverse warping: every output pixel gets exactly one value, and the result has no holes.
Left: camera image of a straight road with four marked points on the two lane lines forming a trapezoid. Right: the bird's-eye view, in which the lane lines are parallel and the four points form a rectangle. On the straight road the lane lines are parallel in the bird’s-eye view, and the four marked points form a rectangle 3.7 m wide. The near rows are sharp. The far rows are blurred along the direction of travel, because each camera pixel there is stretched over many grid pixels. The black triangles at the bottom are road outside the camera’s field of view.

Finding the lane

In the bird’s-eye view a lane line is a curve Y(X)Y(X) in meters. The code thresholds the bright paint and builds a histogram of its lateral positions over the 10 m nearest the car. The peak within 3 m on each side gives the starting position of each line. Sliding windows then follow each line forward. Each window collects the paint pixels near the line, recenters on them, and steps ahead along the line’s direction, which also carries it across the gaps of the dashed line. A quadratic Y=aX2+bX+cY = aX^2 + bX + c fitted to the collected pixels gives the radius of curvature at the car (X=0X = 0), ρ=(1+b2)3/2∣2a∣,\rho = \frac{(1 + b^2)^{3/2}}{|2a|}, and the lane center at the car is the mean of the two fitted values of cc.
Bird's-eye view of the curved road with the sliding windows that follow each lane line and the quadratic fit through each line. The estimates are 141 m against the true 150 m, and 0.36 m against the true 0.30 m. With the exact homography the same code gives 152 m and 0.28 m, so most of the error comes from the half-pixel marking error in the calibration, which stretches the far end of the map.

Back to the camera image

To show the result in the camera image, each camera pixel is sent to the road through H−1H^{-1}. The pixel is painted when its road point lies between the two fitted lines and inside the grid. Only the inverse of the same homography is needed.
The camera image of the curve with the detected lane shaded green between the fitted lines, and the estimated radius and lane-center offset printed in a corner.

When the road plane moves

The homography is valid only for the road plane it was calibrated on. When the car brakes or drives over a bump it pitches, and the camera’s real pitch no longer matches HH. Below, the car is pitched 1° nose up, and the image is warped with the calibrated HH.
Two bird's-eye views of the same curve. With the calibrated pitch the lane has constant width; with the car pitched up by one degree the lane lines converge with distance. A point 10 m ahead lands at 9.0 m, one 20 m ahead at 16.1 m, and one 30 m ahead at 21.9 m. The lane narrows from 3.7 m to 3.30, 2.94 and 2.64 m, so the lines in the bird’s-eye view converge and the curve looks tighter. A curvature estimate from this frame would be wrong. A hill or a banked road breaks the flat-road assumption in the same way. Correcting for it needs the pitch in every frame, from an IMU for example, or a road model that is not a single plane.

From a warped image to a bird’s-eye grid

The homography maps only the road plane. Anything with height, such as a car, a pedestrian or a curb, is smeared away from the camera in the warped image, because the homography treats every pixel as a point on the road. Driving stacks therefore treat the bird’s-eye view as a grid to fill rather than an image to warp. Lidar returns are projected into the grid directly. For cameras, networks learn to transform the images of several cameras into one bird’s-eye grid around the car and label each cell, for example as drivable road or as an obstacle. Tesla’s occupancy networks predict a 3D grid of occupied voxels from eight cameras (Elluswamy, 2022). These grids are occupancy grids filled by a learned inverse sensor model, and the planner uses them the same way.

References

  • Elluswamy, A. (2022). Keynote, Workshop on Autonomous Driving, CVPR 2022. Video.
  • Monogioudis, P. (2017). Advanced lane finding. Perspective transform to a bird’s-eye view, sliding-window lane search and curvature estimation.

Found an error on this page? Report an issue.