OpenCV  4.1.0
Open Source Computer Vision
Creating Bounding boxes and circles for contours

Prev Tutorial: Convex Hull

Next Tutorial: Creating Bounding rotated boxes and ellipses for contours

Goal

In this tutorial you will learn how to:

Theory

Code

[block] [block] [block]

Explanation

The main function is rather simple, as follows from the comments we do the following:

[block] [block] [block] [block] [block] [block] [block] [block] [block]

The callback function does all the interesting job.

[block] [block] [block] [block] [block] [block] [block] [block] [block]

We found everything we need, all we have to do is to draw.

[block] [block] [block] [block] [block] [block] [block] [block] [block]

Result

Here it is:

Bounding_Rects_Circles_Source_Image.jpg
Bounding_Rects_Circles_Result.jpg