Sitemap
TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

Performing Image Annotation using Python and OpenCV

6 min readApr 27, 2023

--

Press enter or click to view image in full size
Photo by Héctor J. Rivas on Unsplash

One of the common tasks in deep learning is object detection, a process in which you locate specific objects in a given image. An example of object detection is detecting cars in an image, where you could tally the total number of cars detected in an image. This might be useful in cases where you need to analyze the traffic flow at a specific junction.

In order to train a deep learning model to detect specific objects, you need to supply your model with a set of training images, with the coordinates of the specific object in the images all mapped out. This process is known as image annotation. Image annotation assigns labels to objects present in an image, with the objects all marked out.

In this article, I will show you how to use Python and OpenCV to annotate your images — you will use your mouse to mark out the object that you are annotating and the application will draw a bounding rectangle around the object. You can then see the coordinates of the object you have mapped out and optionally save it to a log file.

Displaying an Image using OpenCV

First, create a text file and name it as bounding.py. Then, populate it with the following statements:

--

--

Wei-Meng Lee
Wei-Meng Lee

Written by Wei-Meng Lee⁠

ACLP Certified Trainer | Blockchain, Smart Contract, Data Analytics, Machine Learning, Deep Learning, and all things tech (http://calendar.learn2develop.net).

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.