[Free] AndroidFaceDetector | Using Android’s built-in FaceDetector

🧩 AndroidFaceDetector

Lightweight face-detection extension using Android’s built-in FaceDetector API.
Detects faces from local image files or URLs, returning:
midpoints, eye distances, confidence, and Euler pose (X, Y, Z).

Developed by A E M O, built with FAST.


:clipboard: Specifications

Property Value
:package: Package me.aemo.androidfacedetector
:floppy_disk: Size 7.87 KB
:gear: Version 1.5
:mobile_phone: Min API Level 14
:date: Updated On 2025-10-31
:laptop: Built & documented using FAST v5.2.2-premium

:brain: Events

1. OnFacesDetected

Triggered when one or more faces are detected.

Parameter Type Description
totalFaces number Total number of faces detected.
width number Image width in pixels.
height number Image height in pixels.
midXs list List of midpoint X coordinates for faces.
midYs list List of midpoint Y coordinates for faces.
eyesDistances list Distance between the eyes for each face.
confidences list Detection confidence values (0–100).
poseXs list Euler X rotation (tilt).
poseYs list Euler Y rotation (yaw).
poseZs list Euler Z rotation (roll).

2. OnError

Triggered when an error occurs (invalid path, unreadable image, or no faces detected).

Parameter Type Description
message text Description of the error.

:gear: Method

FindFaces

Detects faces in an image and triggers OnFacesDetected or OnError.

Parameter Type Description
imagePath text File path or URL of the image (must be readable).
maxFaces number Maximum number of faces to detect (recommended: 1–10).

:down_arrow: Download

AndroidFaceDetector Extension (.aix)
me.aemo.androidfacedetector.aix (7.9 KB)


:books: Library Used

This extension uses Android’s classic on-device face detector:

android.media.FaceDetector

:link: Official Documentation:


:warning: Notes & Limitations

Android’s built-in FaceDetector API is lightweight but has major limitations:

:small_blue_diamond: Faces Must Be Upright

Only detects upright, forward-facing faces. Fails on:

  • side profiles
  • upside-down faces
  • extreme angles
  • heavily rotated faces

:small_blue_diamond: Only Detects Basic Data

Provides only:

  • midpoint
  • eye distance
  • Euler rotation
  • confidence
    :cross_mark: No bounding box
    :cross_mark: No landmarks (nose, mouth, etc.)

:small_blue_diamond: Max Resolution Issues

Very large images may cause:

  • memory errors
  • slow processing
  • “no faces detected” due to scaling

:small_blue_diamond: Bitmap Format Restriction

Only works with RGB_565 (16-bit) images.
Conversion failures trigger errors.

:small_blue_diamond: maxFaces Limitation

Faces beyond the maxFaces value are ignored.

:small_blue_diamond: Poor Detection in Low Light

Performance is limited in:

  • dark environments
  • overexposed images
  • blurry images

:light_bulb: Best Practices for Better Detection

  • Use medium-resolution images (300×200 → 1024×1024).
  • Make sure the face is upright and clearly visible.
  • Avoid low-light and blurry images.
  • Use direct image URLs (.jpg / .png).
  • Set a realistic maxFaces value (1–5 recommended).
  • Avoid images with extreme rotation.

:wrench: Troubleshooting

Error Message Cause Solution
File not found Incorrect path Verify full file path.
Unable to load image Corrupted / unsupported image Convert to JPG or PNG.
Bitmap config not supported Not RGB_565 Pre-convert or compress image.
No faces detected Angle, lighting, bad quality Improve lighting or crop closer.
URL failed to load Redirect / HTML page Use a direct image URL.
OutOfMemoryError Image too large Use lower resolution.

:rocket: Coming Soon :wink:

ML Kit FaceDetector Integration

A new version of this extension using Google ML Kit’s Face Detection API is in development.

It will support:

  • :check_mark: high-accuracy detection
  • :check_mark: side-profile faces
  • :check_mark: full landmarks (eyes, nose, mouth, etc.)
  • :check_mark: expression detection
  • :check_mark: multi-face tracking
  • :check_mark: improved performance

Planned name: me.aemo.mlkitfacedetector
Release: Coming soon! :wink:


:bar_chart: FaceDetector vs ML Kit

Feature Android FaceDetector Google ML Kit
Accuracy Low High
Works offline :check_mark: :check_mark:
Side-profile faces :cross_mark: Poor :check_mark: Excellent
Landmarks :cross_mark: None :check_mark: 100+ points
Expressions detection :cross_mark: No :check_mark: Yes
Multi-face tracking :cross_mark: No :check_mark: Yes
Stability Medium High
Modern support Limited Excellent

8 Likes

Can it detect faces on camera by any chance? Great extension

I guess you should use the camera component to capture then use the extension to scan the captured image

1 Like