12.6.1 • Published 10 days ago

expo-face-detector v12.6.1

Weekly downloads
8,346
License
MIT
Repository
github
Last release
10 days ago

expo-face-detector

Installation

iOS (Cocoapods)

If you're using Cocoapods, add the dependency to your Podfile:

pod 'EXFaceDetector'

and run pod install.

iOS (no Cocoapods)

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesexpo-face-detector and add EXFaceDetector.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libEXFaceDetector.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R).

Android

  1. Append the following lines to android/settings.gradle:

    include ':expo-face-detector'
    project(':expo-face-detector').projectDir = new File(rootProject.projectDir, '../node_modules/expo-face-detector/android')
    
    include ':expo-face-detector-interface'
    project(':expo-face-detector-interface').projectDir = new File(rootProject.projectDir, '../node_modules/expo-face-detector-interface/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

    compile project(':expo-face-detector')
    compile project(':expo-face-detector-interface')

Introduction

FaceDetector lets you use the power of Google Mobile Vision framework to detect faces on images.

Known issues

  • Android does not recognize faces that aren't aligned with the interface (top of the interface matches top of the head).

Methods

detectFaces

Detect faces on a picture.

Arguments

  • uri (string) -- file:// URI to the image.
  • options? (object) -- A map of options:
    • mode? (FaceDetector.Constants.Mode) -- Whether to detect faces in fast or accurate mode. Use FaceDetector.Constants.Mode.{fast, accurate}.
    • detectLandmarks? (FaceDetector.Constants.Landmarks) -- Whether to detect and return landmarks positions on the face (ears, eyes, mouth, cheeks, nose). Use FaceDetector.Constants.Landmarks.{all, none}.
    • runClassifications? (FaceDetector.Constants.Classifications) -- Whether to run additional classifications on detected faces (smiling probability, open eye probabilities). Use FaceDetector.Constants.Classifications.{all, none}.

Returns

Returns a Promise that resolves to an object: { faces, image } where faces is an array of the detected faces and image is an object containing uri: string of the image, width: number of the image in pixels, height: number of the image in pixels and orientation: number of the image (value conforms to the EXIF orientation tag standard).

Example

import { FaceDetector } from 'expo-face-detector';

// ...
detectFaces = async (imageUri) => {
  const options = { mode: FaceDetector.Constants.Mode.fast };
  return await FaceDetector.detectFaces(imageUri, options);
};
// ...
Detected face schema

A detected face is an object containing at most following fields:

  • bounds (object) -- an object containing:
    • origin ({ x: number, y: number }) -- position of the top left corner of a square containing the face in image coordinates,
    • size ({ width: number, height: number }) -- size of the square containing the face in image coordinates,
  • rollAngle (number) -- roll angle of the face (bank),
  • yawAngle (number) -- yaw angle of the face (heading, turning head left or right),
  • smilingProbability (number) -- probability that the face is smiling,
  • leftEarPosition ({ x: number, y: number}) -- position of the left ear in image coordinates,
  • rightEarPosition ({ x: number, y: number}) -- position of the right ear in image coordinates,
  • leftEyePosition ({ x: number, y: number}) -- position of the left eye in image coordinates,
  • leftEyeOpenProbability (number) -- probability that the left eye is open,
  • rightEyePosition ({ x: number, y: number}) -- position of the right eye in image coordinates,
  • rightEyeOpenProbability (number) -- probability that the right eye is open,
  • leftCheekPosition ({ x: number, y: number}) -- position of the left cheek in image coordinates,
  • rightCheekPosition ({ x: number, y: number}) -- position of the right cheek in image coordinates,
  • mouthPosition ({ x: number, y: number}) -- position of the center of the mouth in image coordinates,
  • leftMouthPosition ({ x: number, y: number}) -- position of the left edge of the mouth in image coordinates,
  • rightMouthPosition ({ x: number, y: number}) -- position of the right edge of the mouth in image coordinates,
  • noseBasePosition ({ x: number, y: number}) -- position of the nose base in image coordinates.

smilingProbability, leftEyeOpenProbability and rightEyeOpenProbability are returned only if runClassifications option is set to .all.

Positions of face landmarks are returned only if detectLandmarks option is set to .all.

12.7.1

10 days ago

12.7.0

15 days ago

12.6.1

5 months ago

12.6.0

6 months ago

12.5.0

7 months ago

12.4.0

8 months ago

12.2.0

11 months ago

12.3.0

9 months ago

12.1.2

12 months ago

12.1.0

1 year ago

12.1.1

1 year ago

12.0.0

2 years ago

11.3.0

2 years ago

11.2.0

2 years ago

11.1.3

2 years ago

11.1.1

2 years ago

11.1.2

2 years ago

11.1.0

2 years ago

11.0.2

3 years ago

11.0.3

3 years ago

11.0.1

3 years ago

11.0.0

3 years ago

10.1.1

3 years ago

10.1.0

3 years ago

10.0.1

3 years ago

10.0.0

3 years ago

9.0.1

3 years ago

9.0.0

3 years ago

8.4.0

3 years ago

8.3.0

4 years ago

8.2.1

4 years ago

8.2.0

4 years ago

8.0.1

4 years ago

8.1.0

4 years ago

8.0.0

4 years ago

7.0.0

5 years ago

7.0.0-rc.0

5 years ago

6.0.1

5 years ago

6.0.0

5 years ago

6.0.0-rc.1

5 years ago

6.0.0-rc.0

5 years ago

5.0.1

5 years ago

5.0.0

5 years ago

5.0.0-rc.0

5 years ago

4.0.0

5 years ago

3.0.0

5 years ago

2.0.0

5 years ago

2.0.0-rc.2

5 years ago

2.0.0-rc.1

5 years ago

2.0.0-rc.0

5 years ago

1.1.0

6 years ago

1.1.0-rc.1

6 years ago

1.1.0-rc.0

6 years ago

1.0.2

6 years ago

1.0.2-rc.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

1.0.0-rc.2

6 years ago

1.0.0-rc.1

6 years ago

1.0.0-rc.0

6 years ago

0.0.1

6 years ago