@vundl/react-native-uvc-camera
Version:
UVC Camera implementation for React Native
76 lines (56 loc) • 2.31 kB
Markdown
[](https://npmjs.org/package/react-native-uvc-camera "View this project on npm")
[](https://npmjs.org/package/react-native-uvc-camera "View this project on npm")
[](https://npmjs.org/package/react-native-uvc-camera "View this project on npm")
[](https://npmjs.org/package/react-native-uvc-camera "View this project on npm")
A React Native module for UVC camera access with face detection capabilities.
```sh
npm install react-native-uvc-camera
yarn add react-native-uvc-camera
```
```javascript
import { UVCCamera, FaceDetector } from 'react-native-uvc-camera';
// Using the camera component
const App = () => {
const handleFacesDetected = ({ faces }) => {
console.log('Detected faces:', faces);
};
return (
<UVCCamera
style={{ flex: 1 }}
onFacesDetected={handleFacesDetected}
faceDetectionMode={FaceDetector.Constants.Mode.FAST}
/>
);
};
// Using the face detector
const detectFaces = async (imageUri) => {
const faces = await FaceDetector.detectFacesAsync(imageUri, {
mode: FaceDetector.Constants.Mode.ACCURATE,
detectLandmarks: FaceDetector.Constants.Landmarks.ALL,
runClassifications: FaceDetector.Constants.Classifications.ALL,
});
console.log('Detected faces:', faces);
};
```
| Prop | Type | Description |
|------|------|-------------|
| deviceId | string | ID of the camera device to use |
| onFacesDetected | function | Callback that is invoked when faces are detected |
| faceDetectionMode | string | 'fast' or 'accurate' |
| faceDetectionLandmarks | string | 'none' or 'all' |
| faceDetectionClassifications | string | 'none' or 'all' |
Static method to detect faces in an image:
```javascript
FaceDetector.detectFacesAsync(uri, options)
```
- `uri`: string - The URI of the image to process
- `options`: object - Detection options
MIT