The Musical Magic Mirror with an AI Machine Vision Sensor | Study Pack of HUSKYLENS for micro:bit 01
Lesson 1 The Musical Magic Mirror with an AI Machine Vision Sensor
Unlock the power of AI camera vision with our comprehensive guide on creating a musical magic mirror using AI camera HUSKYLENS and microbit. Equipped with innovative face recognition technology, this project illuminates the potential of integrating artificial intelligence into everyday use. Dive into the practical application of AI vision, explore the complex mechanics of face recognition, and learn how to bring a musical magic mirror to life with HUSKYLENS, the toolset for the future of AI camera vision.
“Mirror, Mirror, on the wall, who’s the fairest of them all?”I am sure you’ve been very familiar with this line since it comes from the classic childhood fairy tale Snow White and the Seven Dwarfs.
Now, with AI camera HUSKYLENS, you can make a real magic mirror like this by yourself. Getting the mirror to talk is a bit difficult, but letting a buzzer make a sound is easy. So let's make a musical magic mirror that can express its attitude by playing different music!
1. Understand the working principle and application scenarios of face recognition
2. Learn to use the face recognition function of HUSKYLENS
3. Learn to use AI camera HUSKYLENS to make a musical magic mirror
Tips: In order to facilitate teaching, we specially prepared cards with a human face printed for HUSKYLENS to learn and recognize. Of course, HUSKYLENS can also learn to recognize real human faces.
Learning Content AI Camera
The working principle and applications of face recognition
Like other biological characteristics of the human body (fingerprint, iris, etc.), the face is inherent, unique, and not easily copied. It is the first kind of image that has been studied, and also the widely used one in the field of computer vision. This project is making use of the face recognition of HUSKYLENS.
1. What is face recognition Vision Technology
Face recognition is a biological recognition technology for identity recognition based on information about facial features. It uses a camera to collect images and videos containing human faces and automatically detects and tracks the faces, then performs a series of analytical techniques of the detected faces.
2. The working principle of face recognition
There are 4 key steps in the process of face recognition:
Here is a brief description of these 4 steps.
Face detection: Find the position of the face in the picture, usually marked with a box.
Face alignment: Identify faces from different angles by locating feature points on the face.
Face coding: It can be simply understood as extracting face information and converting it into information that can be understood by a computer.
Face matching: Match the face information to an existing database, which to obtain a similarity score and give the matching result.
Face recognition is also considered to be one of the most difficult research topics in the field of biometric and even in the field of artificial intelligence (AI). The difficulty of face recognition is mainly caused by the characteristics of the face as a biological feature.
Similarity: There is just a little difference between different individuals. The facial structure of all faces is similar, and even the appearance and structure of human facial organs are very similar. Such a feature is advantageous for using human faces for positioning, but it is disadvantageous for using human faces to distinguish human individuals.
Variability: The shape of the human face is very unstable, and people can produce many expressions through facial changes. Observing the face from different angles, the visual image of the face will also be very different. In addition, face recognition is also affected by various factors such as lighting conditions (such as day and night, indoor and outdoor, etc.), face coverings (such as masks, sunglasses, hair, beards, etc.), age and other factors.
3. Main application scenarios of face recognition vision technology
Access control system: In areas protected by security, the identity of entrants can be identified through face recognition, such as prisons, detention centers, communities, schools, etc.
Camera surveillance system: For example, surveillance of people in public places such as banks, airports, stadiums, shopping malls, supermarkets, etc., to achieve the purpose of identity recognition, or installing surveillance systems at airports to prevent terrorists from boarding the plane.
Network application: Use face recognition to assist the use of credit cards for online payment, to prevent non-credit card users from impersonating the owner and to prevent counterfeit claims in social security payment, etc.
Face recognition is currently widely used in all walks of life, such as student attendance systems, cameras, unlocking mobile phones, and all-in-one verification machines.
In addition to the above several application scenarios, where else can you list the use of face recognition technology in your life?
Before using HUSKYLENS, it is recommended that you upgrade the firmware to the latest version to get the latest features and the most stable experience. If your HUSKYLENS is already the latest version of the firmware, there is no need to update it.
This tutorial requires a firmware version of at least V0.5.1, this version integrates all functions (including object classification).
1. Check the firmware version number
1. Toggle the function button to the right until the last option “general setting”, short press the function button to enter the secondary menu;
2. Toggle the function button to the right until you reach the “version”option, you can see the version number. As shown in the figure below, the version number is 0.5.1Norm.
2. Firmware upgrade
If your firmware version is lower than V0.5.1 or you are a user of HUSKYLENS for the first time, please refer to the WIKI website for firmware burning and language setting.
AI Camera HUSKYLENS Face Recognition Function Demonstration
The reason why AI camera HUSKYLENS can distinguish faces is mainly because of its built-in machine learning function. It is like a database collector, which can manually input the specified face information and mark this information.
How does it work? Take out your HUSKYLENS first, and let's do it together!
1. Power on
AI camera HUSKYLENS comes with an independent USB power port. Power on the board via a USB cable.
2. Select the "Face Recognition" function
Toggle the "Function Button" to the left until "Face Recognition" is displayed at the top of the screen.
3. Face learning
Point HUSKYLENS at the human face area, the screen will automatically select all the detected faces with a white frame, and the words "human face" will be displayed respectively.
Align the "+" in the center of the HUSKYLENS screen with the face that needs to be learned, short press the "learning button" to complete the learning. If the same face is recognized, a blue frame will appear on the screen and display "Face: ID1". This shows that HuskyLens has learned the face and can recognize it now.
* Keep pressing the "learning button", you can record faces from multiple angles.
* If there is no "+" in the center of the screen, it means that HUSKYLENS has been learned under this function (learned state). At this time, short press the "learning button", the screen will prompt "press again to forget!". Short press the "learning button" again before the end of the countdown to delete what learned last time.
AI Vision Project Practice
After learning the basic operation of the HUSKYLENS AI camera, let's finish the production of the musical magic mirror together~
The first function to be realized is that when the camera recognizes faces, it can distinguish between learned and unlearned faces in the terminal. The second is to add music to achieve different music playback, at least two. At last, you can also find a small mirror to build the exterior. This will be done in two tasks.
Task 1: Distinguish human faces with AI camera
First, learn how to use the HUSKYLENS camera to recognize and distinguish human faces, also be able to make judgments. When the learned faces are recognized, there should be some feedback.
Task 2: Add music
After learning how to distinguish faces and perform the feedback function, you can add more functions on this basis, such as being able to play different music after identifying different faces.
Task 1: Distinguish human faces AI camera
Note: HUSKYLENS sensor uses the I2C interface, you need to pay attention to the line sequence when wiring, and do not connect it wrongly or reversely. At the same time, you need to set the protocol type to I2C on HUSKYLENS.
AI Vision Program Design
The default AI camera for distinguishing faces here has learned the specified face information (for the specific learning process, please refer to the HUSKYLENS face recognition function demonstration in this chapter). When the camera sees the face again, it will judge whether it is the learned face. By displaying different patterns on the main control screen, the display process is more intuitive. When a smiling face is displayed on the main control panel, it means that the learned face has been recognized; when a crying face is displayed, it means that the face has not been learned.
The MakeCode Sample Program
For users who are not familiar with the use of micro:bit, please refer to the introductory tutorial of micro:bit.
AI Vision Operating Effect
Run the program, when AI camera HUSKYLENS detects a face that has been learned, it will display a smiling face, and if it detects a face that has not been learned, it will switch to a crying face.
Note: When running the program, in addition to powering the IO expansion board, HUSKYLENS also needs a separate power supply.
Task 2: Add music
The program design
Here, we can add a piece of music under the smiling face and crying face. For example, "Dashing thr'o the snow, In a one horso open sleigh." in the music "Jingle Bells" and "Twinkle Twinkle little star, how I wonder what you are!" in "Little Star".
How to add music? The buzzer that comes with the IO expansion board is used here, turned on the switch that controls the buzzer while in use.
How to find the music score? Search for the notation of "Jingle Bells" and "Little Stars" on the Internet, and cut out the paragraphs you need.
How to write a program? In MakeCode, it has instructions for playing notes, which are divided into three scales of low, mid and high, and 7 different beats.
How to match music scores with instructions? Here is a simple identification method, take note 2 as an example, as shown in the following table.
The MakeCode Sample Program：
AI Vision Operating Effect
Run the program, when the AI camera detects a face that has been learned, it will play the music "Dashing thr'o the snow, In a one horso open sleigh." If the camera detects other faces, it will play the music "Twinkle Twinkle little star, how I wonder what you are!". Isn't it very interesting?
At last, you can also try to let it learn your face, find a small mirror, hide the hardware behind the mirror, expose the camera to collect face information, and build a musical magic mirror that can recognize you!
AI Vision Project Review
Through the musical magic mirror project, we not only learned the working principle of face recognition vision technology, but also learned the instruction application of AI camera HUSKYLENS face recognition algorithm.
In the field of artificial intelligence visual recognition, face recognition is an indispensable part, and there are also variable application scenarios. Let's brainstorm together, think about what other face recognition applications that we can make.
In this project, we combined face recognition with music to make a fun musical magic mirror. In fact, when you think about it, HUSKYLENS will make a sound when it recognizes an unknown face. Isn't this an access control alarm system?