Perspective correction
Let's take a step back and start simple. The easiest case that we can have is with a straight lane. Let's see how it looks:
If we were flying over the road, and watching it from a bird's eye view, the lanes would be parallel, but in the picture, they are not, because of the perspective.
The perspective depends on the focal length of the lens (lenses with a shorter focal length show a stronger perspective) and the position of the camera. Once the camera is mounted on a car, the perspective is fixed, so we can take it into consideration and correct the image.
OpenCV has a method to compute the perspective transformation: getPerspectiveTransform()
.
It takes two parameters, both arrays of four points, identifying the trapezoid of the perspective. One array is the source and one array is the destination. This means that the same method can be used to compute...