Lesson 2 - AI Exploration: Face Detection

Lesson 2 - AI Exploration: Face Detection

Students learn how to detect human faces and program the micro:bit to show a pattern when it detects a human face.

image1.pngI can explain what face detection is.

image3.pngI can summarize what makes face detection easier.

image3.pngI can write pseudocode to plan my program.


1. Engage: What Is a Smart Gate?

We need a smarter way to run the farm: a gate that knows when someone is coming—no button needed. The technology behind it is called face detection.

Key Question

What is face detection?

image5.png

Definition: Face detection is a computer vision technique that enables a program to detect human faces and locate them within images or video streams.

Let’s make a smart gate bell with face detection!


2. Explore: How Does the Camera "See" a Person?

First, make the hardware connection:

image6.png

Once the hardware is connected, press the mode button to switch the AI camera to “face detection” mode. The topright LED shows which mode the camera is currently in, while the bottomright LED lights up to indicate whether a face has been detected.

image7.png

Activity 1

• Build and install the hardware following the Building Instruction.

image8.png

• Test and complete the table:

ActionDoes it work?
In a dark classroom.
In a light classroom.
image9.png
image9.png
Show the side face.
Show the straight face.
image9.png
image9.png
Stand one arm's length away from the camera.
Stand 3 meters away from the camera.
image9.png
image9.png
Cover your eyes.
Cover your mouth.
image9.png
image9.png
Using a photo of a face.image9.png

Key Question

What conditions make face detection easy? What makes it hard?

Lighting

Orientation of face

Scale of face

Occlusion


3. Engineer: Build the Face-Detecting Bell

Part 1: Plan the Algorithm

Key Question

What should our smart bell do?

Let's describe how this algorithm should work.

image11.png

This is our program's pseudocode, which is the important part of our program.

Part 2: Rebuild the Code

Go to MakeCode and add the required Extensions.

image12.pngClick Extensions
image13.pngType boson and search
image14.pngClick the extension and go back to the coding page

Rebuild the code.

image15.png

Download the program and check the effect.

Walk in front of the camera → The “√” should show.

Walk away → The “×” should show.


4. Experience & Challenge: Build Your Smart Gate

Experience: choose your favorite bell music

Activity 2

• Guide students to explore the Music category to make the smart gate ring when it sees a face.

image16.png

• Students can choose their favorite Music block or combine them to customize their program.

Challenge: Improve your smart bell

Run your program, and what do you notice?

Key Question

What will happen if you keep standing in front of the camera?

If you keep showing your face to the camera, the music loops rapidly, which is noisy and annoying.

Activity 3

• Challenge students to add the pause (ms) block in the program to wait a moment after the bell rings.

• Change the pause time to 1 second and 5 seconds. What is the difference?

image17.png


5. See also: How does AI learn to detect?

Key Question

How does AI learn to detect faces?

It wasn't born with that ability. It had to learn—just like you learn to recognize things!

How does it work?
Step 1: Look at lots of pictures.

The AI was shown millions of pictures—some with faces, some without.

Step 2: Find the patterns

Over time, it discovered that face pictures always share something in common—like two dark spots on top (eyes), a line in the middle (nose), and another line below (mouth).

Step 3: Practice and fix mistakes

Every time it made a wrong guess, it adjusted itself—a little bit at a time—until it got better and better.

This is called Machine Learning. AI doesn't learn from a manual. It learns from data—lots and lots of it!

icon Lesson 2.zip 3.43MB Download(0)
License
All Rights
Reserved
licensBg
0