Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-face-detection-tc

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-face-detection-tc

react-native face detection using Google MLKit

  • 0.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
0
Weekly downloads
 
Created
Source

react-native-face-detection

react-native face detection using Google ML Kit.

Some part of the code is from react-native-firebase ml-vision package (version 6.4.0) but due to Google separate Firebase ML Kit into Google ML Kit and Firebase Machine Learning then the ml-vision will no longer available on react-native-firebase.

This package bring back face detection feature from ml-vision package.

Installation

You can use npm or yarn to install the latest version:

npm

npm install --save react-native-face-detection

yarn

yarn add react-native-face-detection

iOS

Run npx pod-install after installing the package

Usage

import FaceDetection, { FaceDetectorContourMode, FaceDetectorLandmarkMode, FaceContourType } from "react-native-face-detection";

async function processFaces(imagePath) {
  const options = {
    landmarkMode: FaceDetectorLandmarkMode.ALL,
    contourMode: FaceDetectorContourMode.ALL
  };

  const faces = await FaceDetection.processImage(imagePath, options);

  faces.forEach(face => {
    console.log('Head rotation on X axis: ', face.headEulerAngleX);
    console.log('Head rotation on Y axis: ', face.headEulerAngleY);
    console.log('Head rotation on Z axis: ', face.headEulerAngleZ);

    console.log('Left eye open probability: ', face.leftEyeOpenProbability);
    console.log('Right eye open probability: ', face.rightEyeOpenProbability);
    console.log('Smiling probability: ', face.smilingProbability);

    face.faceContours.forEach(contour => {
      if (contour.type === FaceContourType.FACE) {
        console.log('Face outline points: ', contour.points);
      }
    });

    face.landmarks.forEach(landmark => {
      if (landmark.type === FaceLandmarkType.LEFT_EYE) {
        console.log('Left eye outline points: ', landmark.points);
      } else if (landmark.type === FaceLandmarkType.RIGHT_EYE) {
        console.log('Right eye outline points: ', landmark.points);
      }
    });
  });
}

// Local path to file on the device
const imagePath = '/path/to/face-image.png';

processFaces(imagePath).then(() => console.log('Finished processing file.'));

Example

Check example foler.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Keywords

FAQs

Package last updated on 20 Sep 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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc