logo
On this page

Face detection


The ZegoEffects SDK provides a face detection function, which can detect all faces in a video and the positions of the faces in the video images.

Prerequisites

Before you begin to use the SDK's face detection feature in your project, make sure you complete the following steps:

  1. Integrate the ZegoEffects SDK into your project. For details, see Integration.
  2. Implement the basic image processing functionality. For details, see Implementation.
  3. Import the FaceDetectionModel. For details, see Import resources and models.

Enable face detection

Warning

To use the face detection feature, import the model file FaceDetectionModel first; otherwise, this feature can't take effect. For details, see Import resources and models.

  1. Call the setEventHandler method to set the callback to return the face detection result.

    Untitled
    // Set the callback to return the face detection result.
    mEffects.setEventHandler(new ZegoEffectsEventHandler() {
        @Override
        public void onFaceDetectionResult(ZegoEffectsFaceDetectionResult[] results, ZegoEffects handle) {
        // Obtain the face detection result, including the number of faces, the confidence level of each detected face and its position.
        }
    });
    
    1
    Copied!
  2. Call the enableFaceDetection method to enable the face detection feature.

    Untitled
    // Enable face detection.
    mEffects.enableFaceDetection(true);
    
    1
    Copied!

Previous

Background Segmentation

Next

Filters