Table of Contents

How to Build an AI Object Detection System in PictoBlox

AI-Object-Detection
Example Description
Learn how to create an AI Object Detection System in PictoBlox using the Object Detection extension. In this project, the webcam continuously analyses the surroundings, detects objects in real time, and creates clones of a sprite to highlight each detected object.

Introduction

Object detection is a computer vision technology that enables AI to identify and locate multiple objects within an image or video stream. In this project, PictoBlox uses the webcam to analyse the environment and detect different objects. For every detected object, a clone of the sprite is created and positioned accordingly, making it easy to visualise and identify objects in real time.

Setting Up the Stage / Sprite

  1. Open PictoBlox and create a new project.
  2. Delete the default Tobi sprite if desired, and add any sprite you would like to use for displaying detected objects.
  3. Click on Choose an Extension and add the Object Detection extension.
  4. Ensure your computer’s webcam is enabled.
  5. Hide the original sprite since only its clones will be used to represent detected objects.

Step-by-Step Block Coding Guide

Step 1: Initialise the Camera and Start Detection

  1. Add the When Green Flag Clicked block to begin the program.
  2. Hide the original sprite using the Hide block.
  3. Turn on the webcam using the Turn Video On block with 0% transparency.
  4. Place the entire detection process inside a Forever loop so that objects are continuously detected.

Step 2: Analyse the Camera Feed and Create Clones

  1. Use the Analyse Image from Camera block to process the live webcam feed.
  2. Broadcast a Delete Clones message to remove previously created clones before detecting new objects.
  3. Initialise an object’s variable to zero.
  4. Repeat until the total number of detected objects matches the value of the Objects variable.
  5. Increment the Objects variable by one.
  6. Create a clone of the sprite for every detected object.
  7. Add a short delay to ensure smooth detection and cloning.

Analyse the Camera Feed

Step 3: Delete Previous Clones

  1. Create a separate script using the When I Receive Delete Clones event.
  2. Use the Delete This Clone block so that all previously created clones are removed before new detections are displayed.
  3. This prevents duplicate or outdated object markers from remaining on the stage.

Delete Previous Clones

Step 4: Configure Each Clone

  1. Use the When I Start as a Clone block.
  2. Set the clone’s size based on the detected object’s width.
  3. Position the clone using the detected object’s X coordinate.
  4. Position the clone using the detected object’s Y coordinate.
  5. Show the clone on the stage.
  6. Display the detected object’s class name using the Say block.

Configure Each Clone

As a result, every detected object appears with its own correctly positioned and sized sprite that identifies what the AI has recognised.

Conclusion

The AI Object Detection System demonstrates how computer vision can be used to recognise and track multiple objects in real time using PictoBlox. By combining live camera analysis with sprite cloning, the project provides an interactive visualisation of detected objects and their positions. It is an excellent introduction to artificial intelligence, image processing, and computer vision concepts, while showcasing how AI can interpret and interact with the real world.