HOG Face Detection

The Histogram of Oriented Gradients (HOG) classifier is another popular face detection algorithm that has shown excellent performance in various computer vision applications. Proposed by Dalal and Triggs, HOG is based on the idea of using the distribution of gradient orientation in small cells to represent the features of an image. The algorithm first extracts the gradient orientation histograms from the input image and then uses a sliding window approach to detect potential face regions. The HOG classifier has several advantages over the Haar classifier. Firstly, it is more robust to variations in lighting and pose, as it uses a distribution of gradient orientations rather than a single orientation. Secondly, it is less sensitive to the size of the face, allowing it to detect faces of varying sizes. Finally, the HOG classifier is computationally more efficient than the Haar classifier, making it a better choice for real-time applications. Evaluated on “Labeled Faces in the Wild” (LFW) dataset, it achieved an accuracy of 95.6% with a false positive rate of 0.13. However, the HOG classifier also has some limitations. It requires a large amount of training data to achieve good performance, and the training process can be computationally expensive. Additionally, the classifier is sensitive to the choice of parameters, such as the size of the cells and the number of bins used in the histogram.

Example

from dronevis.models import HOGFaceDetection

model = HOGFaceDetection() # create model instance
model.load()                # load model weights
model.detect_webcam()       # run camera detection

HOG Face Detection Class

class dronevis.models.HOGFaceDetection

HOG Face Detection model

__init__()

Initialize self. See help(type(self)) for accurate signature.

load_model()

Load model weights

transform_img(image)

Run image transformation

predict(image)

Run model inference on the image

Parameters

image (np.ndarray) – Input image

Returns

Image withe face annotations

Return type

np.ndarray

detect_webcam(video_index=0, window_name='HOG Face Detection')

Run model on a video stream from the webcam

Parameters
  • video_index (int) – Index of the camera/video device to retrieve stream

  • window_name (str, optional) – Name of openCV window for running the mpdel.

  • to "Cam Detection". (Defaults) –