From d11220d70c580657925ba9c8c589638f26312ef1 Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 4 Dec 2018 19:03:00 +0000 Subject: [PATCH] added date for unknown faces --- main.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index b0a5c81..fc36531 100644 --- a/main.py +++ b/main.py @@ -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()