-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdraw.py
41 lines (33 loc) · 849 Bytes
/
draw.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# pylint:disable=no-member
import cv2 as cv
import numpy as np
blank = np.zeros((500, 500, 3), dtype="uint8")
cv.imshow("Blank", blank)
# 1. Paint the image a certain colour
blank[200:300, 300:400] = 0, 0, 255
cv.imshow("Green", blank)
# 2. Draw a Rectangle
cv.rectangle(
blank, (0, 0), (blank.shape[1] // 2, blank.shape[0] // 2), (0, 255, 0), thickness=-1
)
cv.imshow("Rectangle", blank)
# 3. Draw A circle
cv.circle(
blank, (blank.shape[1] // 2, blank.shape[0] // 2), 40, (0, 0, 255), thickness=-1
)
cv.imshow("Circle", blank)
# 4. Draw a line
cv.line(blank, (100, 250), (300, 400), (255, 255, 255), thickness=3)
cv.imshow("Line", blank)
# 5. Write text
cv.putText(
blank,
"Hello, my name is Nilooooo!!!",
(0, 225),
cv.FONT_HERSHEY_TRIPLEX,
1.0,
(0, 255, 0),
2,
)
cv.imshow("Text", blank)
cv.waitKey(0)