npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@goteam/face-api

v1.2.1

Published

Facial Recognition SDK

Downloads

37

Readme

This package leverages the power of @mediapipe/tasks-vision, a robust framework for computer vision tasks. If you wish to tailor your facial recognition experience to your unique needs and preferences, we encourage you to explore the extensive documentation provided by the Mediapipe team. This documentation offers comprehensive insights and resources for customizing and enhancing your facial recognition capabilities

Installation

 npm install @goteam/face-api

Quick Start

  • Instantiating Face API

    You can quickly set up the Face API by importing the FaceApi class and creating an instance. Optionally, you can specify a model file path as a parameter.

    import { FaceApi } from "@goteam/face-api"
    
    /**
     * Create an instance of the Face API.r 
     * 
     * @param {?String} model - (Optional) Specify a model file path.
     */
    const faceApi = await FaceApi.make();
  • Face Detector

    Once you've instantiated the FaceApi class, you can access the face detector module to work with face detection.

    /**
     * To use the face detector module, provide an HTMLVideoElement as a parameter.
     * 
     * @param {HTMLVideoElement} video - HTML video element for face detection.
     * @param { FaceDetectorOptions } config - (optional)
     */
    const faceDetector = faceApi.faceDetector(config);
    
    // Once you have the faceDetector instance, you can chain methods to perform actions.
    
    /**
     * Display bounding boxes around detected faces in the video.
     */
    faceDetector.withBoundingBox();
    
    /**
     * Display bounding boxes around detected faces in the video.
     * @param {String} rgba - Change the color of the bounding box.
     */
    faceDetector.setBoundingBoxColor(rgba);
      
    /**
     * Hide bounding boxes around detected faces in the video.
     */
    faceDetector.hideBoundingBox();
    
    /**
     * Generate an HTMLImageElement containing the detected face(s).
     * 
     * @param { getFaceParameters } params
     * If more faces are detected than allowed, it throws a { NumberOfFacesAllowedError }.
     */
    faceDetector.getFaces(params);
    
    /**
     * Sets the source of the video or image element.
     *
     * @param {HTMLVideoElement|HTMLImageElement} source - The video or image element to set as the source.
     * @return {FaceDetector} - Returns the current instance of the object.
     */
    faceDetector.setSource(source);

    This quick start guide helps you set up the Face API, instantiate it, and use the face detector module to perform face detection tasks efficiently.

    • Image Segmentation

      /**
       * To use the image segmenter module.
       * 
       * @param { ImageSegmenterOptions } config - (optional)
       */
      const segmenter = faceApi.imageSegmenter(config);
        
      /**
       * Extract segments from images
       * @param {HTMLImageElement} - The image source to be extracted
       * @param {?Array} - (optional) The image source to be extracted
       * 
       * @return HTMLImageElement
       */
      segmenter.extractSegment(image, segments);
  • Face Matcher

    You can utilize the face matcher by accessing the faceAPI variable.

    /**
     * To work with the face matcher module, you can directly invoke the `matcher` method.
    *
    * @param { ImageEmbedderOptions } config - (optional) You can also provide configuration settings for the matcher.
    */
    const faceMatcher = faceApi.matcher(config);
    
    /**
    * Retrieve the floating-point embeddings of the image. Please note that this will return embeddings only for the first detected person.
    * @param {String | HTMLImageElement} image: - the image source for generate image embeddings
    *
    * @return Embedding
    */
    faceMatcher.getEmbeddings(image);
    
    /**
    * Obtain similarities between the source image supplied to the samples.
    */
    faceMatcher.similarities(source: HTMLVideoElement | HTMLImageElement): Promise<number | undefined>;
    

    For a more streamlined and cleaner approach, you can chain these methods as follows:

    const similarities = faceMatcher.setSamples(imageSamples).similarities(image);