Lesson 10: Intelligent Reverse Safety System

In real life, vehicles face certain safety risks while reversing, especially in complex environments where the driver’s visibility is easily limited. A moment’s negligence may lead to collisions or even injure pedestrians.

To address this issue, more and more vehicles are now equipped with reverse cameras and parking radar systems to help drivers better perceive the rear environment. However, traditional parking radars can only detect "whether there is an object" but cannot determine "who the object is" or "how far the object is".

This system uses a camera to detect faces in real time, distinguishing pedestrians from other obstacles, and estimates the actual distance based on face size. When a pedestrian enters the danger zone, the vehicle automatically stops reversing, achieving proactive safety protection.

Task Objective

Detect the rear face in real time via the camera, accurately estimate the distance between the vehicle and the pedestrian, and automatically trigger braking when the distance is below the safety threshold, achieving intelligent reverse protection.

Key Knowledge Points

1. Understand the basic principles of face detection technology

2. Use the results of face detection width and height to determine whether reversing poses a risk

3. Understand typical applications of AI and sensing technology in traffic safety

Materials List

Hardware:

HARDWARE LIST
1 Maqueen Plus V3
1 UNIHIKER K10

Software:

Mind+ programming software (V1.8.1 RC3.0 or above)

Download link: https://mindplus.cc/

Hands-on Practice

This project mainly uses the camera to detect whether there is a pedestrian behind, and judges whether it is within a safe distance based on the detected pedestrian face width. If within the safe distance, the car continues reversing; otherwise, it automatically brakes and triggers simultaneous sound and light warnings. Therefore, it is divided into the following two sub-tasks.

Task 1: Pedestrian Recognition

Use the camera to monitor rear faces in real time, and print the detected face pixels (width and height) via the serial port area.

Task 2: Active Safety Braking

Convert the detected face pixel size into actual distance. When the detected distance is less than the preset value (15 cm), the vehicle automatically brakes and triggers simultaneous sound and light warnings.

Task 1: Pedestrian Recognition

1. Hardware connection

Use a USB 3.0 to Type-C data cable to connect the assembled car to the computer. Note: The Type-C end should be connected to the UNIHIKER K10.

2. Software preparation

Open Mind+ and complete the software preparation as shown in the figure below.

3. Programming

Under the "unihiker k10 on start", add the "Enable camera show" block to show the camera-captured image in real time on the K10 screen, making it easier to observe the detection effect.

Similarly, under the "unihiker k10 on start", use the "switch mode face detection" block to change the camera mode to face detection, enabling face recognition capability.

Use the "detected face?" block together with the "if...then" block to determine whether a face is detected in the current frame. If a face is detected, proceed with the distance judgment operation.

Use the "get face attributes length" block to get the detected face height (in pixels). Use the "get face attributes width" block to get the detected face width. Then, use the "Serial 0 write string Wrap" block to output the detected face pixel values in the serial port area.

4. Running the program

Before running the program, make sure the UNIHIKER K10 is correctly connected to the computer via USB. After confirming the connection, click the "Run" button in the software. Once running, the K10 screen will display the live camera feed. When a face is detected, it will be highlighted with a frame, and the face pixel data (width and height) will be printed in the serial area.

Task 2: Active Safety Braking

1. Programming

(1) Face Detection and Distance Conversion

This task builds upon Task 1. To convert face pixels into distance, we need a conversion formula. The formula for converting face pixels to distance is usually based on geometric principles, assuming that the size of the face in the image is inversely proportional to the distance. Distance = K / Face Width (pixels)

How to Determine the Constant K? Here are the steps:

Choose a Known Distance (e.g., 20 cm).

Measure Face Width in Pixels at that distance (e.g., 75 pixels at 20 cm).

Calculate K: K=Known Distance×Face Width (pixels)=20×75=1500

If the detected face width is 50 pixels, and K=1500. Distance=1500/50=30cm

(2) Active Safety Braking

Create a variable "distance". When a face is detected, calculate its distance using the formula and assign it to "distance".

Use the "if...then...else" block to check whether "distance" is less than the safety threshold (e.g., 15 cm).

If true - "distance" is less than the safety threshold), use the "set all motor stop" block to stop the car.

If false - "distance" is greater than the safety threshold), use the "set all motor direction rotate backward speed 100" block to make the car reverse slowly.

Note: Remember to add the "System initialization module" block when using motor control commands.

2. Running the program

Before running the program, please ensure that the UNIHIKER K10 is properly connected to the computer via the USB cable. Once the connection is confirmed, click the "Run" button in the software and wait for the program to execute. If the detected distance is greater than the safe distance threshold (15 cm), the car will start reversing. If the detected distance is less than the safe distance threshold, the car will stop reversing.

3. Try it yourself

Next, let's try to add alert sounds and light effects to the program for Task 2. For example, when the detected distance is less than the safe distance threshold, the buzzer will play the built-in tune "dadadadum," and the front lights of the car will turn red. Conversely, if the detected distance is greater than the safe distance threshold, the car will move backward, and the lights will display green.

Knowledge Base

1. Understanding the Principle of Distance Conversion

Distance conversion bridges mathematical principles with real-world applications. In this project, we estimate the distance between the car and a pedestrian by measuring face width in pixels. This method relies on a simple geometric concept: an object's apparent size in an image is inversely proportional to its distance. For example, a face appears larger when closer to the camera and smaller when farther away—just like how a mountain seems bigger as you approach it.

2. Fundamentals of Face Detection Technology

(1) What is Face Detection?

Face detection is a computer vision technique that identifies human faces in images or videos. It powers applications like smartphone unlocking and surveillance systems.

(2) How It Works

The technology recognizes facial features (eyes, nose, mouth) using deep learning. By training on vast datasets, machines learn to detect faces—similar to how humans learn from experience.

3. The Future of Smart Transportation

Advancements in AI and sensor technology will revolutionize transportation. Future vehicles will not only detect obstacles autonomously but also communicate with other cars (V2V) and infrastructure (V2I) to prevent accidents.

AI-driven autonomous cars will navigate complex traffic, optimize speed, and enhance safety. Beyond mere transport, they’ll evolve into intelligent mobile hubs, connected via sensors for safer, greener, and more efficient travel. The possibilities are limitless.

Challenge Yourself

Since we can detect face pixels and calculate distance, can we also determine the pedestrian’s exact position behind the car (center, left, right)? How would you implement it? Think about it!

icon program.zip 663KB Download(1)
License
All Rights
Reserved
licensBg
0