Commit e1c72495 authored by cb's avatar cb

Quick Code Formatting

parent f3699846
......@@ -89,7 +89,6 @@ def detectAndTrackMultipleFaces(start_thread, charset, draw_person_dangerosity):
elif pressedKey == 194: # F5
FULLSCREEN = not FULLSCREEN
#Resize the image to 320x240
baseImage = cv2.resize( fullSizeBaseImage, ( 320, 240))
......@@ -98,12 +97,14 @@ def detectAndTrackMultipleFaces(start_thread, charset, draw_person_dangerosity):
#overlayed rectangle for the largest face
if FULLSCREEN == True:
resultImage = fullSizeBaseImage.copy()
cv2.setWindowProperty('result-image', cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
cv2.setWindowProperty('result-image',
cv2.WND_PROP_FULLSCREEN,
cv2.WINDOW_FULLSCREEN)
else:
resultImage = baseImage.copy()
cv2.setWindowProperty('result-image', cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_NORMAL)
cv2.setWindowProperty('result-image',
cv2.WND_PROP_FULLSCREEN,
cv2.WINDOW_NORMAL)
#STEPS:
# * Update all trackers and remove the ones that are not
......@@ -120,8 +121,6 @@ def detectAndTrackMultipleFaces(start_thread, charset, draw_person_dangerosity):
#Increase the framecounter
frameCounter += 1
#Update all the trackers and remove the ones for which the update
#indicated the quality was not good enough
fidsToDelete = []
......@@ -140,14 +139,10 @@ def detectAndTrackMultipleFaces(start_thread, charset, draw_person_dangerosity):
calculateAverageSuspicious(faceSuspicion)
#Every 10 frames, we will have to determine which faces
#are present in the frame
if (frameCounter % 10) == 0:
#For the face detection, we need to make use of a gray
#colored image so we will convert the baseImage to a
#gray-based image
......@@ -156,8 +151,6 @@ def detectAndTrackMultipleFaces(start_thread, charset, draw_person_dangerosity):
#in the image
faces = faceCascade.detectMultiScale(gray, 1.3, 5)
#Loop over all faces and check if the area for this
#face is the largest so far
#We need to convert it to int here because of the
......@@ -175,8 +168,6 @@ def detectAndTrackMultipleFaces(start_thread, charset, draw_person_dangerosity):
x_bar = x + 0.5 * w
y_bar = y + 0.5 * h
#Variable holding information which faceid we
#matched with
matchedFid = None
......@@ -208,7 +199,6 @@ def detectAndTrackMultipleFaces(start_thread, charset, draw_person_dangerosity):
( y <= t_y_bar <= (y + h ))):
matchedFid = fid
#If no matched fid, then we have to create a new tracker
if matchedFid is None:
......@@ -235,15 +225,15 @@ def detectAndTrackMultipleFaces(start_thread, charset, draw_person_dangerosity):
t.start()
else:
# Directly add name
faceNames[ currentFaceID ] = randomnames.rand_name(charset) #"Person " + str(fid)
# Directly add name + pass a charset to which name must belong
# "Person " + str(fid)
faceNames[ currentFaceID ] = randomnames.rand_name(charset)
calculateAverageSuspicious(faceSuspicion)
#Increase the currentFaceID counter
currentFaceID += 1
#Now loop over all the trackers we have and draw the rectangle
#around the detected faces. If we 'know' the name for this person
#(i.e. the recognition thread is finished), we print the name
......@@ -266,7 +256,11 @@ def detectAndTrackMultipleFaces(start_thread, charset, draw_person_dangerosity):
t_w = int(tracked_position.width())
t_h = int(tracked_position.height())
cv2.rectangle(resultImage, (t_x+t_w, t_y), (t_x+t_w+30, t_y+80), suspiciousColors[faceSuspicion[fid]], -1)
cv2.rectangle(resultImage,
(t_x+t_w, t_y),
(t_x+t_w+30, t_y+80),
suspiciousColors[faceSuspicion[fid]],
-1)
if averageSuspicious>2.5:
color = RED
......@@ -280,17 +274,25 @@ def detectAndTrackMultipleFaces(start_thread, charset, draw_person_dangerosity):
if fid in faceNames.keys():
# Name's alignment
cv2.putText(resultImage, faceNames[fid] ,
cv2.putText(resultImage,
faceNames[fid] ,
(t_x+ int((t_w - len(faceNames[fid])*10)/2 +2), int(t_y)),
cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 255, 255), 1, cv2.LINE_AA)
0.5,
(255, 255, 255),
1,
cv2.LINE_AA)
else:
# Detecting
text = "Identifying"
cv2.putText(resultImage, text ,
cv2.putText(resultImage,
text ,
(t_x + int((t_w - len(text)*10)/2 +2), int(t_y)),
cv2.FONT_HERSHEY_SIMPLEX,
0.5, (255, 255, 255), 1, cv2.LINE_AA)
0.5,
(255, 255, 255),
1,
cv2.LINE_AA)
#Since we want to show something larger on the screen than the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment