# 🧩 mlkitFaceDetection — Free Face Detection Extension Beta Version

🧩 mlkitFaceDetection

An extension for MIT App Inventor 2.
Google ML Kit Face Detection. Detects faces and returns bounding boxes, landmarks, and smile/eye details.

:memo: Specifications


:package: Package: com.mlkit.face.detection.idriss.ma.mlkitfacedetection
:floppy_disk: Size: 2.35 MB
:gear: Version: 3.0
:mobile_phone: Minimum API Level: 21
:date: Updated On: 2026-09-23T23:00:00Z
:laptop: Built & documented using: FAST v7.1.1

Events:

mlkitFaceDetection has total 5 events.

1. FacesDetected

Fired when face detection completes. Sends a list of all detected faces as dictionaries containing bounding box, landmarks, and classifications.

Parameter Type
facesList list

2. FaceDetected

Fired for each detected face. Parameters: faceNumber (1-based index), left/top/right/bottom/width/height (bounding box), smilingProbability, leftEyeOpenProbability, rightEyeOpenProbability, and landmark coordinates.

Parameter Type
faceNumber number
left number
top number
right number
bottom number
width number
height number
smilingProbability number
leftEyeOpenProbability number
rightEyeOpenProbability number
leftEyeX number
leftEyeY number
rightEyeX number
rightEyeY number
noseX number
noseY number

3. NoFacesDetected

Fired when the image is processed but no faces are found.

4. ErrorOccurred

Fired when an error occurs during image loading, initialization, or face detection. Check the message for details.

Parameter Type
message text

5. TestCompleted

Result of TestSetup. success=True means library, Play Services, detector, and face model are all ready. Provides status code and detailed explanation.

Parameter Type
success boolean
status text
details text

Methods:

mlkitFaceDetection has total 16 methods.

1. DetectFaces

Detects faces in the image at the given file path. Example: DetectFaces(/storage/emulated/0/DCIM/photo.jpg) analyzes the image and fires FacesDetected or NoFacesDetected. Supports content:// URIs, file:// paths, and Asset names. Returns immediately; results arrive via events.

Parameter Type
imagePath text

2. GetAllFaces

Returns a list of all detected faces as dictionaries. Each dictionary contains keys: faceNumber, left, top, right, bottom, width, height, smilingProbability, leftEyeOpenProbability, rightEyeOpenProbability, and landmark coordinates (leftEyeX, leftEyeY, etc.). Example: GetAllFaces() returns [{“faceNumber”: 1, “left”: 120, …}, …]

  • Return type: list

3. GetFacesCount

Returns the total number of faces detected in the last image (0 if none found).

  • Return type: number

4. HasFace

Returns True if a face exists at the given 1-based index. Example: HasFace(1) returns True if at least one face was detected.

  • Return type: boolean
Parameter Type
faceIndex number

5. GetFaceBoundingBox

Returns the bounding box as a list [left, top, right, bottom, width, height] for the face at the given 1-based index. Example: GetFaceBoundingBox(1) might return [120, 200, 400, 520, 280, 320]. Returns [-1, -1, …] if face not found.

  • Return type: list
Parameter Type
faceIndex number

6. GetFaceDetails

Returns a complete dictionary for the face at the given 1-based index. Keys include all face properties (bounding box, landmarks, classifications). Example: GetFaceDetails(1) returns {“faceNumber”: 1, “left”: 120, “smilingProbability”: 0.85, …}

  • Return type: dictionary
Parameter Type
faceIndex number

7. GetFaceLandmarks

Returns the key facial landmarks as a list [leftEyeX, leftEyeY, rightEyeX, rightEyeY, noseX, noseY] for the face at the given 1-based index. Example: GetFaceLandmarks(1) might return [150, 210, 350, 210, 250, 300].

  • Return type: list
Parameter Type
faceIndex number

8. GetBoundingBox

Returns a bounding box coordinate (left, top, right, bottom, width, height) for the face at the given 1-based index.

  • Return type: number
Parameter Type
faceIndex number
coordinate BoundingBoxCoordinate (helper blocks)
  • Enums for BoundingBoxCoordinate: Left, Top, Right, Bottom, Width, Height

9. GetClassification

Returns a classification probability (smiling, left eye, or right eye) for the face at the given 1-based index.

  • Return type: number
Parameter Type
faceIndex number
classificationType ClassificationType (helper blocks)
  • Enums for ClassificationType: Smiling, LeftEyeOpen, RightEyeOpen

10. GetLandmark

Returns a specific landmark coordinate (X or Y) for a facial feature for the face at the given 1-based index.

  • Return type: number
Parameter Type
faceIndex number
landmarkType LandmarkType (helper blocks)
coordinateType CoordinateType (helper blocks)
  • Enums for LandmarkType: LeftEye, RightEye, NoseBase, MouthLeft, MouthRight, MouthBottom
  • Enums for CoordinateType: X, Y

11. IsInitialized

Returns True if the face detector is initialized and ready to process images.

  • Return type: boolean

12. IsLibraryAvailable

Returns True if the ML Kit Face Detection library classes are available on the device.

  • Return type: boolean

13. GetStatus

Returns a quick status string showing library, Google Play Services, and detector readiness. Example: “library=OK | playServices=OK | detector=READY | faces=0”. For detailed model download status, use TestSetup instead.

  • Return type: text

14. TestSetup

Performs a full diagnostic check: validates library, Google Play Services, detector initialization, and face model download status. Fires TestCompleted with results. Example: Use this button to verify everything is set up before calling DetectFaces.

15. GetVersion

Returns the version number of the ML Kit Face Detection library (e.g., “16.1.5”).

  • Return type: text

16. Close

Closes the face detector and clears all cached face data. Next DetectFaces call will reinitialize automatically.

ScreenShots


Blocks


APK

faceDetection.apk (6.4 MB)

File AIA

faceDetection.aia (2.6 MB)

AIX

com.mlkit.face.detection.idriss.ma.mlkitfacedetection.aix (2.3 MB)


3 Likes