Socket
Socket
Sign inDemoInstall

react-face-detection-hook

Package Overview
Dependencies
164
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-face-detection-hook

React face detection hook using @mediapipe/face_detection, @mediapipe/camera_utils and react-webcam


Version published
Weekly downloads
1
decreased by-85.71%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

📚 Introduction

React Hook to detect faces from react-webcam video source using MediaPipe

🧰 Installation

To install, you can use npm or yarn:

npm install react-face-detection-hook
# or
yarn add react-face-detection-hook

💡 Usage

import { 
  useFaceDetection,
  FaceDetectionResults,
  Camera,
  FaceDetection,
  Webcam
} from 'react-face-detection-hook'

function MyComponent() {
  const camWidth = ...
  const camHeight = ...
  const { webcamRef } = useFaceDetection( {
    handleOnFaceDetected,
    faceDetectionOptions: {
      model: 'short'
    },
    faceDetection: new FaceDetection( {
      locateFile: ( file ) => {
        return `https://cdn.jsdelivr.net/npm/@mediapipe/face_detection/${ file }`
      }
    } ),
    camera: ( {
      mediaSrc,
      onFrame
    } ) => new Camera( mediaSrc, {
      onFrame,
      width: camWidth,
      height: camHeight
    } )
  } ) 

  function handleOnFaceDetected({ 
    detections
  }: FaceDetectionResults){
    console.log('face detections', detections)
  }

  return (
    <Webcam
      ref={ webcamRef }
      style={ {
        width: camWidth,
        height: camHeight
      } }
    />
  )
}

👷 Built With

  • ReactJS - Frontend Javascript web framework
  • TypeScript - Open-source language which builds on JavaScript
  • MediaPipe - Machine Learning framework
  • React Webcam - Webcam Library

📚 Author

Keywords

FAQs

Last updated on 19 May 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc