To identify circles, ellipses or in general any shape in which the pixels are connected we use the
SimpleBlobDetector() function of OpenCV. In non-technical terms, a blob is understood as a thick liquid drop. Here, we are going to call all shapes as a blob. Our task is to detect and recognize whether the blob is a circle or not.
OpenCV provides a convenient way to detect blobs and filter them based on different characteristics. There are various different parameters that control the identification process and the results. The important parameters used for this project are:
- Filter by Area – This is to avoid any identification of any small dots present in the image that can be wrongly detected as a circle.
- Filter by Circularity – This helps us to identify, shapes that are more similar to a circle.
Circularity = .
A true circle has circularity of 1, a square has a circularity near 78%.
- Filter by Convexity – Concavity in general, destroys the circularity.More is the convexity, the closer it is to a close circle.
- Filter by Inertia – Objecs similar to a circle has larger inertial.E.g. for a circle, this value is 1, for an ellipse it is between 0 and 1, and for a line it is 0. To filter by inertia ratio, set filterByInertia = 1, and set, 0 <= minInertiaRatio <= 1 and maxInertiaRatio (<=1 ) appropriately.
Below is the code for identifying Circles:
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Python Bokeh - Plotting Ellipses on a Graph
- OpenCV - Facial Landmarks and Face Detection using dlib and OpenCV
- Transition from OpenCV 2 to OpenCV 3.x
- Image resizing using Seam carving using OpenCV in Python
- Negative transformation of an image using Python and OpenCV
- Log transformation of an image using Python and OpenCV
- OpenCV Python Program to analyze an image using Histogram
- Python Program to detect the edges of an image using OpenCV | Sobel edge detection method
- Reading an image in OpenCV using Python
- Python | Detect corner of an image using OpenCV
- Image Pyramid using OpenCV | Python
- Python | Image blurring using OpenCV
- Image Resizing using OpenCV | Python
- Image Translation using OpenCV | Python
- Image Registration using OpenCV | Python
- Python | Detect Polygons in an Image using OpenCV
- Image Steganography using OpenCV in Python
- Create Local Binary Pattern of an image using OpenCV-Python
- Point Processing in Image Processing using Python-OpenCV
- Set Countdown timer to Capture Image using Python-OpenCV
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.