In this tutorial, I will show you how to draw a circle in OpenCV.
OpenCV comes with lots of built-in functions that make our life easier especially when we are working on image processing.
And there is a function called circle in OpenCV which is used to draw a circle.
This function takes following parameters:
1. Image: Takes an image object
2. Center: Center point coordinates
3. Radius: Radius of the circle
4. Color: Takes color in BGR format
5. Thickness: By default set to 1 (optional)
6. Line Type: By default set to 8-connected.It can also be LINE_AA or 4-connected (Optional)
7. Shift: Shifts fractional bits in the point coordinates of center and radius (Optional)
Especially when we are creating closed shapes. Thickness plays an important role. Here if the negative thickness is passed in this function or any other function which creates a closed shape(rectangle, polygon, etc). Then it creates a filled shape (filled with color).
Negative Thickness
Positive Thickness
Anti Aliased Circle
Program
#import cv2 moduleimport cv2 as cvimg = cv.imread("nature.jpg")height,width= img.shape[0:2]#Hollow Circleimg = cv.circle(img,(width/2,height/2),100,(255,145,88),10)#Filled Circle#img = cv.circle(img,(width/2,height/2),100,(255,145,88),-1)#AntiAliased Curve#img = cv.circle(img,(width/2,height/2),250,(255,145,88),10,cv.LINE_AA)cv.imshow('Circle',img)cv.waitKey(0)cv.destroyAllWindows()
Thanks for reading 🙂 🙂
Comments
Post a Comment