-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path104openCVDraw.py
More file actions
33 lines (21 loc) · 1003 Bytes
/
104openCVDraw.py
File metadata and controls
33 lines (21 loc) · 1003 Bytes
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
import cv2
print("OpenCV version:")
print(cv2.__version__)
img = cv2.imread("nomadProgramerIcon.png")
print("width: {} pixels".format(img.shape[1]))
print("height: {} pixels".format(img.shape[0]))
print("channels: {}".format(img.shape[2]))
cv2.imshow("nomadProgramer", img)
(b, g, r) = img[0, 0]
print("Pixel at (0, 0) - Red: {}, Green: {}, Blue: {}".format(r,
g, b))
dot = img[50:100, 50:100]
img[50:100, 50:100] = (0, 0, 255)
cv2.rectangle(img, (150, 50), (200, 100), (0, 255, 0), 5) # 픽셀 시작, 끝, 색상, 선의 굵기
cv2.circle(img, (275, 75), 25, (0, 255, 255), -1) # 중심의 위치, 반지름, 색상, -1->전체 채우기
cv2.line(img, (350, 100), (400, 100), (255, 0, 0), 5) # 픽셀 시작, 끝, 색상, 굵기
cv2.putText(img, 'creApple', (450, 100), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 4)
# 픽셀 시작(좌측 하단), 폰트, 폰트의 크기, 색상, 폰트의 굵기
cv2.imshow("nomadProgramer - draw", img)
cv2.waitKey(0)
cv2.destroyAllWindows()