Object Detection in the Images

Learn to detect objects present in the images using the Azure Computer Vision service.

We'll cover the following

Introduction

In this lesson, we’re going to build a script to detect objects in an image using the Computer Vision API. The Computer Vision API detects the objects in an image and returns the bounding-boxthe co-ordinates of the objects present in the image. This differs from generating the tags for the image because the tags are generated for contextual terms too (like indoor, outdoor, etc.) which cannot be represented using the bounding-boxes.

Implementation

We’ll be using the detect_objects() function from the ComputerVisionClient class. This function accepts the URL of an image and helps to detect all the objects with their corresponding locations from an image. The response is in the JSON format and contains the objects identified with their location coordinates and the confidence score with which these objects are identified from the image. If an error occurs on the computer vision end, this function will return an error code with an error message.

Later in the lesson, we’ll also explore the detect_objects_in_stream() function. This function works the same way that detect_objects() works. The only difference is that the detect_objects_in_stream() function accepts an image in bytes format. So, we can read the image from the local machine and pass the image data to this function to identify the objects present in the image.

Now let’s move on to the implementation of this functionality.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy