This tutorial explains what is face recognition and how we can use it to detect the age, gender and emotion in PictoBlox(Scratch) This tutorial explains what is face recognition and how we can use it to detect the age, gender and emotion in PictoBlox(Scratch)
  • Home
  • Tutorials
  • Age, Gender and Emotion Detection: Face Recognition – AI in PictoBlox

Age, Gender and Emotion Detection: Face Recognition – AI in PictoBlox

Gender, Emotion, Age Detector in Scratch
About This Tutorial
This tutorial explains what is face recognition and how we can use it to detect the age, gender and emotion in PictoBlox(Scratch)
Tutorial Info

In today’s world, Face recognition is widely used everywhere from the face unlock feature of a smartphone to smile detection in digital cameras to detect faces in real-time for surveillance or even to tag people in pictures over social media platforms like Facebook. Hence, in this tutorial, we will make a script in PictoBlox that detects the face using the camera and reports the age, gender, and emotion of the person.

Face Detection

Before we let’s understand what Face detection is and how it works.

In the past few years, face recognition has become one of the most promising applications of computer vision. Face detection can be considered to be a substantial part of face recognition operations.

Face detection is the action of locating human faces in an image and optionally returning different kinds of face-related data.

How Facial Recognition Works?

First, a face is analyzed from a captured image, its geometrical properties, size, and position are obtained. Then a structure is generated that forms a pattern that is later stored in a database. Once stored, the user’s facial record is compared with the biometric features of each face that is scanned and allows adding new templates to make the recognition more effective. If the image matches a search, the system will alert us that a match has been found.

Face Detection

Requirements:

Making Script in PictoBlox

Now, we know what Face detection is and how it works. So, Let’s make a script in PictoBlox that detects the face using the camera and reports the age, gender, and emotion of the person.

Before making a script make sure your device has connected to the Internet. Because we are going to use the Artificial Intelligence extension of PictoBlox and it will work only if your device is connected to the internet.

Let’s Begin!

  • Create a new project in PictoBlox.
  • Select evive as your board from the Board tab in the menu bar.
  • Next, click on the Add Extension button and add Artificial Intelligence extension.AI Extension of PictoBlox (Scratch)

Setting Up the Stage

  • Add the Square Box sprite and delete the Tobi Sprite.Adding New Sprite
  • Make the following script to hide the Square Box and turn on the camera feed.Face Detector Script
  • The stage is set. Click the green flag to get the camera feed on the stage.

Recognizing the Image

  • Below the previous script, add a wait block and then snap the image recognization block. 
  • Select face details from the first dropdown and set the feed as the stage from the second dropdown.
  • Now, Your script will look like the following script.Face Detector Script
  • Click on the Green flag to run and test the script.
  • Drag and drop the recognized face count block to the scripting area and click on it. It will report to you the number of faces detected.Recognizing face counts Recognizing face counts

Detecting every face in the image

  • Make a new variable called Face.Making variables
  • We will continue with the previous script, set the initial value of the Face variable as 0.
  • Now we use a loop and change value of Face by 1 until the value of Face becomes equal to the faces in the recognized image.Face Detector Script

Displaying Square Box around the faces

  • Now, we will bound the faces by showing the Square Box around them, Hence the box should point towards the face and its parameter i.e. size, coordinates should be as per the face.
  • To do so, add the few more block as shown in the following script.Face Detector Script

Reporting the Age, Gender, and Emotion

And last but not least.

  • Add three more blocks to display Age, Gender, and Emotion and a hide block to disappear the box in the end.
  • Complete the script as shown below.Face Detector Script
    You can download the entire code from here.
  • Your script is now complete. Click the green flag to start the script.Gender, Emotion, Age Detector in Scratch

Hope you enjoyed the tutorial, we also developed an online course on Artificial Intelligence covering all detailed concepts for smart kids like you. So for what you are what for? Enroll now and get yourself certified.

Share this Tutorial
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Featured Projects
All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart