1.0.1 • Published 2 years ago

react-use-face-detection v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

✨ Live Demo ✨

📚 Introduction

Simple React Hook to detect faces from an HTMLImageElement or react-webcam video source. Powered by MediaPipe

💡 Usage

🧰 Installation

To install, you can use npm or yarn:

npm

npm install react-use-face-detection

yarn

yarn add react-use-face-detection

⚙️ Options

NameTypeOptionalDescription
mirroredbooleantrueThis enables a mirrored detection of the faces in the provided media source - e.g. if you flip the media source horizontally, this would enable the correct output of your flipped media source.
handleOnResults(results: FaceDetectionResults) => voidtrueCallback function that returns the FaceDetectionResults
faceDetectionOptionsFaceDetectionOptionstrueOptions for configuring the face detection model - see https://google.github.io/mediapipe/solutions/face_detection.html#javascript-solution-api
faceDetectionFaceDetectionfalseInitialize the face detection model from @mediapipe/face_detection
camera(cameraOptions: CameraOptions) => CameratrueInitialize the camera utility model from @mediapipe/camera_utils

🎁 Returned Values

NameTypeDescription
boundingBoxBoundingBox[]Returns details and coordinates of the bounding box around the detected face(s)
isLoadingbooleanReturns a boolean that detects whether if the model has been loaded
detectedbooleanReturns a boolean that detects whether if a face has been detected
facesDetectednumberReturns a number of faces that have been detected
webcamRefLegacyRefReturns a ref object for the react-webcam <Webcam/> node
imgRefRefObjectReturns a ref object for the <img/> element

👷 Built With

📚 Author