Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rodgomesc/vision-camera-face-detector

VisionCamera Frame Processor Plugin to detect faces using MLKit Vision Face Detector
https://github.com/rodgomesc/vision-camera-face-detector

Last synced: 4 days ago
JSON representation

VisionCamera Frame Processor Plugin to detect faces using MLKit Vision Face Detector

Awesome Lists containing this project

README

        

# vision-camera-face-detector

VisionCamera Frame Processor Plugin to detect faces using MLKit Vision Face Detector

## Installation

```sh
yarn add vision-camera-face-detector
```

## Usage

```js
import * as React from 'react';
import { runOnJS } from 'react-native-reanimated';

import { StyleSheet } from 'react-native';
import {
useCameraDevices,
useFrameProcessor,
} from 'react-native-vision-camera';

import { Camera } from 'react-native-vision-camera';
import { scanFaces, Face } from 'vision-camera-face-detector';

export default function App() {
const [hasPermission, setHasPermission] = React.useState(false);
const [faces, setFaces] = React.useState();

const devices = useCameraDevices();
const device = devices.front;

React.useEffect(() => {
console.log(faces);
}, [faces]);

React.useEffect(() => {
(async () => {
const status = await Camera.requestCameraPermission();
setHasPermission(status === 'authorized');
})();
}, []);

const frameProcessor = useFrameProcessor((frame) => {
'worklet';
const scannedFaces = scanFaces(frame);
runOnJS(setFaces)(scannedFaces);
}, []);

return device != null && hasPermission ? (

) : null;
}

```

## Contributing

See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.

## License

MIT