Face Detection

This module load and inference images for face detection.

Example:

from dronevis.models import FaceDetectModel

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

Face Detection Class

class dronevis.models.FaceDetectModel(confidence=0.6)

Face detection class with mediapipe

This class inherits from base class CVModel, and implements its abstract methods for code integrity.

__init__(confidence=0.6)

Construct model instance

Parameters:
  • confidence (float, optional) – threshold for detection,

  • 1]**. (**input is a probability [0,) –

  • 0.5. (Defaults to) –

load_model()

Load model from memory

transform_img(image)

Idle transformation of the image

predict(image)

Run model inference on input image and output face detection keypoints.

Parameters:

img (np.array) – input image (assumed to be non-transformed)

Returns:

output image with keypoints drawn

Return type:

np.array

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

Run webcam (or any video streaming device) with face detection module

Parameters:
  • video_index (Union[int, str], optional) – index of video device. can be an IP

  • 0. (or video_path. Defaults to) –

  • window_name (str, optional) – name of opencv window. Defaults to “Face Detection”.