added date for unknown faces

This commit is contained in:
HeshamTB 2018-12-04 19:03:00 +00:00
parent 29fa3a3335
commit d11220d70c

11
main.py
View File

@ -1,11 +1,11 @@
from time import sleep
from io import BytesIO
from PIL import Image
import os
import serial
import sys
import json
import datetime
try:
import numpy as np
@ -67,8 +67,8 @@ def start( camera, face_cascade):
roi_gray = gray[y:y+h, x:x+w]
roi_color = img[y:y+h, x:x+w]
person = recognize(roi_gray, face_recognizer, names)
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
cv2.putText(img, person, (x, y), cv2.FONT_HERSHEY_PLAIN, 1.7, (255, 0, 0), 2)
cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),1)
cv2.putText(img, person, (x, y), cv2.FONT_HERSHEY_PLAIN, 1.7, (0,255,0), 2)
except:
print('[ Error ] Recognition fail')
if person == 'unknown':
@ -76,9 +76,10 @@ def start( camera, face_cascade):
try:
RGBImage = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
image = Image.fromarray(RGBImage)
image.save('lastUnknown.png')
except:
image.save('unknown/'+str(datetime.datetime.now())+'.png')
except Exception as ex :
print('[ Error ] Saving unkown fail')
print(ex)
else:
print('Found '+person)
OpenShifter()