Face-recognition program in Galileo IoT DevKit

asked 2015-05-13 08:29:33 -0600

GalileoUser gravatar image

updated 2015-05-13 08:39:33 -0600

berak gravatar image

Hi everybody.

I have the image IoT DevKit installed in my Galileo platform and I would like to write a program, it can be in python to do face recognition. I want my program works like that: There will be two folders: resources and results. Inside of resources I want another two folders (person1 and person2) and inside both I want to include pictures .jpg of faces. There will be a webcam connected in Galileo. So I will stand in front of the camera in order it takes a picture of my face. I click in a button in my Galileo, then it will take a picture and verify if my face is inside of person1 or person2 folders and I want the program save the picture in results and give me a signal the person is in the system or not, for example printing in SSH terminal a message saying that and later I want to send this signal as 0 or 1 in an output to use in external circuits. The only program I have is to do face detection, take a look:

import numpy as np
import cv2

# it starts the caputre
capture = cv2.VideoCapture(0)
# take the last received frame
ret,img = capture.read()
# save as pic.jpg

cv2.imwrite('pic.jpg', img)


capture.release()


face_cascade = cv2.CascadeClassifier('/home/root/haarcascade_frontalface_default.xml')
eye_cascade = cv2.CascadeClassifier('/home/root/haarcascade_eye.xml')

img = cv2.imread('pic.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)
for (x,y,w,h) in faces:
        cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
        roi_gray = gray[y:y+h, x:x+w]
        roi_color = img[y:y+h, x:x+w]
        eyes = eye_cascade.detectMultiScale(roi_gray)
        for (ex,ey,ew,eh) in eyes:
         cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)

cv2.imwrite('img.png', img)

This program also design squares on the eyes, mouth and face, so I have done the detection, but I still need the recognition. That's the first time I work with embedded systems and Galileo platform and all program I find is for linux in desktops. Thank you.

edit retag flag offensive close merge delete

Comments

"so I have done the detection" - not much, but a start ;)

for more, e.g. look here and here

berak gravatar imageberak ( 2015-05-13 09:57:52 -0600 )edit

You can check out the Python code for local binary pattern unless you have a specific way you want to implement the face detection. The Python code uses Numpy histogram and Skimage for texture matching. Haven't done LBP for facerec but I think they are similar.

fredreload gravatar imagefredreload ( 2015-05-13 23:36:06 -0600 )edit

Hi berak. I was trying to implemente the code you mentioned, but I find a problem in the lines: from facerec.feature import Fisherfaces and from ... import ... File "13mayreconhecimento.py", line 4 import Fisherfaces ^ IndentationError: unexpected indent

do you know what it means?

GalileoUser gravatar imageGalileoUser ( 2015-05-20 13:19:01 -0600 )edit