Reader small image

You're reading from  Mastering OpenCV 4 with Python

Product typeBook
Published inMar 2019
Reading LevelExpert
PublisherPackt
ISBN-139781789344912
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Alberto Fernández Villán
Alberto Fernández Villán
author image
Alberto Fernández Villán

Alberto Fernndez Villn is a software engineer with more than 12 years of experience in developing innovative solutions. In the last couple of years, he has been working in various projects related to monitoring systems for industrial plants, applying both Internet of Things (IoT) and big data technologies. He has a Ph.D. in computer vision (2017), a deep learning certification (2018), and several publications in connection with computer vision and machine learning in journals such as Machine Vision and Applications, IEEE Transactions on Industrial Informatics, Sensors, IEEE Transactions on Industry Applications, IEEE Latin America Transactions, and more. As of 2013, he is a registered and active user (albertofernandez) on the Q&A OpenCV forum.
Read more about Alberto Fernández Villán

Right arrow

An introduction to contours

Contours can be seen as a curve joining all the points along the boundary of a certain shape. As they define the boundary of the shape, an analysis of these points can reveal key information for shape analysis and object detection and recognition. OpenCV provides many functions to properly detect and process contours. However, before diving into these functions, we are going to see the structure of a sample contour. For example, the following function simulates detecting a contour in a hypothetical image:

def get_one_contour():
"""Returns a 'fixed' contour"""

cnts = [np.array(
[[[600, 320]], [[563, 460]], [[460, 562]], [[320, 600]], [[180, 563]], [[78, 460]], [[40, 320]], [[77, 180]], [[179, 78]], [[319, 40]], [[459, 77]], [[562, 179]]], dtype=np.int32)]
return cnts

As you can see, a contour is an array composed...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Mastering OpenCV 4 with Python
Published in: Mar 2019Publisher: PacktISBN-13: 9781789344912

Author (1)

author image
Alberto Fernández Villán

Alberto Fernndez Villn is a software engineer with more than 12 years of experience in developing innovative solutions. In the last couple of years, he has been working in various projects related to monitoring systems for industrial plants, applying both Internet of Things (IoT) and big data technologies. He has a Ph.D. in computer vision (2017), a deep learning certification (2018), and several publications in connection with computer vision and machine learning in journals such as Machine Vision and Applications, IEEE Transactions on Industrial Informatics, Sensors, IEEE Transactions on Industry Applications, IEEE Latin America Transactions, and more. As of 2013, he is a registered and active user (albertofernandez) on the Q&A OpenCV forum.
Read more about Alberto Fernández Villán