Comments (9)
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
});
from amazon-rekognition-developer-guide.
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
from amazon-rekognition-developer-guide.
Time to create a pull request
from amazon-rekognition-developer-guide.
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.
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.
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.
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.
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.
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.
No recent activity.
from amazon-rekognition-developer-guide.
Related Issues (20)
- Incorrect behavior for DetectLabels method/docs in javascript SDK HOT 3
- Ruby example for Detecting Labels in an Image HOT 1
- NodeJs example for Detecting Labels in an Image
- Ruby and NodeJs examples for Detecting Faces in an Image HOT 1
- Ruby and NodeJs Examples for Comparing Faces HOT 1
- Face comparasion result HOT 1
- 'faceId was not found in the collection.' occurs randomly in java using lambda HOT 2
- No mention of required headers for requests via REST HOT 2
- Golang example for detecting faces in Image HOT 1
- Golang example for detecting labels in Image HOT 1
- Error AccessDenied HOT 2
- Golang example for comparing faces HOT 1
- Golang example to read local image and Detect labels HOT 1
- Load testing issue HOT 1
- Java Json (Jackson) Serialization broken/howto? HOT 1
- SearchFaces throws InvalidParameterException: faceId was not found in the collection HOT 1
- Rekognition Error Handling redirect to proper Service Limit page HOT 1
- Aws Rekognition stop-stream-processor results in error AccessDeniedException
- Parameter validation failed:\nUnknown parameter in input: \"Features\" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amazon-rekognition-developer-guide.