Skip to content

Instantly share code, notes, and snippets.

@OlafenwaMoses
Created May 13, 2019 15:08
Show Gist options
  • Save OlafenwaMoses/6760745644e9d9fcf5d4268aa7d6fd47 to your computer and use it in GitHub Desktop.
Save OlafenwaMoses/6760745644e9d9fcf5d4268aa7d6fd47 to your computer and use it in GitHub Desktop.
const request = require("request")
const fs = require("fs")
const easyimage = require("easyimage")
image_stream = fs.createReadStream("family.jpg")
var form = {"image":image_stream}
request.post({url:"http://localhost:80/v1/vision/face", formData:form},function(err,res,body){
response = JSON.parse(body)
predictions = response["predictions"]
for(var i =0; i < predictions.length; i++){
pred = predictions[i]
gender = pred["gender"]
y_min = pred["y_min"]
x_min = pred["x_min"]
y_max = pred["y_max"]
x_max = pred["x_max"]
easyimage.crop(
{
src: "family.jpg",
dst: i.toString() + "_.jpg",
x: x_min,
cropwidth: x_max - x_min,
y: y_min,
cropheight: y_max - y_min,
}
)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment