Giter Club home page Giter Club logo

Comments (9)

omenking avatar omenking commented on July 20, 2024 1

NodeJs Example:

// Add to your package.json
// npm install aws-sdk --save-dev

const fs   = require('fs')
const path = require('path')
const AWS  = require('aws-sdk')

const photo     = 'photo.jpg' // the name of file
const client    = new AWS.Rekognition();
const file_path = path.resolve(__dirname,photo)
const file      = fs.readFileSync(file_path)
const buffer    = new Buffer(file)

const config = new AWS.Config({
  accessKeyId: process.env.AWS_ACCESS_KEY_ID,
  secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  region: process.env.AWS_REGION
})


const params = {
  Image: {
    Bytes: buffer
  },
  MaxLabels: 10
}
client.detectLabels(params, function(err, response) {
  if (err) {
    console.log(err, err.stack); // an error occurred
  } else {
    console.log(`Detected labels for: ${photo}`)

    response.Labels.forEach(label => {
      console.log(`Label:      ${label.Name}`)
      console.log(`Confidence: ${label.Confidence}`)
      console.log("Instances:")
      label.Instances.forEach(instance => {
        let box = instance.BoundingBox
        console.log("  Bounding box:")
        console.log(`    Top:        ${box.Top}`)
        console.log(`    Left:       ${box.Left}`)
        console.log(`    Width:      ${box.Width}`)
        console.log(`    Height:     ${box.Height}`)
        console.log(`  Confidence: ${instance.Confidence}`)
      })
      console.log("Parents:")
      label.Parents.forEach(parent => {
        console.log(`  ${parent.Name}`)
      })
      console.log("------------")
      console.log("")
    }) // for response.labels
  } // if
});

Proof it works
Screen Shot 2019-08-01 at 1 43 20 PM

from amazon-rekognition-developer-guide.

omenking avatar omenking commented on July 20, 2024

Ruby, onto NodeJs

# Add to your Gemfile
# gem 'aws-sdk-rekognition'

require 'aws-sdk-rekognition'

credentials = Aws::Credentials.new(
   ENV['AWS_ACCESS_KEY_ID'],
   ENV['AWS_SECRET_ACCESS_KEY']
)

client   = Aws::Rekognition::Client.new credentials: credentials

photo = 'photo.jpg'
path = File.expand_path(photo)
file = File.read(path)
attrs = {
  image: {
    bytes: file
  },
  max_labels: 10
}
response = client.detect_labels attrs

puts "Detected labels for: #{photo}"

response.labels.each do |label|
  puts "Label:      #{label.name}"
  puts "Confidence: #{label.confidence}"
  puts "Instances:"
  label['instances'].each do |instance|
    box = instance['bounding_box']
    puts "  Bounding box:"
    puts "    Top:        #{box.top}"
    puts "    Left:       #{box.left}"
    puts "    Width:      #{box.width}"
    puts "    Height:     #{box.height}"
    puts "  Confidence: #{instance.confidence}"
  end
  puts "Parents:"
  label.parents.each do |parent|
    puts "  #{parent.name}"
  end
  puts "------------"
  puts ""
end

Proof it works
Screen Shot 2019-08-01 at 1 31 14 PM

from amazon-rekognition-developer-guide.

omenking avatar omenking commented on July 20, 2024

Time to create a pull request

from amazon-rekognition-developer-guide.

omenking avatar omenking commented on July 20, 2024

Oh looks like I am using detect labels instead of faces. Will double-check the other examples.
Ah nevermind. It appears between language examples they are not consistent between which method though they all do show the core functionality for the purpose of the example. So I think I'm okay here

from amazon-rekognition-developer-guide.

omenking avatar omenking commented on July 20, 2024

Want any Architectural diagrams?

@AWSChris if there are any technical architectural diagrams you think Rekognition AWS docs could benefit it takes me about 10mins to put graphics together following the strict guides of the AWS Architectural Guidelines.

For an example of graphic quality see here I how I was trying to create one for KMS docs
awsdocs/aws-kms-developer-guide#15

Any interest in a Rekognition tutorial?

I don't believe I saw an example on how to actually draw the lines so using RMagick (ImageMagick) and the Ruby SDK I detected labels, faces and celebrities. If could I think of a practical reason than I could tutorial something as such. The Rekognition docs are very good as they are though maybe a practical example of integrating multiple services might assist.

rectangle

I see lots of people use IBM Watson with their web-cam to detect faces in realtime. Maybe I could tutorial that?

There was this aws blog post, but it does not show all the steps or I could pair it down to something more practical:
https://aws.amazon.com/blogs/machine-learning/easily-perform-facial-analysis-on-live-feeds-by-creating-a-serverless-video-analytics-environment-with-amazon-rekognition-video-and-amazon-kinesis-video-streams/

If you have any buring ideas please share

from amazon-rekognition-developer-guide.

AWSChris avatar AWSChris commented on July 20, 2024

How about some Ruby and Node.js example for Amazon Textract? The pattern is the same as Rekognition - https://github.com/awsdocs/amazon-textract-developer-guide.

from amazon-rekognition-developer-guide.

omenking avatar omenking commented on July 20, 2024

I have a Textract example handy. I was building a Star Trek Karaoke service which would extract the videos of specific words to assemble a video of star trek cast. The end result would be a viral video such as this:

https://www.youtube.com/watch?v=E9xAcYSIxQ4

I was using Rekogintion to identify celebrities from the show.

I will see what I can do.

from amazon-rekognition-developer-guide.

AWSChris avatar AWSChris commented on July 20, 2024

Can I suggest adding examples to the AWS code gallery? - https://docs.aws.amazon.com/code-samples/latest/catalog/welcome.html. I can pick up the examples from there whilst giving you more exposure for your work.

from amazon-rekognition-developer-guide.

AWSChris avatar AWSChris commented on July 20, 2024

No recent activity.

from amazon-rekognition-developer-guide.

Related Issues (20)

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.