Skip to content

mat2718/Capacitor-Face-Detection

Repository files navigation

@mat2718/face-detection

Live face detection for Capacitor

Install

npm install @mat2718/face-detection
npx cap sync

API

startActiveScan(...)

startActiveScan(options: StartActiveScanOptions) => Promise<void>
Param Type
options StartActiveScanOptions

readFaceFromImage(...)

readFaceFromImage(options: readFaceFromImageOptions) => Promise<FaceDetectionResults>
Param Type
options readFaceFromImageOptions

Returns: Promise<FaceDetectionResults>


stopScan()

stopScan() => Promise<void>

addListener('faceScanned', ...)

addListener(eventName: 'faceScanned', listenerFunc: (event: ActiveFaceSanResult) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'faceScanned'
listenerFunc (event: ActiveFaceSanResult) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


addListener('scanError', ...)

addListener(eventName: 'scanError', listenerFunc: (event: ScanErrorEvent) => void) => Promise<PluginListenerHandle> & PluginListenerHandle
Param Type
eventName 'scanError'
listenerFunc (event: ScanErrorEvent) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle


removeAllListeners()

removeAllListeners() => Promise<void>

enableTorch()

enableTorch() => Promise<void>

disableTorch()

disableTorch() => Promise<void>

toggleTorch()

toggleTorch() => Promise<void>

isTorchEnabled()

isTorchEnabled() => Promise<IsTorchEnabledResult>

Returns: Promise<IsTorchEnabledResult>


isTorchAvailable()

isTorchAvailable() => Promise<IsTorchAvailableResult>

Returns: Promise<IsTorchAvailableResult>


openSettings()

openSettings() => Promise<void>

isSupported()

isSupported() => Promise<IsSupportedResult>

Returns: Promise<IsSupportedResult>


checkPermissions()

checkPermissions() => Promise<PermissionStatus>

Returns: Promise<PermissionStatus>


requestPermissions()

requestPermissions() => Promise<PermissionStatus>

Returns: Promise<PermissionStatus>


Interfaces

StartActiveScanOptions

Prop Type
lensFacing LensFacing

FaceDetectionResults

Prop Type
faces Face[]

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

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

FaceLandmark

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

Point holds two coordinates

Prop Type
x number
y number

FaceContour

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

readFaceFromImageOptions

Prop Type
path string

PluginListenerHandle

Prop Type
remove () => Promise<void>

ActiveFaceSanResult

Prop Type
face Face

ScanErrorEvent

Prop Type
message string

IsTorchEnabledResult

Prop Type
enabled boolean

IsTorchAvailableResult

Prop Type
available boolean

IsSupportedResult

Prop Type
supported boolean

PermissionStatus

Prop Type
camera CameraPermissionState

Type Aliases

CameraPermissionState

PermissionState | 'limited'

PermissionState

'prompt' | 'prompt-with-rationale' | 'granted' | 'denied'

Enums

LensFacing

Members Value
Front 'FRONT'
Back 'BACK'

LandmarkType

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

ContourType

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

About

Live Face Detection for Capicitor Framework

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published