Detecting Object using Artificial Intelligence of PictoBlox

online AI course for kids
About This Tutorial
This tutorials shows how can you detect the number, size, position, and the type of object using the Object Detection Extension of PictoBlox
Tutorial Info

Introduction

In the future ahead us, the words AI, ML, and robots are going to be the common thing to be heard, they will be used everywhere from shopping malls to your home, so have you ever wonder how they will able to recognize the millions of different man-made objects, and millions of things that pre-exist in nature, the algorithms used for recognizing things already exist and the technology behind it is called are object detection.

So with the new object detection extension inside PictoBlox, we will be able to make scripts in which you can recognize objects from images as well as from the cameras, and with information associated with each of those objects, we will be able to make lots of cool projects.

Let’s begin.

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 Object Detectionobject 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.
  2. PictoBlox.
  3. Internet connection.
  4. A sample image(You can download the sample image from here).

    Baseball sample Image

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 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. Turn off the camera using the turn () video on stage with () transparency block. Choose OFF from the first drop-down.
  2. Let’s set up the Stage. Click on the upload backdrop option and select the baseball image which you have downloaded and place it on the stage.
  3. Next, select the Square box sprite, and let’s start making the script.
  4. First, drag and drop the when flag clicked hat block to execute the program every time the green flag is clicked.
  5. Next, let’s process the imagery stage. Add the analyze image from () the block below the when the flag is clicked block. Select Stage from the dropdown menu.
  6. Now, let’s create a variable to store the object count. Click on the Make a variable button inside the Variables palette. Make a variable with the name “Object” and click on ok.
  7. Add the set variable () as () block and set Object as 0.
  8. Now, as we need to detect all the objects, add a repeat until () block. Drag and drop an equal to block from the Operator Palette inside the hexagonal space of the repeat until block.
  9. Now to acquire the no of objects from the image use get # of objects block inside the first space of the equal to block and place the variable Object into the second empty space. The block get # of objects contains information on the number of objects that are detected from the image that has been processed.
  10. Next, let’s display the recognized objects. To display the properties of all detected objects one by one, we need to increment our variable by 1 each time we execute our control logic. Thus place change () to () block into the repeat until block.
  11. Next, set the size of the square box to accommodate the object detected, drag and drop the set size to () % block from Looks palette. To detect the width, add the () of object block inside it and choose width from the drop-down. This block contains all the information like x,y position, width, height class of the given object.
  12. Add the Object variable into the space given.
  13. Then we need to move our Square box to the location of the object, thus add go to x() y() block from Motion palette. Next, insert two () of object block and choose x position and y position from the respective blocks to obtain the X value and Y value of the object respectively.
  14. Finally, to display the class of recognized object, get the say () for () seconds block from the Looks palette and make it say the class of the detected object.

With this, the script is ready.

You can download the script from here.

Click on the flag button and let the script work its magic on image.object detection

You will observe that two objects are detected from this particular image first one being obviously a person and the other one being the sports ball. You can change the image on the backdrop and recognize objects from lots of different images.

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. Visit the link here to know more about the course.

[tutorialRelatedProjects]
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