How to use cvcircle In Python
To draw a circle in Opencv Python
Syntax: cv2.circle(image, center_coordinates, radius, color, thickness)
Parameters:
- image: It is the image on which line is to be drawn.
- center_coordinates: It is the center coordinates of circle. The coordinates are represented as tuples of two values i.e. (X coordinate value, Y coordinate value).
- radius: It is the radius of circle.
- color: It is the color of line to be drawn. For BGR, we pass a tuple. eg: (255, 0, 0) for blue color.
- thickness: It is the thickness of the line in px.
Return Value: It returns an image.
Example: Here, we will draw a circle in Opencv Python. In this, we will pass center_coordinates and radius where the center coordinate is represented as tuples of two values of X-coordinate and Y-coordinate values.
Python3
import cv2 image = cv2.imread( 'geekslogo.png' ) overlay = image.copy() # A filled circle cv2.circle(overlay, ( 250 , 250 ), 70 , ( 15 , 75 , 50 ), 20 ) alpha = 0.4 # Transparency factor. # Following line overlays transparent rectangle # over the image image_new = cv2.addWeighted(overlay, alpha, image, 1 - alpha, 0 ) cv2.imshow( "some" , image_new) cv2.waitKey( 0 ) cv2.destroyAllWindows() |
Output:
How to create a semi transparent shape Python-OpenCV
In this article, we will see how to create a semi-transparent shape python OpenCV.
Sometimes we need transparency in our outputs. It gives our outputs their own unique style. Today, we will see how you can do it easily with OpenCV python. Here, we are going to cover 3 different methods of shape and they are:
- Using Rectangular shape.
- Using Line.
- and, Using Circle.
Note: The concept will be the same for any other shape or image.