Emergency Lane Watchdog | Huskylens Playground with micro:bit EP08

0 3384 Medium
projectImage

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.

projectImage

Truck vector created by macrovector - www.freepik.com

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?

Function Introduction:

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.

Materials:

projectImage

Knowledge Field:

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.

1. What is IoT?

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.

2. Introduction to Easy IoT

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.

projectImage

Send and check messages.

projectImage

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.

projectImage

3. Set up IoT Device

Enter the Easy IoT website https://iot.dfrobot.com, register and sign in.

projectImage

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.

projectImage

3. Object Recognition

The setting method and operation steps of object recognition are described in detail in Lesson 5.

Project Practice:

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.

Task 1: Vehicle Photo

1. Structure Building and Hardware Connection

Fix HuskyLens above the emergency lane. Note: We need to ensure the camera detection area is within the lane in case of misidentification.

projectImage

HuskyLens communicates with I/O expansion board through I2C. The connection diagram is as follows:

projectImage

2. Program Design

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.

Step 1. Learn and Recognize

Before designing the program, we need to let the HuskyLens sensor learn the vehicle image.

projectImage

Step 2. Mind+ Settings

Open Mind+ (version 1.62 or above), switch to "Offline", click "Extension", click “micro:bit” under “Board”, click “HuskyLens AI Camera” under “Sensor”.

projectImage

Step 3. Command Learning

Here are the instructions mainly used.

projectImage

① 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.

projectImage

② 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.

projectImage

③ 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.

projectImage

④ 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.

projectImage

⑤ Check whether the IDx has been learned from the requested “Result”.

projectImage

⑥ 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.

projectImage

⑦ Display characters anywhere on the screen, including English letters, numbers and symbols except for Chinese characters.

projectImage

⑧ Trigger camera and screenshot functions of HuskyLens.

projectImage

⑨ Trigger the clearing of all characters displayed by block 7.

Step 4. Flowchart Analysis

projectImage

3. Sample Program

projectImage

4. Operating Effect

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.

Task 2: Remote Control

1. Hardware Connection

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).

projectImage

2. Program Design

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.

Step 1. Add OBLOQ IoT Module

Add a communication module on the basis of task 1. Click “Extensions”, click to load “OBLOQ IoT module” in “Communication”.

projectImage

Step 2. Command Learning

Here are some commands mainly used.

projectImage

① 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.

projectImage

② Send message, send a text to the corresponding channel.

projectImage

③ Receive message, receive the text sent by Easy IoT channel.

Step 3. Flowchart Analysis

projectImage

3. Sample Program

projectImage

4. Operating Effect

projectImage

Project Summary:

Project Review:

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.

Project Extension:

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.

License
All Rights
Reserved
licensBg
0