Ask Your Question

GalileoUser's profile - activity

2015-05-25 09:37:33 -0600 answered a question face recognition with opencv and python

Hi Berak, are you still there?

2015-05-24 11:26:15 -0600 received badge  Enthusiast
2015-05-23 22:32:46 -0600 commented question face recognition with opencv and python

Then you said the program uses the 1st image from the folder for testing, which folder? root or the 1st image in the person1 folder (which is inside the folder images), that are actually my data? If it happens so, what do I need to change in the program to make it to user the image captured01.jpg inside root folder, which was taken by a webcam?

2015-05-23 22:27:10 -0600 commented question face recognition with opencv and python

so my program facerec_demo.py is the the folder 'root' and inside this folder I have other two folders 'images' and 'resultados'. Inside 'images' I have other two folders, 'person1' and 'person2' where the images really are, so I thought I needed to change 'None' to 'resultado', but when I do that the program says resultado isn't defined

File "facerec_demo.py", line 58, in <module>
    out_dir = resultado
NameError: name 'resultado' is not defined

but when I leave None it prints USAGE: facerec_demo.py </images> [</resultado>]

it means the program ends in the 'if'

if len(sys.argv) < 2: print "USAGE: facerec_demo.py </images> [</resultado>]" sys.exit()

what does mean len(sys.argv) < 2?

Oh ok, so it save the images as teste.png.

2015-05-23 22:20:13 -0600 commented question face recognition with opencv and python

1) opencv tutorial suggest to use pgm, then I need to convert my pictures to this format, right? 2) I'm running my program from ssh terminal on my macbook. Should I not replace the sys.argv[1] by the name of the folder where the images are? (in this case its name is 'images'), since it's an atribute of the function 'read_images'. 'resultado' is a folder where I want to save the picture after all process. In the original code phillip wrote

if __name__ == "__main__":
   # This is where we write the images, if an output_dir is given
   # in command line:
   out_dir = None
   # You'll need at least a path to your image data
2015-05-22 07:50:35 -0600 received badge  Editor (source)
2015-05-22 07:45:30 -0600 asked a question face recognition with opencv and python

I'm trying to use the code showed here http://answers.opencv.org/answers/105... to do face recognition.

I have two folders, images and resultado, inside images I have folders person1 and person2, inside them I have pictures.

  • first question: can the type of my image data be .jpg?
  • second question: in this line [X,y] = read_images(path=sys.argv[1],sz=(70,70)) what is sys.argv[1]? Should I replace it by "images" because my data is there? When I try to run the program I find the error:

    File "facerec_demo.py", line 103 [X,y] = read_images(path=sys.argv[1],sz=(70,70)) ^ IndentationError: unexpected indent

  • third question: I want my program take a image and compare with the data. Do this line do that?cv2.imwrite("test.png", X[0]).

The code is as follows:

#!/usr/bin/env python
# Software License Agreement (BSD License)
#
# Copyright (c) 2012, Philipp Wagner <bytefish[at]gmx[dot]de>.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
#  * Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#  * Redistributions in binary form must reproduce the above
#    copyright notice, this list of conditions and the following
#    disclaimer in the documentation and/or other materials provided
#    with the distribution.
#  * Neither the name of the author nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.


import os
import sys
import cv2
import numpy as np

def normalize(X, low, high, dtype=None):
    """Normalizes a given array in X to a value between low and high."""
    X = np.asarray(X)
    minX, maxX = np.min(X), np.max(X)
    # normalize to [0...1].    
    X = X - float(minX)
    X = X / float((maxX - minX))
    # scale to [low...high].
    X = X * (high-low)
    X = X + low
    if dtype is None:
        return np.asarray(X)
    return np.asarray(X, dtype=dtype)


def read_images(path, sz=None):
    """Reads the images in a given folder, resizes images on the fly if size is given.

    Args:
        path: Path to a folder with subfolders representing the subjects (persons).
        sz: A tuple with the size Resizes 

    Returns:
        A list [X,y]

            X ...
(more)
2015-05-20 13:19:01 -0600 commented question Face-recognition program in Galileo IoT DevKit

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?

2015-05-13 08:35:18 -0600 asked a question Face-recognition program in Galileo IoT DevKit

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.