OpenCV
3.4.0
Open Source Computer Vision
|
In this tutorial you will learn how to:
This tutorial code's is shown lines below. You can also download it from here
The main function is rather simple, as follows from the comments we do the following:
thresh_callback
is necessary to display the "Contours" window simultaniously with the "Source" window. The callback function thresh_callback
does all the interesting job.
threshold_output
the threshold of the grayscale picture (you can check out about thresholding here). contour
and hierarchy
. For every found contour we now apply approximation to polygons with accuracy +-3 and stating that the curve must me closed.
After that we find a bounding rect for every polygon and save it to boundRect
.
At last we find a minimum enclosing circle for every polygon and save it to center
and radius
vectors.
We found everything we need, all we have to do is to draw.
Here it is: