Lesson 12: Emergency Lane Watchdog with an AI Machine Vision Sensor
The emergency lane is the only "passage of life" for rescue vehicles in the event of an emergency.
According to the Road Traffic Safety Law, except for police cars, engineering rescue vehicles, and ambulances that perform emergency tasks, other motor vehicles are not allowed to enter the "emergency lane".
How can we use the AI machine vision sensor Huskylens and micro:bit to create an emergency lane watchdog, increasing the monitoring and enforcement of violations in the emergency lane, and compensating for the limitations of police patrols and manual photography?
Learning Goals
1. Use the program to trigger the camera function
2. Use the AI machine vision sensor Huskylens to make an emergency lane watchdog
Preparation
Note: The memory card is not included in this kit.
Learning Contents
How to judge whether the vehicle occupies the emergency lane? We can make it by installing a camera above the emergency lane. In this case, when HuskyLens detects that a vehicle is in the lane, it will take a picture of it, and then use the flashing RGB lights to warn the vehicle to leave quickly.
Later, the traffic police only need to check the photos in the memory card to know which vehicles have occupied the emergency lane in violation of regulations, which can save them a lot of time and energy.
Demonstration of AI Machine Vision Sensor HUSKYLENS Object classification function
1. Detect Objects
Align HuskyLens to the target object – car, there will be a white box to select it automatically and its name will be displayed as well on the screen.
2. Mark Objects
Firstly, align HuskyLens to the target object. When it is detected and its name is displayed on screen, align the “+” on screen to the center of the white box of the object, short press the "learning button" to mark it. At this point, the color of the box will change from white to blue, and the name and ID1 of the object will be displayed as well.
3. Recognize Objects
When HuskyLens comes across objects it marked again, there will be a blue box to select them on the screen, as well as their names and ID.
Note: For this project, the functions of learning multiple objects and learning a single object are both suitable.
AI Vision Project Practice
Next, we will complete this project by dividing it into two tasks. First, we must use object recognition and camera functions of HuskyLens to take photos of the vehicles peccancy in the emergency lane. Then add the alarm warning function on the basis of the previous function.
Task 1: Vehicle Photo
In the program, all the vehicles appearing on the HuskyLens screen will be regarded as vehicles that occupy emergency lanes illegally and HuskyLens will take pictures of them.
Task 2: Alarm Warning
Based on task 1, add RGB lights and alarm to warn the vehicle to leave the emergency lane.
Task 1: Vehicle Photo
Hardware Connection
AI Vision Program Design
Function Description:
When HuskyLens detects that there is a vehicle in the emergency lane, it will display “shooting” on screen (x=230, y=10) and take a picture, which will be stored on the SD card.
Program Flow Chart Analysis:
The MakeCode Sample Program
Makecode Sample Program link : https://makecode.microbit.org/_7ukF983TacEt
AI Vision Project Operating Effect
Run the program. The word "Please learn" will be displayed on the screen until HuskyLens learns something. After learning the car, when HuskyLens detects it, the word "shooting" will be displayed on the screen.
Task 2: Alarm Warning
Hardware Connection
Program Design
AI Vision Function Explain:
When the HuskyLens detects that vehicles are occupying the emergency lane illegally, how to signal them to leave quickly? In this case, we can warn the vehicles by the alarm sound and flashing RGB lights.
Program Flow Chart Analysis:
The MakeCode Sample Program
Makecode Sample Program link : https://makecode.microbit.org/_PR2hEALcRCyc
AI Vision Project Operating Effect
Run the program. When HuskyLens detects a car occupying the emergency lane, it will take a picture of it, and then make some lights and alarm sound to warn the car to leave the lane quickly. Besides, you can also view the photos of vehicles on the memory card through the card reader.
Project Review
In this project, we have used the function of object recognition and triggered the camera function by program judgment. That is, it will take a picture once the car is recognized. Moreover, the project can also remind the vehicles occupying the emergency lane to leave by lighting up RGB lights and making alarm sounds.
The emergency lane watchdog, to a large extent, saves traffic police a lot of time and energy. Their work efficiency can be improved owing to the fact that manual photography is no longer required. Because they can know which vehicles have illegally occupied the emergency lane by checking the picture on the memory card.
Project Expansion
You can use waste corrugated paper to draw a complete lane, and then fix HuskyLens above the emergency lane to ensure that HuskyLens can detect vehicles in it.
Click Buy Study Pack of HUSKYLENS for micro:bit
Click Buy Huskylens - An Easy-to-use AI Camera | Vision Sensor
Click Buy Study Pack with HUSKYLENS and micro:bit V2
Engage in learning the previous AI vision project : HuskyLens Camera with an AI Machine Vision Sensor