Build Webcam and IP camera solutions efficiently in C#.Net
- Download the SDK
- Copy the C# code example into Visual Studio
- Build your IP Camera project
Did you know?This SDK was used to build:
Ozeki Phone System XE - VoIP PBX Software for Developers Which is a high performance PBX system supporting Mobile and Desktop phones.
It was also used to create Ozeki 3D VoIP softphone. A cool SIP client that allows 3D Video calls.
How to implement number plate recognition in C#
NPR (Number Plate Recognition) is a system that captures the image of vehicles and recognizes their license numbers using image processing algorhitms. It can be used at a number of places for like automatic high-way parking systems, traffic safety enforcement systems, automatic toll collection gates, car parking systems, automated petrol stations, and border security gates.
Difficulties of creating a capture from a number plate
- Poor resolution, usually because the plate is too far away or using a low-quality camera.
- Poor lighting and low contrast due to overexposure, reflection or shadows.
- An object obscuring (part of) the plate, quite often a tow bar, or the plate is broken or dirty.
- A different font, popular for vanity plates (some countries do not allow such plates).
- Lack of coordination between countries or states. Two cars from different countries or states can have the same number but they have different design of the plates and different country codes on it.
To maximize the chance of effective license plate capture, installers should carefully consider the positioning of the camera relative to the target capture area. Exceeding threshold angles of incidence between camera lens and license plate will greatly reduce the probability of obtaining usable images due to distortion. Analyzing a live video stream or a picture is very time-consuming and sometimes does not produce any usable results.
Figure 1 - ANPR System
We need to complete four steps to recognize a number plate from a camera image.
The first step refers to process and prepare an image which is necessary for further license plate detection and character recognition. Pre-processing involves the digital filtering of an image. First, every colour image is converted into grayscale mode to preserve memory and speed up the further processing. This does not affect the useful data of the image.
According to the new conception of additional thresholding entirely black pixel rows appear repeatedly in the image after pre-processing. The white license plate area is situated somewhere between those black rows. By finding the longest vertical array of white pixels, it is possible to detect the left and the right edge of the license plate. When analyzing the image from left to right, the first longest vertical array of white pixels represents the left edge of the license plate. Accordingly, the last white column of the same size represents the right edge of the license plate. By finding the longest horizontal array of white pixels, it is possible to detect the top and the bottom of the license plate. It is enough to know the position of these license plate edges to detect the coordinates of the license plate.
The next step is the segmentation of the license plate area into smaller parts each representing a character of the license plate. We often apply the adaptive thresholding filter to enhance an area of the plate before the segmentation. The adaptive thresholding is used to separate dark foreground from light background with non-uniform illumination. Vertical projection of a binary image looks like a set of black hills on a white surface. This is obtained by counting the number of black pixels in each column. Columns without black pixels represent the spacing between each character. Coordinates of each character are then determined with alternatively found left and right hill edge
The process of character recognition is repeated for each character image obtained in the last step. This process can be carried out in several steps. The output of this process should be a recognized character. The set of possible outputs are characters appearing on license plates, which can be alphabetic letters, numbers from 0 to 9 and special characters like the dash. Algorithms also look for characters equal in color and equidistance, with similar font structure to break apart each individual character. This sequential congruency of the characters embodies a characteristic set that is typically uniform, regardless of the type of license plate. Character Segmentation separates each letter or number where it is subsequently processed by optical character recognition algorithms. In order to simplify recognition, the initial step is to separate the possible outputs into smaller groups by counting the character end points. There are situations when the recognition mechanism fails, in these cases it is possibile to detect the failure by a syntactical analysis of the recognized plate. If we have country-specific rules for the plates, we can evaluate the validity of that plate towards these rules. Automatic syntax-based correction of plate numbers can increase the recognition abilities of the whole ANPR system.
Implementing number plate recognition
A graphic user interface is built to make testing easier through each phase from the previous section. Each phase can be performed by clicking on a separate button, while the whole process can be performed by clicking one single button. Images obtained using this algorithm are shown one by another in the image-boxes. In the end, the recognized license plate characters are presented as a string inside the label in the lower right corner. The using of several integrated bitmap functions makes the image processing much easier. The functions are used for managing the pixel values and image cropping.
Below you can find the answers for the most frequently asked questions related to this topic:
How can I get the URL of the camera?
You can get the URL from the producer of the camera. (In the 10th tutorial you can find information on how to create an own IP camera discoverer program.)