Book Image

OpenCV 3.0 Computer Vision with Java

By : Daniel Lelis Baggio
Book Image

OpenCV 3.0 Computer Vision with Java

By: Daniel Lelis Baggio

Overview of this book

Table of Contents (15 chapters)
OpenCV 3.0 Computer Vision with Java
About the Author
About the Reviewers

Contour finding

When dealing with the binary images removed from the background, it is important to transform pixels into useful information, such as by grouping them into an object or making it very clear for the user to see. In this context, it is important to know the concept of connected components, which are a set of connected pixels in a binary image, and OpenCV's function used to find its contours.

In this section, we will examine the findContours function, which extracts contours of connected components in an image as well as a helper function that will draw contours in an image, which is drawContours. The findContours function is generally applied over an image that has gone through a threshold procedure as well as some canny image transformation. In our example, a threshold is used.

The findContours function has the following signature:

public static void findContours(Mat image,
                java.util.List<MatOfPoint> contours,
                Mat hierarchy,