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