Moves faceparams out of FaceMovie. Starts implementing console user interaction

This commit is contained in:
julien Lengrand-Lambert
2012-04-25 18:25:23 +02:00
parent 4ab8d52d0e
commit 62f24e4fef
3 changed files with 43 additions and 12 deletions

View File

@@ -47,6 +47,7 @@ class FaceParams(object):
# postpend .xml
cascade_name = self.training_types[training_type] + ".xml"
# Setting up some default parameters for Face Detection
print os.path.join(xml_folder, cascade_name)
self.face_cascade = cv.Load(os.path.join(xml_folder, cascade_name))
# To be defined more precisely

View File

@@ -17,19 +17,17 @@ class FaceMovie(object):
Contains the core image processing functions.
Supports the communication layer with the end user interface.
'''
def __init__(self, in_folder, out_folder, param_folder):
def __init__(self, in_folder, out_folder, face_params):
'''
Constructor
'''
self.source= in_folder # Source folder for pictures
self.out = out_folder # Folder to save outputs
self.params_source = param_folder # Folder in which xml files can be found
self.guys = [] # List of pictures in source folder
# Setting up some default parameters for Face Detection
training_type = "frontal face alt"
self.face_params = FaceParams(self.params_source, training_type)
# Retrieving parameters for Face Detection
self.face_params = face_params
# Position of the center in output images
self.x_center = 0

View File

@@ -10,6 +10,7 @@ import sys
import argparse
import Facemovie
import FaceParams
class Facemoviefier():
"""
@@ -20,25 +21,52 @@ class Facemoviefier():
def __init__(self):
#inits Command Line Parser
self.parser = initCLParser()
self.args = self.initCLParser()
print self.args
# par folder should be known (contained somewhere in the installation)
root_fo = "C:\Users\jll\perso\workspace\FaceMovie"
par_fo = os.path.join(root_fo, "facemovie/haarcascades")
self.face_params = FaceParams.FaceParams(par_fo, "frontal face alt")
# Finally def ines the FaceMovie itself
self.Facemovie = Facemovie.FaceMovie(in_fo, out_fo, par_fo)
self.facemovie = Facemovie.FaceMovie(self.args['input'], self.args['output'], self.face_params)
def initCLParser(self):
"""
Inits and Configures the command line parser designed to help the user configure the application
"""
parser = argparse.ArgumentParser(description="Creates a movie from a bunch of photos containing a Face.")
return parser
# --- Arguments to be processed (for now) ---
#input folder
parser.add_argument('-i', '--input', help='Input folder of the images', required=True)
# output folder
parser.add_argument('-o', '--output', help='Output folder to save the results', required=True)
args = vars(parser.parse_args())
return args
def run(self):
"""
Runs all the steps needed to get the desired output
"""
self.facemovie.list_guys() # find images in input folder
self.facemovie.search_faces() # search for images with faces
# I want to change images so that all faces have the same size
self.facemovie.normalize_faces() # sets all faces to the same size
# I want to know the size of the output frame, knowing initial conditions
self.facemovie.find_out_dims() # finds output minimal size to get all eyes in the same place
#choose your final step
#self.facemovie.show_faces(1000)
#self.facemovie.save_faces(self.args['output'])
self.facemovie.save_movie(self.args['output'])
if __name__ == '__main__':
print sys.argv
#We need input_folder, output_folder, param_folder for now
"""
if len(sys.argv) == 4:
print "I trust your inputs!"
[in_fo, out_fo, par_fo] = sys.argv[1, :]
@@ -48,7 +76,11 @@ if __name__ == '__main__':
in_fo = os.path.join(root_fo, "data/input\Axel")
out_fo = os.path.join(root_fo, "data/output")
par_fo = os.path.join(root_fo, "facemovie/haarcascades")
"""
my_job = Facemoviefier()
my_job.run()
"""
my_movie = Facemovie.FaceMovie(in_fo, out_fo, par_fo)
my_movie.list_guys() # find images in input folder
my_movie.search_faces() # search for images with faces
@@ -61,5 +93,5 @@ if __name__ == '__main__':
#my_movie.show_faces(1000)
#my_movie.save_faces("output")
my_movie.save_movie("output")
"""
print "Facemovie finished !"