SpiveyConall Laverty
Published © MIT

Build a Facial Recognition Camera

Build a facial recognition camera that can detect if someone is smiling (or not) and their age using Wia, Amazon Rekognition & Raspberry Pi.

IntermediateFull instructions provided2 hours7,151

Things used in this project

Story

Read more

Schematics

Raspberry Pi Camera

Code

Take a picture

JavaScript
'use strict';

var wia = require('wia')('your-device-secret-key');
var fs = require('fs');
var RaspiCam = require("raspicam");

// Setup the camera
var camera = new RaspiCam({
  mode: 'photo',
  output: __dirname + '/photo.jpg',
  encoding: 'jpg'
});

// Listen for the "start" event triggered when the start method has been successfully initiated
camera.on("start", function(){
  console.log("Starting to take photo.");
});

// Listen for the "read" event triggered when each new photo/video is saved
camera.on("read", function(err, timestamp, filename){
  console.log("New photo created.", timestamp, filename);

  // Publish the photo to Wia
  wia.events.publish({
    name: 'photo',
    file:  fs.createReadStream(__dirname + '/' + filename)
  });
});

// Take a photo
camera.start();

Credits

Spivey

Spivey

82 projects • 59 followers
Tourist in a Tutu || US Born || Melbourne/Mexico/California Raised || New Yorker at ❤️ || SF to Dublin to be COO of Wia the best IoT startup
Conall Laverty

Conall Laverty

8 projects • 25 followers
Founder & CEO at Wia. Code. Piano. Iron Man. I make things.
Thanks to Conall Laverty.

Comments