Making an Expression Recognizer Using Face Detection in PictoBlox

Learn to recognize expressions using PictoBlox. Follow these steps and make your own expression recognition machine to detect age, gender, location, and many other features. Download the script and get started today!


With the age of AI ahead us, nowadays the face detection software is used in almost every field from mobile devices to snap chat face filters to various security applications. Now that you can learn and make projects on AI using PictoBlox, will be using the face detection extension of the PictoBlox that helps you recognize faces, their age, expressions, gender, location, and many other features. In this tutorial, we will be making a script to recognize the expressions/emotion of the human face. You can download PictoBlox from here.

Ready. Set. Code.

Working with PictoBlox

As the title of the tutorial itself suggests, we will be making this project in PictoBlox- a scratch based graphical programming software. Follow these steps and make your own expression recognition machine.

Setting up the Software

As you like to be up-to-date, so does the software. To use the face detection extension of PictoBlox, you need to update PictoBlox to its latest version. You can download it from here.

Adding Up the Extension

Now that we have the latest version, let’s add the Face Recognition.

  1. First, select the board as evive.
  2. Next, click on the add extension button
  3. Once clicked you will be able to see all the extension available,
  4. Select  Face DetectionChoosing Face detection Extension

You will notice new blocks are being added under the same extension

Please remember that this extension requires an Internet connection in order to process images. Also, wait till models get loaded it might take a few moments to load.

What will you need

  1. A pc/laptop with a camera.
  2. PictoBlox.
  3. Internet connection.
  4. A webcam.

Writing the Script in PictoBlox

Now, that everything is ready. let’s start writing the script.

Adding sprite

Before we begin, let’s add our sprite into the project first.

  1. Click on add sprite button
  2. Add the square box spritesquare box sprite
  3. You can delete The Tobi sprit, simply right click on it and select delete from the drop-down.

Completing the script

Now select the Square box sprite to write the script.

  1. First, drag and drop the when flag clicked hat block to execute the program every time the green flag is clicked.
  2. Next, to turn the camera ON, use turn ON video on stage with 0% transparency block.Making Face Expression
  3. Next, we need to recognize the image. Thus, we now need to process the image projected on the stage. We will use the analyse image from () block and as we are using a camera on stage, we will choose the stage option from the drop-downMaking Face Expression
  4. Once the image is recognized, you can have all the data obtained from the image stored in the memory which you can use later on when and where required.
  5. Next, we need to add an outline to be marked around the face. Thus, in order to show that the face is recognized, we will move our square box to the location of our recognized face. We will be using go to x () and y () block from the Motion Palette for the same.
  6. Next, to move the box around the face, we need the X and Y position of the face. Thus, we will use the get () of face () block from the face detection palette, this block contains all the details including the size and the location of the face.Making Face Expression
  7. Drop each in the white spaces of the go to x () and y () block and select x-position from the first drop-down and y-position from the second drop-down.Making Face Expression
  8. Now that we have recognized the face and located its position it’s now time to recognize the expression of the face.
  9. We need the square box sprite to say out the expression of the face, thus drag and drop say () for () seconds block below the go to x () y () block.
  10. To recognize the expression we use get expression of face () block into the space given of the say block. This block gathers all the information of the face like age, gender, and expression. Making Face Expression
  11. Finally, if you wish to run the script forever, use the forever block from the Controls Palette.

With this our script is ready.Making Face Expression

You can download the script from here.

Click on the green flag button and wait for the script to recognize and display the emotion of a person on the stage.Expression Detection

If you wish to learn how to recognize the expression of multiple faces or how to use artificial intelligence and machine learning with PictoBlox, you can try out our artificial intelligence for kids course.


In conclusion, this tutorial demonstrated how you can use PictoBlox to recognize the expressions/emotions of a human face. We walked through the steps of setting up the software and writing the script in PictoBlox to recognize the expression of a person. We also learned how to use the face detection extension of PictoBlox and how to use the motion, control, and face detection palette blocks to create the script. With this, we have successfully developed an expression recognition machine using PictoBlox.

Table of Contents