Theory
Β 5. Object Detection
AI to identify objects from images. It also tells the location and size of the objects identified)
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 according to the known set of objects.
One of the applications of Object detection includes Self-driving vehicles which detect objects in real-time and act accordingly.
The object detection extension in PictoBlox allows you to detect the following 90 objects:
ID | OBJECT (PAPER) | SUPER CATEGORY |
1 | πΆββοΈ person | person |
2 | π²bicycle | vehicle |
3 | πcar | vehicle |
4 | πmotorcycle | vehicle |
5 | βοΈ airplane | vehicle |
6 | πbus | vehicle |
7 | πtrain | vehicle |
8 | πtruck | vehicle |
9 | π€boat | vehicle |
10 | π¦traffic light | outdoor |
Β
Accessing Object Detection in Block Coding
Following is the process to add Object Detection capability to the PictoBlox Project.
πOpenΒ PictoBloxΒ and create a new file.
π»Select the coding environment as appropriate Coding Environment.
βNext, click on theΒ Add ExtensionΒ button and add theΒ Object DetectionΒ extension
β¬οΈThe object detection models will be downloaded, which may take a few seconds to load.
β Once downloaded you will get a message saying βModel loaded successfullyβ.
π§© You can find the object detection blocks available in the project.
PictoBlox Blocks
π₯ turn () video on stage with () % transparencyΒ block controls the camera feed on the stage.
βοΈ The block enables or disables the automatic display of the box on object detection on the stage. This is useful when you want to see if the object detection happens during the analysis or not.
π 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.
πThe block analyzes the image and saves the face information locally, which can be accessed using other blocks.
πOnce you have analyzed the images, you can use the get # of objects block to get the number of objects recognized in the image.
πThe () of object () block reports the following attributes of the object: class, x position, y position, width, height, and confidence.
π€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.
π’The block returns the number of objects identified with the specified object class.
Create the program as shown below
Create the program as shown below
Working of the program
- π© When the flag is clicked:
- π¦ The bounding box is hidden.
- π The detection threshold is set to 0.8.
- πΌοΈ The stage image is analysed.
- π Setting up the loop:
- π― Sets a variable “Object” to 1.
- π Moves to coordinates (0,0).
- π Sets the sprite size to 100%.
- π£οΈ Speaking out the detection:
- πΎ Says the number of objects detected for 2 seconds.
- π Repeating for each object:
- βΎοΈ For the number of objects detected:
- π Sets the x position to that of the “Object”.
- π Sets the y position to that of the “Object”.
- π Sets the size to the width of the “Object”.
- π¨οΈ Says the class of the “Object” with its confidence level for 2 seconds.
- β Changes the “Object” variable by 1 to move to the next object.
- βΎοΈ For the number of objects detected:
Output of the program