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".
With the increasing number of vehicles, road traffic is seeing mounting pressure. At the same time, the violation of highway emergency lanes takes up a great proportion of all kinds of traffic violations, which need to be tackled urgently. Currently, people mainly deal with it through patrol cars and manual photography. However, these two methods are extremely inefficient, costing manpower and material resources greatly and bringing inconvenience to management.
So, for intensifying investigation and punishment of occupation of emergency lanes, how can we use HuskyLens to make an emergency lane watchdog make up for the shortage of the two traditional methods?
This project uses the object recognition and camera functions of HUSKYLENS to take photos of vehicles occupying emergency lanes. Combined with the OBLOQ module, upload the data to the IoT platform, and remotely warn the vehicle to leave the emergency lane quickly through the IoT platform.
How to judge whether the vehicle occupies the emergency lane or not? To figure this out, we can put a camera above the lane. In this way, when there is a vehicle appearing in the camera, it will take a photo of the vehicle and send the message to IoT platform. Then the traffic police can send a warning command through the platform, ordering the vehicle to leave the lane quickly. In this project, besides the object recognition and camera functions of HuskyLens, we also need to use the communication function with IoT platform from OBLOQ module.
IoT (Internet of Things) refers to that any object is connected to the network through information sensing equipment according to the agreed protocol, and the object exchanges and communicates through information transmission media to realize intelligent identification, positioning, tracking, supervision and other functions. Generally speaking, IoT connects all objects to the Internet through information sensing devices to carry out information exchange, that is, objects and objects are interrelated, so as to realize intelligent identification and management.
EASY IoT is an IoT platform built by DFRobot, which is intended to make people enjoy the simplest IoT experience. In this platform, all complex communication connections are encapsulated into libraries and all necessary API interfaces are provided. In this case, users can make IoT communication just by changing their ID and device Topic.
This platform is based on the MQTT communication protocol, and any MQTT client can connect and use our IoT. It provides customers with many functions like high-speed data access, secure real-time data storage and display, one-click device creation and message sending, etc. Besides, the platform features a low operating threshold and DFRobot has special OBLOQ IoT module for easy connection between terminal devices and IoT.
Send and check messages.
Diversified message display, displaying IoT data in the form of text and graphs, allowing you to easily view the data uploaded to the IoT and the dynamic changes of the data.
Enter the Easy IoT website https://iot.dfrobot.com, register and sign in.
Click the eye icon to check the generated ID and key, and fill in the corresponding position in the Obloq MQTT initialization module. Select China in the server box.
The setting method and operation steps of object recognition are described in detail in Lesson 5.
We will complete this project in two tasks. First, use object recognition and camera functions of HuskyLens to take photos of the vehicles peccancy in the emergency lane. Second, send a message that there is a vehicle occupying the lane to IoT platform and send the command remotely from the platform to warn the vehicle to leave quickly.
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: Remote Control
Add the OBLOQ module based on task 1. When HuskyLens takes a picture of the vehicle, send a message "car detected" to the channel corresponding to Easy IoT. Then the traffic police can remotely control LED lights on the emergency lane by sending an "alert" command in the channel.
Fix HuskyLens above the emergency lane. Note: We need to ensure the camera detection area is within the lane in case of misidentification.
HuskyLens communicates with I/O expansion board through I2C. The connection diagram is as follows:
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.
Before designing the program, we need to let the HuskyLens sensor learn the vehicle image.
Open Mind+ (version 1.62 or above), switch to "Offline", click "Extension", click “micro:bit” under “Board”, click “HuskyLens AI Camera” under “Sensor”.
Here are the instructions mainly used.
① Initialize only once between the beginning of the main program and looping executions. You can select I2C or Serial, and no need to change I2C address. Please note that the “Output protocol”of your HuskyLens sensor should be set to be consistent with the program, otherwise, data cannot be read.
② You can switch to other algorithms freely, but please note that you can run only one algorithm at each time, and it takes some time to switch algorithms.
③ The main controller requests HuskyLens to store data in the “Result” once(stored in the memory variable of the main board, and once requested, it will refresh the data in the memory once), then the data can be obtained from the “Result”. The latest data can be got from the “Result”only when this module is called.
④ Check whether there is frame or arrow in the screen from the requested “Result”, including the learned(id>0) and unlearned, and returns 1 if there is one or more.
⑤ Check whether the IDx has been learned from the requested “Result”.
⑥ Check if the IDx requested from the “Result”is in the screen. The frame refers to the algorithm of the frame on screen, arrow refers to the algorithm of the arrow on screen. Select arrow when the current is only line-tracking algorithm, for others, choose frame.
⑦ Display characters anywhere on the screen, including English letters, numbers and symbols except for Chinese characters.
⑧ Trigger camera and screenshot functions of HuskyLens.
⑨ Trigger the clearing of all characters displayed by block 7.
HuskyLens can recognize the vehicle that appears in the emergency lane and take a picture of it, which will be stored in the SD card. You can view those vehicle photos with a card reader.
Connect the LED light to the P16 port on expansion board based on task 1, the pins of OBLOQ module are respectively corresponding to T (P1), R (P2), - (GND), and + (VCC).
When HuskyLens detects that there is a vehicle occupying the emergency lane, how can it tell the vehicle to leave the lane quickly? At this time, we can realize the remote control by data receiving and sending function of the OBLOQ, which can send a “car detected” message to Easy IoT platform. Traffic police can remotely control the warning light in the emergency lane by sending the “alert” command to the platform.
Add a communication module on the basis of task 1. Click “Extensions”, click to load “OBLOQ IoT module” in “Communication”.
Here are some commands mainly used.
① Initialization, only needs to be executed one time, placed between start of the main program and the loop execution. You can select the soft or hard serial port. When using the soft serial port, you can set the data receiving pin and data sending pin by yourself. Note: The WiFi password and name you filled in need to be correct, and the parameters of the IoT platform should be consistent with the devices created by yourself.
② Send message, send a text to the corresponding channel.
③ Receive message, receive the text sent by Easy IoT channel.
In this project, we used the data receiving and sending function of OBLOQ to tackle vehicles peccancy on the emergency lane by remote control. However, in real life, if a vehicle breaks down or comes with some trouble, it can temporarily park on the lane to wait for rescue while the safety of people is guaranteed. On such occasions, we may need to make a decision after a further judgment.
Knowledge Point Review:
1. Learn the shooting function of HuskyLens
2. Learn the data receiving and sending function of OBLOQ module.
3. HuskyLens realize remote control with OBLOQ.
In actual scenes, vehicles that illegally occupy emergency lanes will be fined. But how can the deductions and fines information be notified to the vehicle owner?
Congrats! You finished all of Tutorials.