Face detectors

class pftracker.modules.facedetection.detect_one_face(image)[source]

One face detection class.

Class used for detecting one face in the first frame of video where particle filter algorithm is going to be applied.

Parameters

image (array) – image where the face detection is perfomed

Supported Face detectors:
  • ‘HaarCascade’: Viola and Jones (V&J) detector

  • ‘CaffeModel’: Single Shot Detector (SSD)

  • ‘dlib’: Histogram of Oriented Gradient (HOG)

bb_faces(face)[source]

Returns face bounding box coordinates in the format (startX, startY, endX, endY).

Parameters

faces (tuple) – face detection resulting from a detector algorithm in the format (startX, startY, w, h). Where w and h are the weight and height of the face bounding box respectevely.

caffeModel_detector(confidence=0.5)[source]

Run Single Shot Detector (SSD) algorithm for face detection on image.

Parameters

confidence (float, optional) – minimum algorithm confidence boundary for detection.

Returns

(tuple) with face bounding box coordinates resulting from detection.

detector(face_detector)[source]

Run a face detector algortihm on image.

Parameters

face_detector (str) – Face detector algorithm to apply

Returns

(tuple) with bounding box coordinates resulting from face detection on image in the format (startX, startY, endX, endY).

Raises

AssertionError – Exception raised if the face detector algorithm couldn’t detect any face (box iqual to (0, 0, 0, 0).

dlib_detector()[source]

Run Histogram of Oriented Gradient (HOG) face detector on image.

Returns

(tuple) with face bounding box coordinates resulting from detection.

get_cascade_faces_from_model(model, minN)[source]

Returns a list of face detections from Viola and Jones (V&J) algorithm.

Parameters
  • model (str) – HaarCascade face detector model (frontal, left profile or right profile)

  • minN (int) – Minimum of neighbors needed for retaining each candidate bounding box detected

haarCascade_detector()[source]

Run Viola and Jones (V&J) face detector on image.

Returns

(tuple) with face bounding box coordinates resulting from detection.