-
Notifications
You must be signed in to change notification settings - Fork 0
/
pypbl.py
34 lines (26 loc) · 841 Bytes
/
pypbl.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
import cv2
import pickle
width, height = 107 ,46
try:
with open('CarParkingPos', 'rb') as f:
posList = pickle.load(f)
except:
posList = []
def mouseClick(event,x,y,flags,param):
if event == cv2.EVENT_LBUTTONDOWN:
posList.append((x,y))
if event == cv2.EVENT_RBUTTONDOWN:
for i, pos in enumerate(posList):
x1, y1 = pos
if x1 < x and x < x1+width and y1 < y and y < y+height:
posList.pop(i)
with open('CarParkingPos','wb') as f:
pickle.dump(posList,f)
while True:
img = cv2.imread("carParkimg.png")
for pos in posList:
cv2.rectangle(img,pos,(pos[0]+width,pos[1]+height),(255,0,255),2)
cv2.imshow("Image",img)
cv2.setMouseCallback("Image",mouseClick)
cv2.waitKey(1)
finalist = poslist