working on code
This commit is contained in:
parent
0c62afdbe1
commit
45ce7aa935
Binary file not shown.
@ -5,30 +5,6 @@ import numpy as np
|
|||||||
from pygame import mixer
|
from pygame import mixer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def display(length):
|
|
||||||
if length == 1:
|
|
||||||
|
|
||||||
onestar = cv2.imread('src/images/*.png')
|
|
||||||
outDoor[220:304, 54:214] = onestar
|
|
||||||
elif length == 2:
|
|
||||||
twostar = cv2.imread('src/images/**.png')
|
|
||||||
outDoor[220:304, 54:214] = twostar
|
|
||||||
|
|
||||||
elif length == 3:
|
|
||||||
threestar = cv2.imread('src/images/***.png')
|
|
||||||
outDoor[220:304, 54:214] = threestar
|
|
||||||
|
|
||||||
elif length == 4:
|
|
||||||
fourstar = cv2.imread('src/images/****.png')
|
|
||||||
outDoor[220:304, 54:214] = fourstar
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def alert():
|
def alert():
|
||||||
mixer.init()
|
mixer.init()
|
||||||
alert = mixer.Sound('src/noises/beep-07.wav')
|
alert = mixer.Sound('src/noises/beep-07.wav')
|
||||||
@ -53,10 +29,8 @@ def click_event(event, x, y, flags, param):
|
|||||||
alert()
|
alert()
|
||||||
elif 620 <= y <= 703 and 468 <= x <= 734:
|
elif 620 <= y <= 703 and 468 <= x <= 734:
|
||||||
print('open gate')
|
print('open gate')
|
||||||
global a
|
global wait_notification
|
||||||
a = datetime.datetime.now()
|
wait_notification = 1
|
||||||
global globalna
|
|
||||||
globalna = 1
|
|
||||||
elif 620 <= y <= 703 and 754 <= x <= 945:
|
elif 620 <= y <= 703 and 754 <= x <= 945:
|
||||||
print('listen')
|
print('listen')
|
||||||
elif 620 <= y <= 703 and 965 <= x <= 1173:
|
elif 620 <= y <= 703 and 965 <= x <= 1173:
|
||||||
@ -67,11 +41,11 @@ def click_event(event, x, y, flags, param):
|
|||||||
out.release()
|
out.release()
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
|
||||||
|
|
||||||
def click_event2(event, x, y, flags, param):
|
def click_event2(event, x, y, flags, param):
|
||||||
if event == cv2.EVENT_LBUTTONDOWN:
|
if event == cv2.EVENT_LBUTTONDOWN:
|
||||||
global displayString
|
global displayString
|
||||||
|
|
||||||
|
|
||||||
if 348 <= y <= 370 and 59 <= x <= 86:
|
if 348 <= y <= 370 and 59 <= x <= 86:
|
||||||
print("1 outdoor")
|
print("1 outdoor")
|
||||||
|
|
||||||
@ -116,7 +90,6 @@ def click_event2(event, x, y, flags, param):
|
|||||||
print("* outdoor")
|
print("* outdoor")
|
||||||
displayString = displayString + '*'
|
displayString = displayString + '*'
|
||||||
print(displayString)
|
print(displayString)
|
||||||
if 472 <= y <= 495 and 100 <= x <= 128:
|
|
||||||
print("0 outdoor")
|
print("0 outdoor")
|
||||||
displayString = displayString + '0'
|
displayString = displayString + '0'
|
||||||
print(displayString)
|
print(displayString)
|
||||||
@ -125,13 +98,11 @@ def click_event2(event, x, y, flags, param):
|
|||||||
displayString = displayString + '#'
|
displayString = displayString + '#'
|
||||||
print(displayString)
|
print(displayString)
|
||||||
|
|
||||||
|
display_work(len(displayString))
|
||||||
display(len(displayString))
|
|
||||||
|
|
||||||
|
|
||||||
def display(length):
|
def display_work(length):
|
||||||
global displayString
|
global displayString
|
||||||
global count
|
|
||||||
if length == 1:
|
if length == 1:
|
||||||
onestar = cv2.imread('src/images/*.png')
|
onestar = cv2.imread('src/images/*.png')
|
||||||
outDoor[220:304, 54:214] = onestar
|
outDoor[220:304, 54:214] = onestar
|
||||||
@ -145,42 +116,75 @@ def display(length):
|
|||||||
|
|
||||||
elif length == 4:
|
elif length == 4:
|
||||||
|
|
||||||
if displayString == "1234":
|
if displayString == "1234":
|
||||||
print("dobre haslo")
|
goodpass = cv2.imread('src/images/goodpass.png')
|
||||||
goodpass = cv2.imread('src/images/goodpass.png')
|
outDoor[220:304, 54:214] = goodpass
|
||||||
outDoor[220:304, 54:214] = goodpass
|
|
||||||
count = count + 1
|
|
||||||
if count == 20:
|
|
||||||
displayString = displayString + '#'
|
|
||||||
|
|
||||||
else:
|
if wait_3_sec_v2() == True:
|
||||||
badpass = cv2.imread('src/images/badpass.png')
|
displayString = displayString + '#'
|
||||||
outDoor[220:304, 54:214] = badpass
|
|
||||||
|
else:
|
||||||
|
badpass = cv2.imread('src/images/badpass.png')
|
||||||
|
outDoor[220:304, 54:214] = badpass
|
||||||
|
|
||||||
elif length == 5:
|
elif length == 5:
|
||||||
displayString = ''
|
displayString = ''
|
||||||
|
|
||||||
|
|
||||||
def notification():
|
def notification():
|
||||||
not1 = cv2.imread('src/notification/not1.png')
|
not1 = cv2.imread('src/notification/not1.png')
|
||||||
frame[50:50 + 139, 800:800 + 406] = not1
|
frame[50:50 + 139, 800:800 + 406] = not1
|
||||||
b = datetime.datetime.now()
|
|
||||||
global a
|
if wait_3_sec_v2() == True:
|
||||||
t = datetime.timedelta(0, 3)
|
global wait_notification
|
||||||
if (b - a) > t:
|
wait_notification = 0
|
||||||
global globalna
|
|
||||||
globalna = 0
|
|
||||||
|
|
||||||
|
|
||||||
global a
|
def putOnDisplay(frame, fheight, sheight, fwidth,
|
||||||
a = None
|
swidth, src):
|
||||||
global count
|
img = cv2.imread(src)
|
||||||
count = 0
|
frame[fheight: sheight, fwidth: swidth] = img
|
||||||
global displayString
|
|
||||||
displayString =""
|
|
||||||
i = 0
|
def putTimeOnDisplay(frame):
|
||||||
|
font = cv2.FONT_HERSHEY_SIMPLEX
|
||||||
|
|
||||||
|
actual_time = str(
|
||||||
|
datetime.datetime.now().strftime("%b %d %Y %H:%M:%S"))
|
||||||
|
|
||||||
|
frame = cv2.putText(frame, actual_time, (10, 50),
|
||||||
|
font, 1, (0, 255, 255), 2, cv2.LINE_AA)
|
||||||
|
|
||||||
|
|
||||||
|
def wait_3_sec(start):
|
||||||
|
live_time = datetime.datetime.now()
|
||||||
|
time_to_expire = datetime.timedelta(0, 3)
|
||||||
|
if (live_time - start) < time_to_expire:
|
||||||
|
live_time = datetime.datetime.now()
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def wait_3_sec_v2():
|
||||||
|
global pusto
|
||||||
|
if pusto == None:
|
||||||
|
pusto = datetime.datetime.now()
|
||||||
|
else:
|
||||||
|
live_time = datetime.datetime.now()
|
||||||
|
time_to_expire = datetime.timedelta(0, 3)
|
||||||
|
if (live_time - pusto) < time_to_expire:
|
||||||
|
live_time = datetime.datetime.now()
|
||||||
|
else:
|
||||||
|
pusto = None
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
global displayString, wait_notification, pusto
|
||||||
|
displayString = ""
|
||||||
|
wait_notification = 0
|
||||||
|
pusto = None
|
||||||
|
|
||||||
cam_status = 1
|
cam_status = 1
|
||||||
liczba = 0
|
|
||||||
globalna = 0
|
|
||||||
|
|
||||||
cap = cv2.VideoCapture(0)
|
cap = cv2.VideoCapture(0)
|
||||||
four_cc = cv2.VideoWriter_fourcc(*'XVID')
|
four_cc = cv2.VideoWriter_fourcc(*'XVID')
|
||||||
@ -188,7 +192,12 @@ out = cv2.VideoWriter('recordings/output.avi', four_cc, 10.0, (1280, 720))
|
|||||||
cap.set(3, 1280)
|
cap.set(3, 1280)
|
||||||
cap.set(4, 720)
|
cap.set(4, 720)
|
||||||
|
|
||||||
while cap.isOpened():
|
while True:
|
||||||
|
|
||||||
|
if not cap.isOpened():
|
||||||
|
print("Camera error")
|
||||||
|
break
|
||||||
|
|
||||||
ret, frameprev = cap.read()
|
ret, frameprev = cap.read()
|
||||||
|
|
||||||
if cam_status == 1:
|
if cam_status == 1:
|
||||||
@ -198,48 +207,23 @@ while cap.isOpened():
|
|||||||
|
|
||||||
if ret:
|
if ret:
|
||||||
|
|
||||||
font = cv2.FONT_HERSHEY_SIMPLEX
|
putTimeOnDisplay(frame)
|
||||||
|
|
||||||
actual_time = str(datetime.datetime.now().strftime("%b %d %Y %H:%M:%S"))
|
putOnDisplay(frame, 620, 720, 0, 1280, 'src/images/menu.png')
|
||||||
|
putOnDisplay(frame, 640, 640 + 63, 20, 169, 'src/icons/icon1.png')
|
||||||
|
putOnDisplay(frame, 640, 640 + 63, 189, 448, 'src/icons/icon2.png')
|
||||||
|
putOnDisplay(frame, 640, 640 + 63, 468, 734, 'src/icons/icon3.png')
|
||||||
|
putOnDisplay(frame, 640, 640 + 63, 754, 945, 'src/icons/icon4.png')
|
||||||
|
putOnDisplay(frame, 640, 640 + 63, 965, 1173, 'src/icons/icon5.png')
|
||||||
|
putOnDisplay(frame, 640, 640 + 63, 1193, 1267, 'src/icons/icon6.png')
|
||||||
|
|
||||||
frame = cv2.putText(frame, actual_time, (10, 50), font, 1, (0, 255, 255), 2, cv2.LINE_AA)
|
if wait_notification == 1:
|
||||||
|
|
||||||
menu = cv2.imread('src/images/menu.png')[620:720, 0:1280]
|
|
||||||
frame[620:720, 0:1280] = menu
|
|
||||||
|
|
||||||
icon1 = cv2.imread('src/icons/icon1.png')
|
|
||||||
frame[640:640 + 63, 20:169] = icon1
|
|
||||||
|
|
||||||
icon2 = cv2.imread('src/icons/icon2.png')
|
|
||||||
frame[640:640 + 63, 189:448] = icon2
|
|
||||||
|
|
||||||
icon3 = cv2.imread('src/icons/icon3.png')
|
|
||||||
frame[640:640 + 63, 468:734] = icon3
|
|
||||||
|
|
||||||
icon4 = cv2.imread('src/icons/icon4.png')
|
|
||||||
frame[640:640 + 63, 754:945] = icon4
|
|
||||||
|
|
||||||
icon5 = cv2.imread('src/icons/icon5.png')
|
|
||||||
frame[640:640 + 63, 965:1173] = icon5
|
|
||||||
|
|
||||||
icon6 = cv2.imread('src/icons/icon6.png')
|
|
||||||
frame[640:640 + 63, 1193:1267] = icon6
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if globalna == 1:
|
|
||||||
notification()
|
notification()
|
||||||
|
|
||||||
cv2.imshow('frame', frame)
|
cv2.imshow('frame', frame)
|
||||||
|
|
||||||
|
|
||||||
outDoor = cv2.imread('src/images/outDoorPanel.png')
|
outDoor = cv2.imread('src/images/outDoorPanel.png')
|
||||||
display(len(displayString))
|
display_work(len(displayString))
|
||||||
|
|
||||||
|
|
||||||
cv2.imshow('outDoor', outDoor)
|
cv2.imshow('outDoor', outDoor)
|
||||||
out.write(frameprev)
|
out.write(frameprev)
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 828 B |
Binary file not shown.
Before Width: | Height: | Size: 196 KiB After Width: | Height: | Size: 195 KiB |
Loading…
Reference in New Issue
Block a user