Day 8: Introduction to Object Detection

Lesson Description

Learn the steps to assemble the vertical robot. understand the process of creating a hand detection system. explore the components and coding needed for hand detection. apply knowledge in a hands-on activity by making a Robo-Pet. develop practical skills through engaging and interactive learning.

Introduction

Object detection is used to locate and identify multiple objects in digital photographs. It is a computer vision technique that helps to detect objects as well as classify them. The object class may appear once or several times in the image. For example, in the following image, object detection assists us to locate the objects and classify them accordingly to the known set of objects.

Object Detection

One of the applications of Object detection includes Self-driving vehicles which detect objects in real-time and act accordingly.

The Object Detection extension of the PictoBlox Machine Learning Environment is used to detect particular targets present in a given picture.

Image Classification vs Object Detection

There is always confusion between image classification and object detection. Let’s look at it.

Image Classification deals with categorizing images based on their characteristics. These characteristics are observed and extracted from the images by the training model. Once extracted, these characteristics can be used as a set of rules to classify previously unseen data. Let’s understand this with an example.

Observe these images:

Image 1:

Image 2:

Thanks to the human brain, it’s no big feat for us to make out that Image 1 is that of a cat and Image 2 is that of a dog. However, computers do not possess the intelligence we do, hence we need to train them to recognize such images. The same is true for any scenario where we want the computer to categorize data.

Now observe this image:

Again, our human brain doesn’t break a sweat in making out that there are two animals in the picture, one cat, and one dog. However, a computer trained to recognize cats and dogs separately will not be able to make complete sense of the image. This is where object detection comes into play.

The biggest characteristic of Object Detection is the fact that it takes the location of objects into consideration.  Object Detection algorithms can detect not only the class of the target objects but also their location.

Hence, Object Detection is extremely useful when there are multiple objects present in an image.

Accessing Object Detection in Block Coding

Following is the process to add Object Detection capability to the PictoBlox Project.

  1. Open PictoBlox and create a new file.
  2. Select the coding environment as appropriate Coding Environment.
  3. Next, click on the Add Extension button and add the Object Detection extension.
  4. The object detection models will be downloaded, which may take a few seconds to load.
    Downloading Models
  5. Once downloaded, you will get a message saying “Model loaded successfully”.
  6. You can find the object detection blocks available in the project.

PictoBlox Blocks

  1. turn () video on stage with () % transparency block controls the control the camera feed on the stage.
  2. This block is used to set the threshold for the confidence (accuracy) of object detection, 0 being low confidence and 1 being high confidence. With the threshold value, you can set the level of confidence required for object detection.
  3. Once you have analyzed the images, you can use the get # of objects block to get the number of objects recognized in the image.
  4. The () of object () block reports the following attributes of the object: class, x position, y position, width, height, and confidence.
  5. The is () detected? block checks whether the selected class has been detected or not. If the class is detected, then the block returns true; else, false.
  6. The block returns the number of objects identified with the specified object class.

Activity: Object Detector

Set the Environment

  1. Open the PictoBlox.
  2. Select Block Coding as your coding environment, ignore it if already selected.

Adding Up the Extension

As you know, we are making a script to recognize the objects so let’s add the Object Detection extension.

Writing the Script in PictoBlox

  1. First, drag and drop the when flag clicked hat block to execute the program every time the green flag is clicked.
  2. Get turn () video on the stage with ()% transparency block from Object Detection palette below when flag clicked. Select on to start the camera.
  3. add set detection threshold to () below  () bounding box. Set the threshold value to 0.4.
  4. Add a forever block from the Control palette.
  5. Snap an analyse image from () and select Camera from the dropdown.
  6. Snap if () then block below the analyse image from() block.
  7. Place the is book detected block from the Object Detection extension in the horizontal space of the if block. Add say () block in the branches of the if () then block.

Testing

Click the green flag to run the script.

Table of Contents