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

Activity 2: Face Tracker

One of the most fascinating activities is face tracking, in which the Quarky can detect a face and move its head in the same direction as yours. How intriguing it sounds, so let’s get started with the coding for a face-tracking robot.

Logic

  1. If the face is tracked at the center of the stage, the servo angle should be straight.
  2. As the face moves to the left side, the servo angle will also move to the left side.
  3. As the face moves to the right side, the servo angle will also move to the right side.

Let’s Code!

  1. Open PictoBlox and create a New File.
  2. Select the coding environment as Block Coding.
  3. Drag and drop the when green flag clicked block from the Events palette.
  4. Then, add a turn () video on stage with () % transparency block from the Face Detection extension and select on from the drop-down. This will turn on the camera.
  5. Click on the green flag and your camera should start. Make sure this part is working before moving further.
  6. Add the forever block below turn () video on stage with () % transparency from the Control palette.
  7. Inside the forever block, add an analyse image from () block. This block will analyze the face the camera detects. Select camera from the dropdown.
  8. To change the position of your servo add the set servo on () to () angle below analyse image from ().
  9. Here comes the logical part as in this, the position of the face on the stage matters a lot. Keeping that in mind, we will add the division () / () block from the Operator palette into the scripting area.
  10. Place  get () of face () at the first place of addition () + (), and 3 at the second place. From the dropdown select X position.
  11. Next, drag the addition ()+() block inside the set servo () to () angle block. Put 90 in the first space and put the ()/() block in the second space.
  12. Save the file with the name Face Tracking Robot.

Servo Block Explained

  1. At the center of the stage, we will get the X position value which is zero.
  2. As we move to the left side the X position value will give you the negative value and as we move to the right side the X position value will give you the positive value.
  3. The x position value is divided by 3 which gives precise positioning.
  4. To set the servo angle at 90 when the face is at the center of the stage we have added 90 to the X position value.
  5. As we move to the left side the servo angle value will get decreased as the X position value is going in negative.
  6. As we move to the right side the servo angle value will get increased as the X position value is going in positive.

Testing

Our next step is to check whether it is working right or not. Whenever your face will come in the front of the camera, it should detect it and as you move to the right or left, the head of your robot should also move accordingly.

Assignment

Before you move on to the next lesson, a small assignment awaits you!

You must upload the PictoBlox program you created in this activity to the website. Submitting the assignment is a must in order to receive the certificate after completing the course.

Follow the steps below to upload your assignment:

  1. Click on Browse.
  2. Search and Select your saved Project file(.sb3) and Click Open.
  3. Click on Upload to submit the assignment.
evive Alert
The file type allowed is the SB3 file generated from the PictoBlox program. The maximum file size allowed is 5 MB.

Good luck!