exception handling
This commit is contained in:
parent
4f88480583
commit
e773fc6a8e
8
main.py
8
main.py
@ -45,6 +45,8 @@ def init():
|
||||
def start( camera, face_cascade):
|
||||
j = 0
|
||||
rawCapture = PiRGBArray(camera)
|
||||
face_recognizer = cv2.createLBPHFaceRecognizer()
|
||||
face_recognizer.load('faces/m')
|
||||
while 1:
|
||||
try:
|
||||
camera.capture(rawCapture, format="bgr")
|
||||
@ -60,7 +62,7 @@ def start( camera, face_cascade):
|
||||
j += 1
|
||||
roi_gray = gray[y:y+h, x:x+w]
|
||||
roi_color = img[y:y+h, x:x+w]
|
||||
person = recognize(roi_gray)
|
||||
person = recognize(roi_gray, face_recognizer)
|
||||
if person == 'unknown':
|
||||
print('Found unknown person')
|
||||
else:
|
||||
@ -76,11 +78,9 @@ def start( camera, face_cascade):
|
||||
cv2.destroyAllWindows()
|
||||
break
|
||||
|
||||
def recognize(image):
|
||||
def recognize(image,face_recognizer):
|
||||
names = loadNames()
|
||||
try:
|
||||
face_recognizer = cv2.createLBPHFaceRecognizer()
|
||||
face_recognizer.load('faces/m')
|
||||
img = image.copy()
|
||||
label= face_recognizer.predict(img)
|
||||
except:
|
||||
|
Loading…
Reference in New Issue
Block a user