Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Paul Ruiz
Published

Facial Recognition Lost Child Finder

Small devices for finding lost children at large venues (like fairs or stores) using face recognition and cell network connectivity

AdvancedFull instructions provided2 days5,612
Facial Recognition Lost Child Finder

Things used in this project

Hardware components

Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
×1
Camera Module
Raspberry Pi Camera Module
×1
Hologram Nova
Hologram Nova
×1
Pi Zero USB shield
Not required, but makes developing for the board way easier since you can plug in a keyboard, mouse and the Hologram Nova all at once.
×1

Software apps and online services

Face Recognition Library
Hologram Python SDK

Story

Read more

Code

Demo code

Python
sudo python programname.py
import face_recognition
import picamera
import numpy as np
from Hologram.HologramCloud import HologramCloud
import urllib

camera = picamera.PiCamera()
#For a non-demo, use a better camera with higher resolution
camera.resolution = (320, 240)
output = np.empty((240, 320, 3), dtype=np.uint8)
camera_name = "demo"

face_locations = []
face_encodings = []

credentials = {'devicekey': 'INSERT_KEY_HERE'}
cloud = HologramCloud(credentials, network='cellular', authentication_type='csrpsk')
cloud.enableSMS()
phone_number = "+15551234567"

print cloud.version
print cloud.network_type

while True:
    sms_obj = cloud.popReceivedSMS()
    if sms_obj is not None:
        print sms_obj.message
        #replace urllib once hologram supports downloading non-string bytes
        urllib.urlretrieve(sms_obj.message, "lost_child.jpg")
        child_image = face_recognition.load_image_file("lost_child.jpg")
        child_encoding = face_recognition.face_encoding(child_image)[0]
        print "Lost child's face encoded"
        while True:
            camera.capture(output, format="rgb")
            face_locations = face_recognition.face_locations(output)
            if len(face_locations) > 0:
                print("Found {} faces in image.".format(len(face_locations)))
                for face_encoding in face_encodings:
                    match = face_recognition.compare_faces([child_encoding], face_encoding)
                    if match[0]:
                        recv = cloud.sendSMS(phone_number, 'Child found at camera: ' + camera_name)
                        print 'response message ' + cloud.getResultString(recv)

Credits

Paul Ruiz

Paul Ruiz

19 projects • 83 followers
Developer Relations Engineer @ Google ML/AI. IoT and mobile developer. Formally robotics.

Comments