Deep Learning and Facial Recognition
Use the Machine Learning extension to achieve facial recognition function. When "woman" is recognized, the message "laugh" will be broadcast, and HaloCode will make a smiling face with its LED ring; otherwise, the message "angry" will be broadcast, and the LED ring of HaloCode will light up red. You can apply facial recognition to your smart-home system.
1. Under "Sprites", click "+" in the Blocks area to add "Teachable Machine" extension.
2. Select Teachable Machine blocks, and click "Training model" to build a new model. In this example, we'll need 3 categories.
3. Name the first category "woman". Print a photo of a woman, and place the photo in front of the camera. Click and hold the button "Learn", so that enough samples will be collected. (Change the angle of the photo to collect different samples; more samples come with better recognition result.)
4. Likewise, we can collect samples for category "man" and "student".
5. When the sample collecting process is done, click "Use the model".
Add event and control
6. Drag an Events blockand a Control block . Then add a Teachable Machine (TM) block .
Create broadcast messages
7. Click Events blocks, and create two messages, "laugh" and "angry".
8. Add an Events block. (HaloCode will execute the script that is activated by the message "laugh", and then others.)
9. Likewise, for "man" and "student", add corresponding Events block. Add a Control block to keep facial recognition function on.
10. Under "Devices", choose "HaloCode". Add an Events blockand two Lighting blocks to light up the second and tenth LED, as the "eyes" of the smiling face.
11. Add 5 more Lighting blocksto light up the fourth to eighth LED as the "mouth". Adjust the RGB values to set the color to light pink.
12. Add a Control blockand a Lighting block .
13. Add an Events blockand a Lighting block . Set the color to red. 0.1 second later, light off all LEDs.