Welcome to Raspbot repository
5.Drawing rectangle circle
1. Drawing rectangle
Rectangle(img,pt1,pt2,color,thickness=None,lineType=None,shift=None)
Parameter Description
l img: Canvas or carrier image.
l pt1, pt2:required parameters. Represents the vertices and diagonal vertices, that is the upper left corner and lower right corner of the rectangle.
l color: required parameters, be used to set color of rectangle.
l thickness: optional parameter, be used to set the width of the rectangle side, when the value is negative, it means to fill the rectangle.
l lineType:optional parameter, be used to set the type of line segment, 8 (8 adjacent connection line-default), 4 (4 adjacent connection line) and cv2.LINE_AA are anti-aliased.
2. Drawing circle
cv2.circle(img, center, radius, color[,thickness[,lineType]])
Parameter Description
l img: canvas or carrier image
l center: the coordinates of the center of the circle, the format: (50,50)
l radius: radius
l color: color
l Thickness: be used to set the width of the circle side, when the value is -1, it means to fill the circle.
l lineType: type of line segment. The default is 8, the connection type description is shown in the table below.
Parameter | Description |
cv2.FILLED | fill |
cv2.LINE_4 | 4 Connection Type |
cv2.LINE_8 | 8 Connection Type |
cv2.LINE_AA | Anti-aliasing, this parameter will make the line smoother |
3. Draw ellipse
cv2.ellipse(img, center, axes, angle, StartAngle, endAngle, color[,thickness[,lineType]])
Parameter Description
l center: Center point of ellipse(x, x)
l axes: hort radius and long radius, (x, x)
l angle: the angle of counterclockwise rotation
l StartAngle: The angle of the starting angle of the arc
l endAngle: The angle of the end angle of the arc
l Img, color: canvas or carrier image and color.
# The fifth parameter refers to the angle at which drawing starts counterclockwise, and the sixth parameter refers to the angle at which drawing ends counterclockwise
# If the fourth or fifth parameters are added with symbols, the opposite direction is indicated, that is, the clockwise direction.
4. Draw polygon
cv2.polylines(img,[pts],isClosed, color[,thickness[,lineType]])
l pts: Vertex of polygon
l isClosed: Whether closed or not. (True/False)
l Other parameters refer to the parameters of drawing circle
Code path:
/home/pi/Yahboom_Project/Raspbot/1.OpenCV_course/03IP_Draw_text_line_segments/ 05_Drawing rectangle_circle.ipynb
|
|
After running the following program, a picture will be displayed in the jupyterLab control interface, as shown below.