react-native-vision-camera-face-detector
Version:
Frame Processor Plugin to detect faces using MLKit Vision Face Detector for React Native Vision Camera!
74 lines (71 loc) • 1.58 kB
JavaScript
;
import React from 'react';
import { Camera as VisionCamera } from 'react-native-vision-camera';
// types
import useFaceDetectorOutput from '../hooks/useFaceDetectorOutput';
import { jsx as _jsx } from "react/jsx-runtime";
/**
* A view that detects {@linkcode Face}s in a Camera
* using the default front {@linkcode CameraDevice}.
*
*
* @example
* ```tsx
* function App() {
* const isFocused = useIsFocused()
* const appState = useAppState()
* const isActive = isFocused && appState === 'active'
* return (
* <Camera
* isActive={isActive}
* barcodeFormats={['all']}
* onFacesDetected={(faces) => {
* console.log(`Detected ${faces.length} faces!`)
* }}
* onError={(error) => {
* console.error(`Error detecting faces:`, error)
* }}
* />
* )
* }
* ```
*/
export function Camera({
onFacesDetected,
onError,
outputResolution,
cameraFacing,
autoMode,
windowWidth,
windowHeight,
performanceMode,
runLandmarks,
runContours,
runClassifications,
minFaceSize,
trackingEnabled,
...cameraProps
}) {
const output = useFaceDetectorOutput({
onFacesDetected,
onError,
outputResolution,
cameraFacing,
autoMode,
windowWidth,
windowHeight,
performanceMode,
runLandmarks,
runContours,
runClassifications,
minFaceSize,
trackingEnabled
});
return /*#__PURE__*/_jsx(VisionCamera, {
...cameraProps,
outputs: [output],
onError: onError
});
}
export default Camera;
//# sourceMappingURL=Camera.js.map