react-native-vision-camera-face-detector
Version:
Frame Processor Plugin to detect faces using MLKit Vision Face Detector for React Native Vision Camera!
59 lines (53 loc) • 1.73 kB
text/typescript
import { NitroModules } from 'react-native-nitro-modules'
import type {
CameraOutput,
Frame
} from 'react-native-vision-camera'
import type { Face } from './specs/Face.nitro'
import type { FaceDetector } from './specs/FaceDetector.nitro'
import type { ImageFaceDetector } from './specs/ImageFaceDetector.nitro'
import type {
FaceDetectorFactory,
FaceDetectorOptions,
FaceDetectorOutputOptions
} from './specs/FaceDetectorFactory.nitro'
import type { ImageFaceDetectorFactory } from './specs/ImageFaceDetectorFactory.nitro'
const faceDetectorFactory = NitroModules.createHybridObject<FaceDetectorFactory>(
'FaceDetectorFactory'
)
const imageFaceDetectorFactory = NitroModules.createHybridObject<ImageFaceDetectorFactory>(
'ImageFaceDetectorFactory'
)
/**
* Create a new {@linkcode FaceDetector}.
*
* The {@linkcode FaceDetector} can be used to
* scan {@linkcode Face}s in a {@linkcode Frame}.
*/
export function createFaceDetector(
options?: FaceDetectorOptions
): FaceDetector {
return faceDetectorFactory.createFaceDetector( options ?? {} )
}
/**
* Create a new {@linkcode FaceDetector}.
*
* The {@linkcode FaceDetector} can be used to
* scan {@linkcode Face}s in a {@linkcode Frame}.
*/
export function createFaceDetectorOutput(
options: FaceDetectorOutputOptions
): CameraOutput {
return faceDetectorFactory.createFaceDetectorOutput( options )
}
/**
* Create a new image {@linkcode ImageFaceDetector}.
*
* The {@linkcode ImageFaceDetector} can be used to
* scan {@linkcode Face}s in a {@linkcode Frame}.
*/
export function createImageFaceDetector(
options?: FaceDetectorOptions
): ImageFaceDetector {
return imageFaceDetectorFactory.createImageFaceDetector( options ?? {} )
}