def get_face_bb(self, image): faceboxes = [] start_time = time.time() fraction = 4.0 image = cv2.resize(image, (0, 0), fx=1.0 / fraction, fy=1.0 / fraction) detections = self.face_net.detect_from_image(image) tqdm.write("Face Detector Frequency: {:.2f}Hz for {} Faces".format( 1 / (time.time() - start_time), len(detections))) for result in detections: # scale back up to image size box = result[:4] confidence = result[4] if gaze_tools.box_in_image(box, image) and confidence > 0.8: box = [x * fraction for x in box] # scale back up diff_height_width = (box[3] - box[1]) - (box[2] - box[0]) offset_y = int(abs(diff_height_width / 2)) box_moved = gaze_tools.move_box(box, [0, offset_y]) # Make box square. facebox = gaze_tools.get_square_box(box_moved) faceboxes.append(facebox) return faceboxes
def get_face_bb(self, image): faceboxes = [] fraction = 4.0 image = cv2.resize(image, (0, 0), fx=1.0 / fraction, fy=1.0 / fraction) detections = self.face_net.detect_from_image(image) for result in detections: # scale back up to image size box = result[:4] confidence = result[4] if gaze_tools.box_in_image(box, image) and confidence > 0.6: box = [x * fraction for x in box] # scale back up diff_height_width = (box[3] - box[1]) - (box[2] - box[0]) offset_y = int(abs(diff_height_width / 2)) box_moved = gaze_tools.move_box(box, [0, offset_y]) # Make box square. facebox = gaze_tools.get_square_box(box_moved) faceboxes.append(facebox) return faceboxes