The Wia Developer Hub

Welcome to the Wia developer hub. You'll find comprehensive guides and documentation to help you start working with Wia as quickly as possible, as well as support if you get stuck. Let's jump right in!

Get Started    

AWS Rekognition

Wia & AWS

Wia & AWS

Amazon Rekognition makes it easy to add image to your applications. You just provide an image to the Rekognition API, and the service can identify the objects, people, text, scenes, and activities, as well as detect any inappropriate content. Amazon Rekognition also provides highly accurate facial analysis and facial recognition. You can detect, analyze, and compare faces for a wide variety of user verification, cataloging, people counting, and public safety use cases.

Detect Faces

Get Number of Faces

Create a Flow with the following nodes:

  • Event
  • Detect Faces (by AWS)
  • Run Function
  • Send Email

It should look like the one below.

In the Event node, set the Event Name to photo and add the Devices you would like the Flow to be triggered by.

In the Run Function node, add the following code to get the number of faces in the image.

if (input.body.faceDetails) {
  var faceCount = input.body.faceDetails.length;
  output.body.faceCount = faceCount;
} else { 
  output.body.faceCount = 0;
}

In the Send Email node, set the To Address and Subject line. In the Body of the email, add the following text.

Found ${input.body.faceCount} faces.

Publish an Event to Wia with the following parameters:

  • name - photo
  • file - Buffer of your file

After a few seconds you should be able to see the Event in your dashboard and receive an email to your To Address in the Send Email node.

Get Details of a Face

To access the details of a face, edit the code in the Run Function node.

You can get a particular face using the code input.body.faceDetails[i] where i is the face instance you would like to get.

The following variables are available:

Field Name
Type

ageRange

Object

ageRange.low

Number

ageRange.high

Number

beard

Object

beard.confidence

Number

beard.value

Boolean

confidence

Number

emotions

Array

emotions[i].confidence
Replace i by instance number
you would like to return e.g. 0, 1, etc.

Number

emotions[i].type
Replace i by instance number
you would like to return e.g. 0, 1, etc.

String

eyeglasses

Object

eyeglasses.confidence

Number

eyeglasses.value

Boolean

eyesOpen

Object

eyesOpen.confidence

Number

eyesOpen.value

Boolean

gender

Object

gender.confidence

Number

gender.value

String

landmarks

Array

landmarks[i].type
Replace i by instance number
you would like to return e.g. 0, 1, etc.

String

landmarks[i].x
Replace i by instance number
you would like to return e.g. 0, 1, etc.

Number

landmarks[i].y
Replace i by instance number
you would like to return e.g. 0, 1, etc.

Number

mouthOpen

Object

mouthOpen.confidence

Number

mouthOpen.value

Boolean

mustache

Object

mustache.confidence

Number

mustache.value

Boolean

pose

Object

pose.pitch

Number

pose.roll

Number

pose.yaw

Number

quality

Object

quality.brightness

Number

quality.sharpness

Number

smile

Object

smile.confidence

Number

smile.value

Boolean

sunglasses

Object

sunglasses.confidence

Number

sunglasses.value

Boolean

Example: How to check if someone is smiling

Build a Flow the same way as in the Get Number of Faces example above. In the Run Function node, change the code to the following:

if (input.body.faceDetails) {
  if (input.body.faceDetails.length > 0) {
    var face = input.body.faceDetails[0];
    output.body.isSmiling = face.smile.value;
  }
} else {
  output.body.isSmiling = false;
}

In the Send Email node, set the To Address and Subject line. In the Body of the email, add the following text.

Person smiling: ${input.body.isSmiling}

Detect Labels

This detects instances of real-world entities within an image. This includes objects like flower, tree, and table; events like wedding, graduation, and birthday party; and concepts like landscape, evening, and nature.

Get a List of Labels

Create a Flow with the following nodes:

  • Event
  • Detect Labels (by AWS)
  • Run Function
  • Send Email

It should look like the one below.

In the Event node, set the Event Name to photo and add the Devices you would like the Flow to be triggered by.

In the Run Function node the following variables are available in the input variable.

Field Name
Type

labels

Array

labels[i].confidence
Replace i by instance number
you would like to return e.g. 0, 1, etc.

Number

labels[i].name
Replace i by instance number
you would like to return e.g. 0, 1, etc.

String

orientationCorrection

String

Add the following code to get the labels of the photo:

output.body = JSON.stringify(input.body, null, 2);

In the Send Email node, set the To Address to your email address and Subject line to 'Detect Labels'. In the Body of the email, add the following text.

Got labels: ${input.body}

Publish an Event to Wia with the following parameters:

  • name - photo
  • file - Buffer of your file

After a few seconds you should be able to see the Event in your dashboard and receive an email to your To Address in the Send Email node.

Detect Text

Detects text in the input image and converts it into machine-readable text.

Get a List of Texts

Create a Flow with the following nodes:

  • Event
  • Detect Text (by AWS)
  • Run Function
  • Send Email

It should look like the one below.

In the Event node, set the Event Name to photo and add the Devices you would like the Flow to be triggered by.

In the Run Function node the following variables are available in the input variable.

Field Name
Type

textDetections

Array

textDetections[i].confidence
Replace i with instance number
you would like to return e.g. 0, 1, etc.

Number

textDetections[i].detectedText

String

textDetections[i].geometry

Object

textDetections[i].geometry.boundingBox

Object

textDetections[i].geometry.boundingBox.height

Number

textDetections[i].geometry.boundingBox.left

Number

textDetections[i].geometry.boundingBox.top

Number

textDetections[i].geometry.boundingBox.width

Number

textDetections[i].geometry.polygon

Array

textDetections[i].geometry.polygon[j]
Replace i and j with instance number
you would like to return e.g. 0, 1, etc.

Object

textDetections[i].geometry.polygon[j].x

Number

textDetections[i].geometry.polygon[j].y

Number

textDetections[i].id

Number

textDetections[i].parentId

Number

textDetections[i].type

String

Add the following code to get the texts of the photo:

var textList = [];
input.body.textDetections.forEach(function(td) {
	textList.push({
  	confidence: td.confidence,
    detectedText: td.detectedText
  });
});
output.body = JSON.stringify(textList, null, 2);

In the Send Email node, set the To Address to your email address and Subject line to 'Detect Text'. In the Body of the email, add the following text.

Got texts: ${input.body}

Publish an Event to Wia with the following parameters:

  • name - photo
  • file - Buffer of your file

After a few seconds you should be able to see the Event in your dashboard and receive an email to your To Address in the Send Email node.

AWS Rekognition