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

node-rekognition

v0.4.0

Published

AWS Rekognition library

Downloads

217

Readme

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|Buffer} image
 * @param {string} threshold (optional. Defaults 50)
 */
const imageLabels = await rekognition.detectLabels(image)

detectFaces

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

compareFaces

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

detectModerationLabels

/**
 * Detects explicit or suggestive adult content in image
 *
 * @param {Object|Buffer} image
 * @param {number} threshold (optional. Defaults 50)
 */
const moderationLabels = await rekognition.detectModerationLabels(image, 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