OpenCV DNN Face Detection
OpenCV has also implemented a deep neural network (DNN) based face detector since version 3.3. This model is based on a single-shot multibox detector and utilizes the ResNet-10 architecture as the backbone. It uses a combination of feature extraction and classification techniques to detect faces in images. The feature extraction step involves extracting relevant information from the input image, such as edges, lines, and corners, using a series of Haar-like features. The extracted features are then fed into a CNN, which uses a ResNet-10 architecture to classify the features as either face or non-face. It achieve an accuracy of 99.60% on the LFW dataset. However, one potential drawback of the DNN face detector in OpenCV is its higher computational cost compared to the Haar cascade classifier. This may make it less suitable for resource-constrained devices such as smartphones or embedded systems.
Example
from dronevis.models import DNNFaceDetection
model = DNNFaceDetection()
model.load_model()
model.detect_webcam()
OpenCV DNN Face Detection Class
- class dronevis.models.DNNFaceDetection(confidence=0.5)
DNN Face Detection model
- __init__(confidence=0.5)
Initialize self. See help(type(self)) for accurate signature.
- load_model(model_name='caffee')
Load model weights
- Parameters
model_name (str, optional) – Whether load the tensorflow quantized
or the caffee version. (version) –
to "caffee". (Defaults) –
- transform_img(image)
Transform image to be compatible with the model
- Parameters
image (np.ndarray) – Image to transform
- Returns
Transformed image
- Return type
np.ndarray
- predict(image)
Predict on image
- Parameters
image (np.ndarray) – Image to predict on
- Returns
Predicted image
- Return type
np.ndarray