This commit is contained in:
HeshamTB 2018-11-30 10:13:21 +00:00
parent 30c8e4b074
commit 8e351a1df0
5 changed files with 139166 additions and 7 deletions

View File

@ -55,7 +55,7 @@ void loop() {
//if (Serial.read() == 'o') {
digitalWrite(relayPin, HIGH);
playBuzzer(300,true);
delay(7000);
delay(4000);
digitalWrite(relayPin, LOW);
IROK = false;
UltraOK = false;

139158
faces/m

File diff suppressed because it is too large Load Diff

View File

@ -1 +1 @@
["", "Hesham", "Saeed"]
["", "Hesham", "Aidarous"]

10
main.py
View File

@ -37,6 +37,7 @@ def init():
go = False
if (go):
print('Starting Photo loop..')
print('Known people are '+str(loadNames()))
start(camera, face_cascade)
else:
@ -57,7 +58,7 @@ def start( camera, face_cascade):
camera.capture(rawCapture, format="bgr")
img = rawCapture.array
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.2,5)
faces = face_cascade.detectMultiScale(gray, 1.3,5)
i = 0;
for (x,y,w,h) in faces:
i += 1
@ -65,9 +66,11 @@ 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)
if person == 'Hesham' or person == 'Saeed':#Change to if 'unknown' elif openShifter
if not person == 'unknown':
OpenShifter()
print('Sending to Arduino!')
else:
print('Found unknown face')
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)
@ -89,7 +92,8 @@ def recognize(image):
face_recognizer.load('faces/m')
img = image.copy()
label= face_recognizer.predict(img)
if label[1] > 120:
if label[1] > 100:
print(str(label))
return 'unknown'
else:
print(str(label) + ' >>'+names[label[0]])

View File

@ -125,3 +125,4 @@ def addName(newName):
with open("faces/names.json","w") as write_file:
json.dump(names,write_file)
start()