Skip to content

Commit

Permalink
Bug fixes and optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
richmondu committed Jan 25, 2019
1 parent e19fd02 commit 098fe65
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion agegenderemotion_webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def process_facedetection(model_detector, model_poseestimator, model_ageestimato

try:
# Initialize face detection
face_detector = FaceDetector(model=model_detector, path=INPUT_DIR_MODEL_DETECTION)#, optimize=True)
face_detector = FaceDetector(model=model_detector, path=INPUT_DIR_MODEL_DETECTION, minfacesize=120)
# Initialize face pose/age/gender estimation
face_pose_estimator = FacePoseEstimator(model=model_poseestimator, path=INPUT_DIR_MODEL_ESTIMATION)
face_age_estimator = FaceAgeEstimator(model=model_ageestimator, path=INPUT_DIR_MODEL_ESTIMATION)
Expand Down
25 changes: 23 additions & 2 deletions enrollment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import numpy as np
import os
import datetime
import math
from libfaceid.detector import FaceDetectorModels, FaceDetector
from libfaceid.encoder import FaceEncoderModels, FaceEncoder
from libfaceid.classifier import FaceClassifierModels
Expand Down Expand Up @@ -70,6 +71,24 @@ def save_video(saveVideo, out, resolution, filename):
saveVideo = True
return saveVideo, out

# inner
s1={}
for i in range(120):
for j in range(2):
if (j%2==0):
s1[i,j]=int(160+105*math.cos(3.0*i*3.14/180))
else:
s1[i,j]=int(120+105*math.sin(3.0*i*3.14/180))
#print(s1[i, j])
# outer
s2={}
for i in range(120):
for j in range(2):
if (j%2==0):
s2[i,j]=int(160+120*math.cos(3.0*i*3.14/180))
else:
s2[i,j]=int(120+120*math.sin(3.0*i*3.14/180))
#print(s2[i, j])

def process_faceenrollment(model_detector, cam_index, cam_resolution):

Expand Down Expand Up @@ -117,9 +136,11 @@ def process_faceenrollment(model_detector, cam_index, cam_resolution):


mask = np.full((frame.shape[0], frame.shape[1]), 0, dtype=np.uint8) # mask is only
cv2.circle(mask, (int(cam_resolution[0]/2),int(cam_resolution[1]/2)), 115, (255,255,255), -1, cv2.LINE_AA)
cv2.circle(mask, (int(cam_resolution[0]/2),int(cam_resolution[1]/2)), 110, (255,255,255), -1, cv2.LINE_AA)
fg = cv2.bitwise_or(frame, frame, mask=mask)
cv2.circle(fg, (int(cam_resolution[0]/2),int(cam_resolution[1]/2)), 115, color_recording, 1, cv2.LINE_AA)
cv2.circle(fg, (int(cam_resolution[0]/2),int(cam_resolution[1]/2)), 110, color_recording, 15, cv2.LINE_AA)
for i in range(120):
cv2.line(fg, (s1[i,0], s1[i,1]), (s2[i,0], s2[i,1]), (0, 0, 0), 2, cv2.LINE_AA)

# Display updated frame
cv2.imshow(WINDOW_NAME, fg)
Expand Down
2 changes: 1 addition & 1 deletion libfaceid/pose.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(self, path, overlay, color):
(42,43), (43,44), (44,45), (45,46), (46,47), (47,42), # right eye
(48,51), (51,54), (54,57), (57,48), (48, 4), (54,12), # outer lip
(30,31), (31,35), (35,30), (30,39), (30,42), (31,48), (35,54), # nose
(48, 7), (7, 57), (57, 9), (9,54), (31, 39), (35, 42), (31, 36), (35, 45), (31, 51), (51, 35), (48, 1), (55,15),
(48, 7), (7, 57), (57, 9), (9,54), (31, 39), (35, 42), (31, 36), (35, 45), (31, 51), (51, 35), (48, 1), (54,15),
}

def detect(self, frame, face):
Expand Down

0 comments on commit 098fe65

Please sign in to comment.