Giter VIP home page Giter VIP logo

node-rekognition-aws-facedetect's Introduction

node-rekognition

AWS Rekognition library

Installation

npm install node-rekognition

Use

Instantiation

const Rekognition = require('node-rekognition')

// Set your AWS credentials
const AWSParameters = {
    "accessKeyId": "XXX",
    "secretAccessKey": "XXX",
    "region": "XXX",
    "bucket": "XXX",
    "ACL": "XXX" // optional
}

const rekognition = new Rekognition(AWSParameters)

The ACL is optional and its possible values are: "private", "public-read", "public-read-write", "authenticated-read", "aws-exec-read", "bucket-owner-read", "bucket-owner-full-control" More info

Upload images to S3

Some methods from AWS Rekognition need one or more images uploaded to AWS S3 bucket

/**
 * Upload image or images array to S3 bucket into specified folder
 * 
 * @param {Array.<string>|string} imagePaths 
 * @param {string} folder a folder name inside your AWS S3 bucket (it will be created if not exists)
 */
const s3Images = await rekognition.uploadToS3(imagePaths, folder)

detectLabels

/**
 * Detects instances of real-world labels within an image 
 * 
 * @param {Object} s3Image 
 * @param {string} threshold (optional. Defaults 50)
 */
const imageLabels = await rekognition.detectLabels(s3Image)

detectFaces

/**
 * Detects faces within an image
 * 
 * @param {Object} s3Image
 */
const imageFaces = await rekognition.detectFaces(s3Image)

compareFaces

/**
 * Compares a face in the source input image with each face detected in the target input image
 * 
 * @param {Object} sourceS3Image 
 * @param {Object} targetS3Image 
 * @param {string} threshold (optional. Defaults 90)
 */
const faceMatches = await rekognition.compareFaces(sourceS3Image, targetS3Image, threshold)

detectModerationLabels

/**
 * Detects explicit or suggestive adult content in image
 * 
 * @param {Object} s3Image
 * @param {number} threshold (optional. Defaults 50)
 */
const moderationLabels = await rekognition.detectModerationLabels(s3Image, threshold)

createCollection

/**
 * Creates a collection 
 * 
 * @param {string} collectionId 
 */
const collection = await rekognition.createCollection(collectionId)

deleteCollection

/**
 * Deletes a collection 
 * 
 * @param {string} collectionId 
 */
const collection = await rekognition.deleteCollection(collectionId)

indexFaces

/**
 * Detects faces in the input image and adds them to the specified collection
 * 
 * @param {string} collectionId 
 * @param {Object} s3Image
 */
const facesIndexed = await rekognition.indexFaces(collectionId, s3Image)

listFaces

/**
 * List the metadata for faces indexed in the specified collection
 * 
 * @param {string} collectionId 
 */
const faces = await rekognition.listFaces(collectionId)

searchFaces

/**
 * Searches in the collection for matching faces of faceId
 * 
 * @param {string} collectionId 
 * @param {string} faceId 
 * @param {number} threshold (optional. Defaults 90)
 */
const faceMatches = await rekognition.searchFacesByFaceId(collectionId, faceId, threshold)

searchFacesByImage

/**
 * First detects the largest face in the image (indexes it), and then searches the specified collection for matching faces.
 * 
 * @param {string} collectionId 
 * @param {Object} s3Image 
 * @param {number} threshold (optional. Defaults 90)
 */
const faceMatches = await rekognition.searchFacesByImage(collectionId, s3Image, threshold)

Test

First of all, you must create a parameters.json file and set your AWS parameters. You have an example file parametrs.json.example

  • cp parameters.json.example parameters.json
  • vim parameters.json

Then:

  • npm install
  • npm test

Changelog

Releases are documented in the NEWS file

Requirements

node >= 7.10.0

Contributing

You are welcome contribute via pull requests.

More info about AWS Rekognition

http://docs.aws.amazon.com/rekognition/latest/dg/API_Operations.html http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Rekognition.html

node-rekognition-aws-facedetect's People

Contributors

oleurud avatar

Watchers

James Cloos avatar athiwatp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.