Back to Course

Class 6 - Coding, AI & Robotics Course

0% Complete
0/0 Steps
  1. Coding

    Session 1: Introduction to Coding
    3 Topics
  2. Session 2: Backdrop, Costume, and Animation
    3 Topics
    |
    1 Quiz
  3. Session 3: Basics of Algorithm and Flowchart
    3 Topics
    |
    1 Quiz
  4. Session 4: Basics of Pseudocode
    3 Topics
    |
    1 Quiz
  5. Session 5: Getting Started with Quarky
    3 Topics
    |
    1 Quiz
  6. Session 6: Variables: The Multitaskers
    4 Topics
    |
    1 Quiz
  7. Session 7: Arithmetic Operators
    4 Topics
    |
    1 Quiz
  8. Session 8: Conditional Statements
    3 Topics
    |
    1 Quiz
  9. Session 9: Logical Operators
    4 Topics
    |
    1 Quiz
  10. Session 10: Nested Conditional Statements
    2 Topics
    |
    1 Quiz
  11. Session 11: Loops
    3 Topics
    |
    1 Quiz
  12. Session 12: Touch Based Piano
    2 Topics
  13. Session 13: Criterial in Loops
    5 Topics
    |
    1 Quiz
  14. Session 14: Catch the Fruit Game - Part 1
    2 Topics
  15. Session 15: Catch the Fruit Game - Part 2
    2 Topics
    |
    1 Quiz
  16. Artificial Intelligence
    Section 16: Introduction to Artificial Intelligence
    3 Topics
    |
    1 Quiz
  17. Session 17: Basics of Face Detection
    2 Topics
    |
    1 Quiz
  18. Session 18: Face Expression Detection
    2 Topics
    |
    1 Quiz
  19. Session 19: Mimic Face with Quarky
    1 Topic
  20. Session 20: Face Filter - Part 1
    2 Topics
  21. Session 21: Face Filter - Part 2
    2 Topics
  22. Robotics
    Session 22: Basics of Robotics
    2 Topics
    |
    1 Quiz
  23. Session 23: Wirelessly Controlled Robot
    2 Topics
  24. Session 24: Introduction to Sensors
    3 Topics
    |
    1 Quiz
  25. Session 25: Introduction to Actuators
    3 Topics
    |
    1 Quiz
  26. Session 26: Face Tracking with Robot
    2 Topics
  27. Session 27: Obstacle Avoidance Robot - Part 1
    3 Topics
  28. Session 28: Obstacle Avoidance Robot - Part 2
    2 Topics
    |
    1 Quiz
  29. Session 29: Edge Detector Robot - Part 1
    3 Topics
  30. Session 30: Edge Detector Robot - Part 2
    2 Topics
    |
    1 Quiz
  31. Capstone Project
    Capstone Project
Lesson Progress
0% Complete

Face Detection Blocks in PictoBlox

The Face Detection extension in PictoBlox has blocks dedicated to face detection.

Let’s first add the extension to our project:

evive Alert
Alert: Make sure you have an active internet connection to load the model.
  1. Create a new project in PictoBlox.
  2. Next, click on the Add Extension button and add the Face Detection extension.
    Face Detection Extension
  3. The face detection models will be downloaded which may take few seconds to load.
    Downloading Models
  4. Once downloaded you will get a message saying “Model loaded successfully”.

Facial Detection Block

To execute face detection, we will use analyse image from () block.

analyse image from ()

You can input the image in the following ways:

  1. Camera feed
  2. Stage

This block. analyses the image and saves the face information locally, which can be accessed using other blocks similar to computer vision.

You have to run this block every time you want to analyze a new image from the camera or stage.

Controlling camera feed

You can control the camera feed on the stage using turn () video on stage with () % transparency block.

turn () video on stage with () % transparency

You can change the following parameters of the block:

  1. Camera state:
    1. OFF – The video feed on the stage will stop.
    2. ON – The video feed on the stage will start.
    3. ON flipped – The video feed on the stage will start with the video mirrored. So, your right hand will be shown as left hand and vice versa.
  2. Transparency: This parameter makes the video translucent. O is defined as the camera feed will be shown on the stage and 100 is the video will fade out completely from the stage.

Edit the parameter and try out this block yourself.

Example – Analyzing Image on Stage

In this topic, we will analyze the following image:

Boy and Girl

  1. Download the image from here: https://learn.edustream.ae/wp-content/uploads/2023/09/Boy-and-Girl.jpg
  2. In PictoBlox, turn off the camera using turn () video on stage with () % transparency block, and choosing the options as shown. Click on the block to execute it.
    Hide camera
  3. Next upload it as backdrop.
    Upload Backdrop
  4. Select Tobi sprite and hide it.
  5. You will find the stage like this:
    Face detection stage
  6. Drag analyse image from () block, change the feed as stage and click on the block to analyze the image.
    analyse stage
  7. Now we will see what things we get when we analyze images in face detection.

Get # faces

Once you have analyzed the images, you can use the get # faces block to get the number of faces recognized in the image.

get # faces

For the image being analyzed, you will get 2.

Get expression of face ()

get expression of face () ssion of face ()

The get expression of face () block reports the recognized expression of the selected face. If the face selected is not detected then it reports NULL.

Emotion

Example: For the first face in the image being analyzed, the expression is Happy.

Is expression of face () ()

is expression of face () ()

The is expression of face () () block checks whether the selected face has a particular emotion or not. If the emotion matches, then the block returns true, else false.

E.g., for face 1 in the image, the emotion is Happy.

is expression 2

Get () of face ()

get () of face ()

The get () of face () block reports the following attributes of the image:

  1. X position: X coordinate of the center of the image on the stage
  2. Y position: Y coordinate of the center of the image on the stage
  3. Width: Width of the face
  4. Height: Height of the face
evive Notes Icon
Note: This block reports an accurate position when the image is analyzed from stage or camera feed.

Using this block you can make the bounding box for the face like this:

We will learn how to do the same in the next topic by making a face detector.

Get () position of landmark () of face ()

get () of landmark () of face ()

The get () position of landmark () of face () block reports the x and y position of the selected landmark (number from 1 to 68) of the selected face.

Using this block you can draw the landmark points on the stage like this:

Face Landmarks

Conclusion

We have looked at the various blocks to analyze images of faces and get key information out of them. In the next lesson, will see how to draw the bounding box on the detected face and report their expressions.

Boy Face Expression