mirror of
https://github.com/jlengrand/Ivolution.git
synced 2026-03-10 08:21:18 +00:00
Prepares dict for choice of training file. The user shall decide what he wants to detect
This commit is contained in:
@@ -10,13 +10,44 @@ class FaceParams(object):
|
||||
'''
|
||||
Simple class used to store parameters used for Face detection
|
||||
'''
|
||||
def __init__(self, xml_folder, i_scale=2, h_scale=1.2, h_flags=0, mn=2):
|
||||
def __init__(self, xml_folder, training_type, i_scale=2, h_scale=1.2, h_flags=0, mn=2):
|
||||
'''
|
||||
Constructor
|
||||
'''
|
||||
# Creates dictionary for all types of training files
|
||||
# some of them shall never be used. Perhaps would it be good to lower the dict size, or hide some of them
|
||||
training_types = {#eyes
|
||||
'eyes':"haarcascade_eye",
|
||||
'glasses':"haarcascade_eye_tree_eyeglasses",
|
||||
'left eye splits':"haarcascade_lefteye_2splits",
|
||||
'eye pair big':"haarcascade_mcs_eyepair_big",
|
||||
'eye pair small':"haarcascade_mcs_eyepair_small",
|
||||
'left eye':"haarcascade_mcs_lefteye",
|
||||
'right eye':"haarcascade_mcs_righteye",
|
||||
'right eye splits':"haarcascade_righteye_2splits",
|
||||
# frontal faces
|
||||
'frontal face alt':"haarcascade_frontalface_alt",
|
||||
'frontal face alt2':"haarcascade_frontalface_alt2",
|
||||
'frontal face':"haarcascade_frontalface_default",
|
||||
#profile face
|
||||
'profile face':"haarcascade_profileface",
|
||||
#body
|
||||
'full body':"haarcascade_fullbody",
|
||||
'lower body':"haarcascade_lowerbody",
|
||||
'upper body mcs':"haarcascade_mcs_upperbody",
|
||||
'upper body':"haarcascade_upperbody",
|
||||
#ear
|
||||
'left ear':"haarcascade_mcs_leftear",
|
||||
'right ear':"haarcascade_mcs_rightear",
|
||||
#mouth
|
||||
'mouth':"haarcascade_mcs_mouth",
|
||||
#nose
|
||||
'nose':"haarcascade_mcs_nose"
|
||||
}
|
||||
# postpend .xml
|
||||
cascade_name = training_types[training_type] + ".xml"
|
||||
# Setting up some default parameters for Face Detection
|
||||
self.face_cascade = cv.Load(os.path.join(xml_folder, "haarcascade_frontalface_alt.xml"))
|
||||
self.eye_cascade = cv.Load(os.path.join(xml_folder, "haarcascade_eye.xml"))
|
||||
self.face_cascade = cv.Load(os.path.join(xml_folder, cascade_name))
|
||||
|
||||
# To be defined more precisely
|
||||
self.min_size = (20,20)
|
||||
|
||||
@@ -25,7 +25,8 @@ class FaceMovie(object):
|
||||
self.guys = [] # List of pictures in source folder
|
||||
|
||||
# Setting up some default parameters for Face Detection
|
||||
self.face_params = FaceParams(self.params_source)
|
||||
training_type = "frontal face alt"
|
||||
self.face_params = FaceParams(self.params_source, training_type)
|
||||
|
||||
# Position of the center in output images
|
||||
self.x_center = 0
|
||||
|
||||
@@ -15,7 +15,7 @@ if __name__ == '__main__':
|
||||
in_fo = raw_input("indicate input folder:")
|
||||
out_fo = raw_input("indicate output folder:")
|
||||
par_fo = raw_input("indicate parameters folder:")
|
||||
elif len(sys.argv) == 2:
|
||||
elif len(sys.argv) == 4:
|
||||
print "I trust your inputs!"
|
||||
[in_fo, out_fo, par_fo] = sys.argv[1, :]
|
||||
else :
|
||||
|
||||
@@ -3,29 +3,5 @@ Created on 16 avr. 2012
|
||||
|
||||
@author: jll
|
||||
'''
|
||||
import os
|
||||
import cv
|
||||
from facemovie import *
|
||||
|
||||
# quick and dirty tests
|
||||
root_fo = "C:\Users\jll\perso\workspace\FaceMovie"
|
||||
in_fo = os.path.join(root_fo, "input\Axel")
|
||||
out_fo = os.path.join(root_fo, "output")
|
||||
par_fo = os.path.join(root_fo, "haarcascades")
|
||||
|
||||
my_movie = FaceMovie(in_fo, out_fo, par_fo)
|
||||
my_movie.list_guys()
|
||||
my_movie.search_faces()
|
||||
|
||||
# I want to change images so that all faces have the same size
|
||||
my_movie.normalize_faces()
|
||||
|
||||
# I want to know the size of the output frame, knowing initial conditions
|
||||
my_movie.find_out_dims()
|
||||
|
||||
# choose your final step
|
||||
#my_movie.show_faces(1000)
|
||||
#my_movie.save_faces("output")
|
||||
my_movie.save_movie("output")
|
||||
|
||||
print "Facemovie finished !"
|
||||
my_dict = {'a b c':1, 'b':2, 'c':3}
|
||||
print my_dict['a b c']
|
||||
Reference in New Issue
Block a user