-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCirclePolygon.py
More file actions
23 lines (19 loc) · 923 Bytes
/
CirclePolygon.py
File metadata and controls
23 lines (19 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import cv2
import numpy as np
import matplotlib.pyplot as plt
def ShowWithMatplotlib(img, title):
imgRGB=img[:, :, ::-1]
plt.imshow(imgRGB)
plt.title(title)
plt.show()
colors={'blue':(255, 0, 0), 'green':(0, 255, 0), 'red':(0, 0, 255), 'yellow':(0, 255, 255),
'magenta':(255, 0, 255), 'cyan':(255, 255, 0), 'white':(255, 255, 255), 'black':(0, 0, 0),
'gray':(125, 125, 125), 'rand':np.random.randint(0, high=256, size=(3,)).tolist(),
'dark_gray':(50, 50, 50), 'light_gray':(220, 220, 220)}
image=np.zeros((640, 640, 3), dtype="uint8")
image.fill(255)
pts=np.array([(600, 320), (563, 460), (460, 562), (320, 600), (180, 563), (78, 460), (40, 320), (77, 180), (179, 78), (319, 40),
(459, 77), (562, 179)])
pts=pts.reshape((-1, 1, 2))
cv2.polylines(image, [pts], True, colors['green'], 5)
ShowWithMatplotlib(image, 'polygon with the shape of a circle using 12 points')