Rectification layer

The rectification layer is a dynamic module you can plug/unplug between the detector’s output and the recognizer’s input to rectify a license plate in order to suppress the distortion. A plate is distorted if it’s slanted or skewed.

A license plate is attached on a moving car and is supposed to be undeformable. The camera could be also moving even if this is not the case for most scenarios. In such situation, every position the plate can take could be estimated using a 3x3 matrice. This is the homography matrice.

The goal for the rectification layer is to estimate the homography matrice using linear regression, compute it’s inverse, multiply it with every pixel from the detector’s output and provide the warped pixels to the recognizer’s input.

As you may expect, this process is time consuming and is disabled by default when the SDK is running on ARM devices. You should not worry about its absence as the default code can already handle moderately distorted plates.

See the configuration section on how to enable/disable the rectification layer.

The next image shows how the rectification layer transforms an image to remove the skew and slant.

Image transformation using rectification layer

Left: before rectification. Right: After rectification


There are two polarities: dark_on_bright and bright_on_dark.


The numbers on the license plate are darker than the background. Example: Black numbers on white background (European license plates).


The numbers on the license plate are brighter than the background. Example: White numbers on blue background (Chinese license plates).

Unlike other implementations we don’t use the four corners from the license plate to estimate the homography matrice because such implemention wouldn’t be robust to high distortions or heavy noise. Instead, we use every edge on the plate to estimate the skew and shear/slant angles. Theses angles are combined with the x/y scales (size normalization) to build a 3x3 rectification matrice (our homography matrice).

The edges directions are very important and this is why we need to know what the polarity. The code contains a polarifier which can estimate the polarity but it’s not immune to errors. To help the polarifier you can define a preferred polarity and even better you can restrict it if your country uses single polarity. See the configuration section for more info.

See the configuration section on how to give a “hint” to the polarifier or define a fixed value.