Course 8 / Lecture 8:

Car license plate recognition

One of the most common robotics applications is barrier control. Parking lots, parking houses, shopping malls all use smart barriers, often equipped with car license plate recognition systems. In this lecture you will learn how to build a smart barrier system that uses license plate recognition. We also add some fun, by shooting the unauthorized vehicles.


Figure 1 - Check how you can turn your camera into a licence plate recognizer

Requirements

Video



Task #1:

Setup the license plate recognition connection!

To use the attached USB camera to recognize license plates, you only need to create a connection for that in Ozeki 10. So, in Control Panel just click on Create new Connection, and select the Video connection method as you can see in Figure 2. Here from the video connections to reach the license plate recognition, you need to choose the Vision connection.


Figure 2 - Connection methods in Ozeki 10

At this point you will be able to see the License plate connection, so after you clicked on it, the last thing that you have to do, is to setup the details of that connection (Figure 3). Here you can set the name of the connection, select from the attached cameras, you can also set the resolution and the frame rate. In the Vision tab, you can select the type of the license plates by regions, and also you can set that to save the detected license plates as a snapshot.


Figure 3 - Connection details of License plate recognition connection

Task #2:

Write code that can store the detected license plate!

In that task, you need to store the detected license plates coming from the connection in SNAP. So, in SNAP, first drag the 'When green flag clicked' entry point. Then, to detect license plates continuously add the 'Forever' block. in 'Forever' first add the 'Get next message', that will wait for messages from the recognition connection. Lastly you have to store the license plate number in a variable, so create a new one with the name 'currentPlate', and with a 'Set 'currentPlate' to message value (string)' (Figure 4) block save the incoming message into the variable.


Figure 4 - Message from the camera stored

Task #3:

Extend code by creating a list of license plate numbers!

To make difference between the license plates that are allowed to get through the barrier and those are not allowed, you need to create a list that contains all the license plates that will be accepted by the recognition camera. For that just create a variable with the name 'licensePlates', and add the 'Set' block before the 'Forever', and select this variable. To the field, drag the 'list' block and type all the license plates that can enter the closed area like in Figure 5.


Figure 5 - List of allowed license plate numbers

Task #4:

Decide that if the detected license plate is in the list or not!

Next, after you can get the messages from the recognition connection, and have got all the license plates that allowed to get through the barrier, you can easily compare the detected license plate with the list, do different actions, if the list contains that license plate or not. For that you just have to add a 'if-else' block, and drag the 'contains' block to the head of it. Lastly as Figure 6 shows add o the left hand side the 'licensePlates' list, and to the right hand side the 'currentPlate' variable. With that you just checked if the 'currentPlate' is in the 'licensePlate' list or not.


Figure 6 - 'If' statement checks if the recognized license plate is in the list or not

Task #5:

Flash the lights on the brick and draw the license plate number to the brick's LCD if that is accepted!

If the license plate is accepted you can greet the car or robot by flashing the LED on the brick, and display the license plate number on the LCD screen. To flash the LEDs you just have to drag the 'Set LED' block into the 'if' block, and select the 'green flashing' option. To display the license plate number, first create a variable with the name 'command' and set it the join of 'draw text foreground 35 50' and the 'currentPlate' variable with the 'Set' block. Then add four 'To [connection] message: [text]' block, and select the LCD to all of them. To the first one, type the command 'clean', to the second one, the 'fontsize large' command, to the third block, drag the 'command' variable, and lastly type the 'update' command as you can see in Figure 7.


Figure 7 - The brick greets the robot by flashing its LEDs and displaying the license plate number

Task #6:

Upgrade code to open the gate to let the robot with the accepted license plate enter the area!

The barrier is connected to motor A, so to open it, you have to rotate that motor. For that, you just need to use the 'Rotate A by -90° at 10%' block, which will rotate the A motor by 90 degrees with 10% of power. Next, with a 'Wait 5 secs' block you have to wait for the robot to go through the barrier safely before you close it. Meanwhile play a beep sound by adding the block 'To, message', where select the speaker and enter the command 'beep' like in Figure 8. Then you can close the gate with the 'Rotate A by 90° at 10%'. Lastly set the LED of the brick back to the initial green color with the 'Set LED' block where you need to choose the 'green' color.


Figure 8 - The barrier control system opens the gate

Task #7:

Expand code to shoot the robot if its license plate is denied!

Now the 'if' part of the code is full, you only need to add blocks to the 'else' part which represents the case when the license plate is denied. So, first, with the 'Set LED' block set the LED of the brick to red, which is the robot's first sign that the license late is rejected. Then with two 'To message' to the LCD with the commands 'clean' and 'update' (Figure 9). These commands will clear the LCD screen, so nothing will be displayed on it. After that, you need to rotate the motor that is connected to the machine gun, which in this case is the B motor. For that, drag the 'Rotate B by -1080° at 30%'. Lastly set the LED back to green with the 'Set LED' block.


Figure 9 - The machine gun shoots the robot if it doesn't have the access to enter

Program code


Figure 10 - The code can detect license plates and decide if the robot has the access to enter or not


More information


Next


Copyright © 2000- |Ozeki Ltd | info@ozekirobot.com |
Page: 6144 | 79.99.42.43 | Login
Thank you for visiting this page