taking photos
|
@ -5,7 +5,7 @@ from PIL import Image
|
|||
import pickle
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
image_dir = os.path.join(BASE_DIR, "images")
|
||||
image_dir = os.path.join(BASE_DIR, "faces")
|
||||
|
||||
face_cascade = cv2.CascadeClassifier(
|
||||
'cascades/data/haarcascade_frontalface_alt2.xml')
|
||||
|
|
Before Width: | Height: | Size: 59 KiB After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 334 KiB After Width: | Height: | Size: 334 KiB |
Before Width: | Height: | Size: 379 KiB After Width: | Height: | Size: 379 KiB |
Before Width: | Height: | Size: 320 KiB After Width: | Height: | Size: 320 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 329 KiB After Width: | Height: | Size: 329 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 79 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 57 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 133 KiB After Width: | Height: | Size: 133 KiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 164 KiB After Width: | Height: | Size: 164 KiB |
Before Width: | Height: | Size: 779 KiB After Width: | Height: | Size: 779 KiB |
Before Width: | Height: | Size: 285 KiB After Width: | Height: | Size: 285 KiB |
Before Width: | Height: | Size: 212 KiB After Width: | Height: | Size: 212 KiB |
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 41 KiB |
Before Width: | Height: | Size: 307 KiB After Width: | Height: | Size: 307 KiB |
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 111 KiB |
Before Width: | Height: | Size: 480 KiB After Width: | Height: | Size: 480 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
Before Width: | Height: | Size: 88 KiB After Width: | Height: | Size: 88 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 203 KiB After Width: | Height: | Size: 203 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 47 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 293 KiB After Width: | Height: | Size: 293 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
@ -0,0 +1 @@
|
|||
dict = <class 'dict'>
|
Before Width: | Height: | Size: 320 KiB |
Before Width: | Height: | Size: 224 KiB |
Before Width: | Height: | Size: 299 KiB |
Before Width: | Height: | Size: 198 KiB |
|
@ -36,11 +36,24 @@ def click_event(event, x, y, flags, param):
|
|||
global wait_notification
|
||||
wait_notification = 1
|
||||
elif 620 <= y <= 703 and 754 <= x <= 945:
|
||||
print('listen')
|
||||
|
||||
global name_of_photo
|
||||
print('taking photo... nr ' + str(name_of_photo))
|
||||
if name_of_photo > 100:
|
||||
name_of_photo = 1
|
||||
img_item = "photos/" + str(name_of_photo) + ".png"
|
||||
cv2.imwrite(img_item, frame)
|
||||
name_of_photo = name_of_photo + 1
|
||||
elif 620 <= y <= 703 and 965 <= x <= 1173:
|
||||
print('pick up')
|
||||
elif 620 <= y <= 703 and 1193 <= x <= 1267:
|
||||
print('off')
|
||||
|
||||
|
||||
with open("variable.pickle", "wb") as f:
|
||||
pickle.dump(name_of_photo, f)
|
||||
|
||||
|
||||
cap.release()
|
||||
out.release()
|
||||
cv2.destroyAllWindows()
|
||||
|
@ -125,7 +138,7 @@ def display_work(length):
|
|||
goodpass = cv2.imread('images/goodpass.png')
|
||||
outDoor[220:304, 54:214] = goodpass
|
||||
|
||||
if wait_seconds(3) == True:
|
||||
if wait_seconds2(3) == True:
|
||||
displayString = displayString + '#'
|
||||
|
||||
else:
|
||||
|
@ -140,7 +153,7 @@ def notification():
|
|||
not1 = cv2.imread('notification/not1.png')
|
||||
frame[50:50 + 139, 800:800 + 406] = not1
|
||||
|
||||
if wait_seconds(3) == True:
|
||||
if wait_seconds3(3) == True:
|
||||
global wait_notification
|
||||
wait_notification = 0
|
||||
|
||||
|
@ -170,17 +183,45 @@ def wait_3_sec(start):
|
|||
return True
|
||||
|
||||
|
||||
def wait_seconds(time):
|
||||
global pusto
|
||||
if pusto == None:
|
||||
pusto = datetime.datetime.now()
|
||||
def wait_seconds1(time):
|
||||
global temp1
|
||||
if temp1 == None:
|
||||
temp1 = datetime.datetime.now()
|
||||
else:
|
||||
live_time = datetime.datetime.now()
|
||||
time_to_expire = datetime.timedelta(0, time)
|
||||
if (live_time - pusto) < time_to_expire:
|
||||
if (live_time - temp1) < time_to_expire:
|
||||
live_time = datetime.datetime.now()
|
||||
else:
|
||||
pusto = None
|
||||
temp1 = None
|
||||
return True
|
||||
|
||||
|
||||
def wait_seconds2(time):
|
||||
global temp2
|
||||
if temp2 == None:
|
||||
temp2 = datetime.datetime.now()
|
||||
else:
|
||||
live_time = datetime.datetime.now()
|
||||
time_to_expire = datetime.timedelta(0, time)
|
||||
if (live_time - temp2) < time_to_expire:
|
||||
live_time = datetime.datetime.now()
|
||||
else:
|
||||
temp2 = None
|
||||
return True
|
||||
|
||||
|
||||
def wait_seconds3(time):
|
||||
global temp3
|
||||
if temp3 == None:
|
||||
temp3 = datetime.datetime.now()
|
||||
else:
|
||||
live_time = datetime.datetime.now()
|
||||
time_to_expire = datetime.timedelta(0, time)
|
||||
if (live_time - temp3) < time_to_expire:
|
||||
live_time = datetime.datetime.now()
|
||||
else:
|
||||
temp3 = None
|
||||
return True
|
||||
|
||||
|
||||
|
@ -190,15 +231,22 @@ def most_frequent(List):
|
|||
|
||||
|
||||
# Declaration
|
||||
global displayString, wait_notification, pusto
|
||||
global displayString, wait_notification, temp1, temp2, temp3, name_of_photo
|
||||
displayString = ""
|
||||
wait_notification = 0
|
||||
pusto = None
|
||||
temp1 = None
|
||||
temp2 = None
|
||||
temp3 = None
|
||||
name_of_photo = 1
|
||||
global cam_status
|
||||
cam_status = 1
|
||||
cam_status = 0
|
||||
List = []
|
||||
count = 0
|
||||
|
||||
with open("variable.pickle", "rb") as f:
|
||||
name_of_photo = pickle.load(f)
|
||||
print(name_of_photo)
|
||||
|
||||
|
||||
cap = cv2.VideoCapture(0)
|
||||
four_cc = cv2.VideoWriter_fourcc(*'XVID')
|
||||
|
@ -232,6 +280,7 @@ while True:
|
|||
if cam_status == 1:
|
||||
frame = copy.deepcopy(frameprev)
|
||||
if cam_status == 0:
|
||||
frame = copy.deepcopy(frameprev)
|
||||
putOnDisplay(frame, 0, 720, 0, 1280, "images/black.png")
|
||||
|
||||
# 3
|
||||
|
@ -279,7 +328,8 @@ while True:
|
|||
font, 1, (0, 255, 255), 2, cv2.LINE_AA)
|
||||
cv2.putText(frame, "is coming!", (250, 225),
|
||||
font, 1, (0, 255, 255), 2, cv2.LINE_AA)
|
||||
|
||||
if wait_seconds1(10) == True:
|
||||
List = []
|
||||
|
||||
###################
|
||||
|
||||
|
@ -288,6 +338,7 @@ while True:
|
|||
# home_screen = copy.deepcopy(frame)
|
||||
|
||||
putTimeOnDisplay(frame)
|
||||
putTimeOnDisplay(frameprev)
|
||||
|
||||
putOnDisplay(frame, 620, 720, 0, 1280, 'images/menu.png')
|
||||
putOnDisplay(frame, 640, 640 + 63, 20, 169, 'icons/icon1.png')
|
||||
|
@ -305,18 +356,20 @@ while True:
|
|||
outDoor = cv2.imread('images/outDoorPanel.png')
|
||||
display_work(len(displayString))
|
||||
|
||||
#cv2.imshow('outDoor', outDoor)
|
||||
cv2.imshow('outDoor', outDoor)
|
||||
|
||||
out.write(frameprev)
|
||||
cv2.setMouseCallback('frame', click_event)
|
||||
#cv2.setMouseCallback('outDoor', click_event2)
|
||||
cv2.setMouseCallback('outDoor', click_event2)
|
||||
|
||||
if cv2.waitKey(1) & 0xFF == ord('q'):
|
||||
break
|
||||
else:
|
||||
break
|
||||
|
||||
|
||||
print("zapisuje " + str(name_of_photo))
|
||||
with open("variable.pickle", "wb") as f:
|
||||
pickle.dump(name_of_photo, f)
|
||||
cap.release()
|
||||
out.release()
|
||||
cv2.destroyAllWindows()
|
||||
|
|
95877
src/trainner.yml
|
@ -0,0 +1 @@
|
|||
<EFBFBD>KL.
|