Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
vision-camera-remove-background
Advanced tools
Frame Processor Plugin to detect faces using MLKit Vision Face Detector for React Native Vision Camera!
vision-camera-remove-background
is a React Native library that integrates with the Vision Camera module to provide face detection functionality. It allows you to easily detect faces in real-time using the front camera and visualize the detected faces on the screen.
If you like this package please give it a ⭐ on GitHub.
yarn add vision-camera-remove-background
Then you need to add react-native-worklets-core
plugin to babel.config.js
. More details here.
Recommended way:
import {
StyleSheet,
Text,
View
} from 'react-native'
import {
useEffect,
useState
} from 'react'
import {useCameraDevice} from 'react-native-vision-camera'
import {
Camera,
DetectionResult
} from 'vision-camera-remove-background'
import { Worklets } from 'react-native-worklets-core'
export default function App() {
const device = useCameraDevice('front')
useEffect(() => {
(async () => {
const status = await Camera.requestCameraPermission()
console.log({ status })
})()
}, [device])
const handleFacesDetection = Worklets.createRunInJsFn( (
result: DetectionResult
) => {
console.log( 'detection result', result )
})
return (
<View style={{ flex: 1 }}>
{!!device? <Camera
style={StyleSheet.absoluteFill}
device={device}
faceDetectionCallback={ handleFacesDetection }
faceDetectionOptions={ {
// detection settings
} }
/> : <Text>
No Device
</Text>}
</View>
)
}
Or default way:
import {
StyleSheet,
Text,
View
} from 'react-native'
import {
useEffect,
useState
} from 'react'
import {
Camera,
useCameraDevice,
useFrameProcessor
} from 'react-native-vision-camera'
import {
detectFaces,
DetectionResult
} from 'vision-camera-remove-background'
import { Worklets } from 'react-native-worklets-core'
export default function App() {
const device = useCameraDevice('front')
useEffect(() => {
(async () => {
const status = await Camera.requestCameraPermission()
console.log({ status })
})()
}, [device])
const handleFacesDetection = Worklets.createRunInJsFn( (
result: DetectionResult
) => {
console.log( 'detection result', result )
})
const frameProcessor = useFrameProcessor((frame) => {
'worklet'
detectFaces(
frame,
handleFacesDetection, {
// detection settings
}
)
}, [handleFacesDetection])
return (
<View style={{ flex: 1 }}>
{!!device? <Camera
style={StyleSheet.absoluteFill}
device={device}
frameProcessor={frameProcessor}
/> : <Text>
No Device
</Text>}
</View>
)
}
OBS: Returned face bounds are relative to image size not to device screen size so you need to scale it by multiplying desired bounds data by screen size divided by frame size: bounds.X * (deviceWidth|Height / frame.width|height)
.
See example app for more details.
Here is a common issue when trying to use this package and how you can try to fix it:
Regular javascript function cannot be shared. Try decorating the function with the 'worklet' keyword...
:
react-native-reanimated
maybe you're missing this step.If you find other errors while using this package you're wellcome to open a new issue or create a PR with the fix.
This package was tested using the following:
react-native
: 0.73.4
(new arch disabled)react-native-vision-camera
: 3.9.0
react-native-worklets-core
: 0.3.0
react-native-reanimated
: 3.6.2
expo
: 50.0.7
Min Android/IOS versions:
Android SDK
: 26
(Android 8)IOS
: 13.4
Made with ❤️ by nonam4.
FAQs
Frame Processor Plugin to detect faces using MLKit Vision Face Detector for React Native Vision Camera!
The npm package vision-camera-remove-background receives a total of 2 weekly downloads. As such, vision-camera-remove-background popularity was classified as not popular.
We found that vision-camera-remove-background demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.