|
|
@@ -16,7 +16,7 @@ os.system('sudo modprobe bcm2835-v4l2')
|
16
|
16
|
# Set the framerate ( not sure this does anything! )
|
17
|
17
|
#os.system('v4l2-ctl -p 4')
|
18
|
18
|
|
19
|
|
-width, height = 320, 240
|
|
19
|
+width, height = 740, 480
|
20
|
20
|
cap = cv2.VideoCapture()
|
21
|
21
|
cap.open(0)
|
22
|
22
|
cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, width)
|
|
|
@@ -68,7 +68,7 @@ def faceDetect(frame):
|
68
|
68
|
flags=cv2.cv.CV_HAAR_SCALE_IMAGE | cv2.cv.CV_HAAR_FIND_BIGGEST_OBJECT | cv2.cv.CV_HAAR_DO_ROUGH_SEARCH
|
69
|
69
|
)
|
70
|
70
|
|
71
|
|
- print "Found {0} faces!".format(len(faces))
|
|
71
|
+
|
72
|
72
|
global last_image_faces
|
73
|
73
|
image_faces = []
|
74
|
74
|
|
|
|
@@ -86,9 +86,9 @@ def faceDetect(frame):
|
86
|
86
|
|
87
|
87
|
# Info = [center_x, center_y, time_since_last_check, user, score]
|
88
|
88
|
center = [center_x, center_y, pos[2] + 1]
|
89
|
|
- print("Tracking face " + str(counter))
|
|
89
|
+ #print("Tracking face " + str(counter))
|
90
|
90
|
counter = counter + 1
|
91
|
|
- if center[2] > 6:
|
|
91
|
+ if center[2] > 20 and w >= 60 :
|
92
|
92
|
if start_x > 0 and start_y > 0:
|
93
|
93
|
face_crop = frame[y:(y+h), x:(x+w)]
|
94
|
94
|
info = recognizeFace(face_crop)
|
|
|
@@ -100,8 +100,9 @@ def faceDetect(frame):
|
100
|
100
|
if len(pos) > 3:
|
101
|
101
|
center.append(pos[3])
|
102
|
102
|
center.append(pos[4])
|
103
|
|
- if pos[4] < 2000:
|
|
103
|
+ if pos[4] < 2500 or pos[4] > 7000:
|
104
|
104
|
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 0, 255), 2)
|
|
105
|
+ cv2.putText(frame, users[center[3]], (x, (y + h + 15)), font, 1, (0,0,255), 1, 1)
|
105
|
106
|
cv2.putText(frame, "%.1f" % (center[4]/1000), ((x + w - 38), (y + 17)), font, 1, (0,0,255), 1, 1)
|
106
|
107
|
else:
|
107
|
108
|
cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
|
|
|
@@ -115,12 +116,13 @@ def faceDetect(frame):
|
115
|
116
|
center = [center_x, center_y, 1]
|
116
|
117
|
image_faces.append(center)
|
117
|
118
|
cv2.rectangle(frame, (x, y), (x+w, y+h), (255, 255, 255), 2)
|
118
|
|
- print("Number of faces detected " + str(len(last_image_faces)))
|
|
119
|
+ #print("Found " + str(len(faces)) + " faces | Recognized " + str(len(last_image_faces)) + " faces")
|
|
120
|
+
|
119
|
121
|
last_image_faces = image_faces
|
120
|
122
|
return frame
|
121
|
123
|
|
122
|
124
|
def recognizeFace(face):
|
123
|
|
- print("Searching Face database...")
|
|
125
|
+ #print("Searching Face database...")
|
124
|
126
|
match_found = False
|
125
|
127
|
face = cv2.resize(face, (120, 120))
|
126
|
128
|
face = cv2.cvtColor(face, cv2.cv.CV_BGR2GRAY)
|
|
|
@@ -130,7 +132,7 @@ def recognizeFace(face):
|
130
|
132
|
predicted_label = predict_image_from_model(model, face)
|
131
|
133
|
print 'Predicted: %(predicted)s ' % {"predicted": users[predicted_label[0]]}
|
132
|
134
|
print str(predicted_label[0]) + " - " + str(predicted_label[1])
|
133
|
|
- print c.face_recognized(users[predicted_label[0]])
|
|
135
|
+ #print c.face_recognized(users[predicted_label[0]])
|
134
|
136
|
return predicted_label
|
135
|
137
|
|
136
|
138
|
def loadFaceDB():
|