O'Reilly logo

Computer Vision with Python 3 by Saurabh Kapur

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Contour detection

In this section, we will see how to use the findContours() function in OpenCV. First let's see what the function returns. It returns three arrays: first is the input image array, the second is the contours found in the image, and the third is the hierarchy array. The hierarchy array stores the relation between the contours: for example, if one contour is within another contour, then they will have a parent-child relationship and this is stored in the hierarchy array. The findContours() function takes three arguments: the source image, contour retrieval mode, and contour approximation method.

The contour retrieval mode tells us about the kind of hierarchy of contours: for example, in RETR_LIST, parents and child are considered ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required