🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

react-native-vision-camera-face-detector

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-vision-camera-face-detector

Frame Processor Plugin to detect faces using MLKit Vision Face Detector for React Native Vision Camera!

Source
npmnpm
Version
1.1.2
Version published
Weekly downloads
10K
-26.6%
Maintainers
1
Weekly downloads
 
Created
Source

📚 Introduction

react-native-vision-camera-face-detector 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.

🏗️ Features

  • Real-time face detection using front camera
  • Integration with Vision Camera library
  • Adjustable face visualization with customizable styles
  • Base64 frame convertion

đź§° Installation

yarn add react-native-vision-camera-face-detector

đź’ˇ Usage

OBS: Pixel format should be either yuv (recomended) or rgb (lower performance).

import { 
  StyleSheet, 
  Text, 
  View 
} from 'react-native'
import { 
  useEffect, 
  useState 
} from 'react'
import {
  Camera,
  useCameraDevice,
  useFrameProcessor
} from 'react-native-vision-camera'
import { detectFaces } from 'react-native-vision-camera-face-detector'
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 frameProcessor = useFrameProcessor((frame) => {
    'worklet'
    runAsync(frame, () => {
      'worklet'
      try {
        const detectionResult = detectFaces(frame)
        console.log('faces detected:', detectionResult.faces)
      } catch (error) {
        console.error(error)
      }
    })
  }, [])

  return (
    <View style={{ flex: 1 }}>
      {device? <Camera
        style={StyleSheet.absoluteFill}
        device={device}
        isActive={!!device}
        frameProcessor={frameProcessor}
        pixelFormat="yuv"
      /> : <Text>
        No Device
      </Text>}
    </View>
  )
}

đź‘· Built With

  • React Native
  • Google MLKit
  • Vision Camera

📚 Author

  • Luiz Carlos Ferreira - nonam4

Keywords

vision-camera

FAQs

Package last updated on 02 Feb 2024

Did you know?

Socket

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.

Install

Related posts