Live face detection for Capacitor
npm install @mat2718/face-detection
npx cap sync
startActiveScan(...)
readFaceFromImage(...)
stopScan()
addListener('faceScanned', ...)
addListener('scanError', ...)
removeAllListeners()
enableTorch()
disableTorch()
toggleTorch()
isTorchEnabled()
isTorchAvailable()
openSettings()
isSupported()
checkPermissions()
requestPermissions()
- Interfaces
- Type Aliases
- Enums
startActiveScan(options: StartActiveScanOptions) => Promise<void>
Param | Type |
---|---|
options |
StartActiveScanOptions |
readFaceFromImage(options: readFaceFromImageOptions) => Promise<FaceDetectionResults>
Param | Type |
---|---|
options |
readFaceFromImageOptions |
Returns: Promise<FaceDetectionResults>
stopScan() => Promise<void>
addListener(eventName: 'faceScanned', listenerFunc: (event: ActiveFaceSanResult) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'faceScanned' |
listenerFunc |
(event: ActiveFaceSanResult) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
addListener(eventName: 'scanError', listenerFunc: (event: ScanErrorEvent) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param | Type |
---|---|
eventName |
'scanError' |
listenerFunc |
(event: ScanErrorEvent) => void |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
removeAllListeners() => Promise<void>
enableTorch() => Promise<void>
disableTorch() => Promise<void>
toggleTorch() => Promise<void>
isTorchEnabled() => Promise<IsTorchEnabledResult>
Returns: Promise<IsTorchEnabledResult>
isTorchAvailable() => Promise<IsTorchAvailableResult>
Returns: Promise<IsTorchAvailableResult>
openSettings() => Promise<void>
isSupported() => Promise<IsSupportedResult>
Returns: Promise<IsSupportedResult>
checkPermissions() => Promise<PermissionStatus>
Returns: Promise<PermissionStatus>
requestPermissions() => Promise<PermissionStatus>
Returns: Promise<PermissionStatus>
Prop | Type |
---|---|
lensFacing |
LensFacing |
Prop | Type |
---|---|
faces |
Face[] |
Represents a face detected by FaceDetector
.
Prop | Type | Description |
---|---|---|
bounds |
Rect |
Returns the axis-aligned bounding rectangle of the detected face. |
landmarks |
FaceLandmark[] |
Returns a list of face landmarks. |
contours |
FaceContour[] |
Returns a list of face contours. |
trackingId |
number |
Returns the tracking ID if the tracking is enabled. |
headEulerAngleX |
number |
Returns the rotation of the face about the horizontal axis of the image. Positive euler X is the face is looking up. |
headEulerAngleY |
number |
Returns the rotation of the face about the vertical axis of the image. Positive euler y is when the face turns toward the right side of the image that is being processed. |
headEulerAngleZ |
number |
Returns the rotation of the face about the axis pointing out of the image. Positive euler z is a counter-clockwise rotation within the image plane. |
smilingProbability |
number |
Returns a value between 0.0 and 1.0 giving a probability that the face is smiling. |
leftEyeOpenProbability |
number |
Returns a value between 0.0 and 1.0 giving a probability that the face's left eye is open. |
rightEyeOpenProbability |
number |
Returns a value between 0.0 and 1.0 giving a probability that the face's right eye is open. |
Rect holds four integer coordinates for a rectangle.
Prop | Type | Description | Since |
---|---|---|---|
left |
number |
The X coordinate of the left side of the rectangle. | 5.1.0 |
top |
number |
The Y coordinate of the top of the rectangle. | 5.1.0 |
right |
number |
The X coordinate of the right side of the rectangle. | 5.1.0 |
bottom |
number |
The Y coordinate of the bottom of the rectangle. | 5.1.0 |
Represent a face landmark. A landmark is a point on a detected face, such as an eye, nose, or mouth.
Prop | Type | Description | Since |
---|---|---|---|
type |
LandmarkType |
Gets the FaceLandmark.LandmarkType type. | 5.1.0 |
position |
Point |
Gets a 2D point for landmark position, where (0, 0) is the upper-left corner of the image. | 5.1.0 |
Point holds two coordinates
Prop | Type |
---|---|
x |
number |
y |
number |
Represent a face contour. A contour is a list of points on a detected face, such as the mouth.
Prop | Type | Description | Since |
---|---|---|---|
type |
ContourType |
Gets the FaceContour.ContourType type. | 5.1.0 |
points |
Point[] |
Gets a list of 2D points for this face contour, where (0, 0) is the upper-left corner of the image. | 5.1.0 |
Prop | Type |
---|---|
path |
string |
Prop | Type |
---|---|
remove |
() => Promise<void> |
Prop | Type |
---|---|
face |
Face |
Prop | Type |
---|---|
message |
string |
Prop | Type |
---|---|
enabled |
boolean |
Prop | Type |
---|---|
available |
boolean |
Prop | Type |
---|---|
supported |
boolean |
Prop | Type |
---|---|
camera |
CameraPermissionState |
PermissionState | 'limited'
'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'
Members | Value |
---|---|
Front |
'FRONT' |
Back |
'BACK' |
Members | Value | Description | Since |
---|---|---|---|
MouthBottom |
0 |
The center of the subject's bottom lip. | 5.1.0 |
LeftCheek |
1 |
The midpoint between the subject's left mouth corner and the outer corner of the subject's left eye. For full profile faces, this becomes the centroid of the nose base, nose tip, left ear lobe and left ear tip. | 5.1.0 |
LeftEar |
3 |
The midpoint of the subject's left ear tip and left ear lobe. | 5.1.0 |
LeftEye |
4 |
The center of the subject's left eye cavity. | 5.1.0 |
MouthLeft |
5 |
The subject's left mouth corner where the lips meet. | 5.1.0 |
NoseBase |
6 |
The midpoint between the subject's nostrils where the nose meets the face. | 5.1.0 |
RightCheek |
7 |
The midpoint between the subject's right mouth corner and the outer corner of the subject's right eye. For full profile faces, this becomes the centroid of the nose base, nose tip, right ear lobe and right ear tip. | 5.1.0 |
RightEar |
9 |
The midpoint of the subject's right ear tip and right ear lobe. | 5.1.0 |
RightEye |
10 |
The center of the subject's right eye cavity. | 5.1.0 |
MouthRight |
11 |
The subject's right mouth corner where the lips meet. | 5.1.0 |
Members | Value | Description | Since |
---|---|---|---|
Face |
1 |
The outline of the subject's face. | 5.1.0 |
LeftEyebrowTop |
2 |
The top outline of the subject's left eyebrow. | 5.1.0 |
LeftEyebrowBottom |
3 |
The bottom outline of the subject's left eyebrow. | 5.1.0 |
RightEyebrowTop |
4 |
The top outline of the subject's right eyebrow. | 5.1.0 |
RightEyebrowBottom |
5 |
The bottom outline of the subject's right eyebrow. | 5.1.0 |
LeftEye |
6 |
The outline of the subject's left eye cavity. | 5.1.0 |
RightEye |
7 |
The outline of the subject's right eye cavity. | 5.1.0 |
UpperLipTop |
8 |
The top outline of the subject's upper lip. | 5.1.0 |
UpperLipBottom |
9 |
The bottom outline of the subject's upper lip. | 5.1.0 |
LowerLipTop |
10 |
The top outline of the subject's lower lip. | 5.1.0 |
LowerLipBottom |
11 |
The bottom outline of the subject's lower lip. | 5.1.0 |
NoseBridge |
12 |
The outline of the subject's nose bridge. | 5.1.0 |
NoseBottom |
13 |
The outline of the subject's nose bridge. | 5.1.0 |
LeftCheek |
14 |
The center of the left cheek. | 5.1.0 |
RightCheek |
15 |
The center of the right cheek. | 5.1.0 |