Welcome to Facemovie’s documentation!

FaceMovie

class facemovie.Facemovie.FaceMovie(in_folder, out_folder, face_params)[source]

Main class of the whole application. Contains the core image processing functions. Takes a bunch of parameters and a list of images and tries to create a video out of it. Contains general methods, aimed at being used trough an interface.

calc_mean_face()[source]

Returns the mean size of all faces in input Used to correctly crop images

Note

Designed for internal use only

crop_im(image)[source]

If needed, crops the image to avoid having black borders.

Parameters:image (IplImage) – the image to be cropped
crop_im_new(a_guy)[source]

If needed, crops the image to avoid having black borders.

Parameters:image (IplImage) – the image to be cropped
find_crop_dims()[source]

Calculates smallest output image that can be used to avoid adding black borders on image It will later be used to create the final image. The idea is the same as for :func:find_out_dims , but while avoiding black brders.

find_out_dims()[source]

Calculates best output image size and position depending on faces found in guys. The system is simple. The output image should be as big as possible, and faces are always placed in the same position. Depending on that, the image input image is placed in the output at the correct position. Black borders are set everywhere else.

find_reference()[source]

Searched for the best face size we want to have. Defined (for now), as the smallest of all found faces.

:returns int - the reference size of the bounding square for faces.

list_guys()[source]

Aims at populating the guys list, using the source folder as an input. Guys list shall be sorted chronologically. .. note::In case no valid date is found, it is set to ‘’.

normalize_faces()[source]

Creates new images, normalized by face size A reference is given in input. The idea is to get all images to have the same size in Guy.

Parameters:reference (int) – the reference size of the face that we want to have (0)
number_guys()[source]

Simply returns the number of guys in the current to-be movie

Note

Designed for interface use only

out_display(im, name, time=1000, im_x=640, im_y=480)[source]

Displays the output image, for time ms. Setting time to 0 causes the image to remains open. Window name slightly changed to match output

Parameters:
  • im (IplImage) – the image to be saved, formatted as an OpenCV Image
  • name (string) – the name of the image to be saved
  • time (int) – time for which the image should be displayed (in ms) (1000)
  • im_x (int) – output size of the displayed image (in pixels) (640)
  • im_y (int) – output size of the displayed image (in pixels) (480)
save_faces(out_folder, im_format='png')[source]

Save all faces into out_folder, in the given image format

Parameters:
  • out_folder (string) – the location where to save the output image.
  • im_format (string) – Format in which the image should be saved (“png”)
save_movie(out_folder, fps=3)[source]

Creates a movie with all faces found in the inputs. Guy is skipped if no face is found.

Parameters:
  • out_folder (string) – the location where to save the output image.
  • fps (int) – the number of frames per second to be displayed in final video (3)
save_result(im, name, out_folder, ext)[source]

Saves output image to the given format (given in extension)

Parameters:
  • im (IplImage) – the image to be saved, formatted as an OpenCV Image
  • name (string) – the name of the image to be saved
  • out_folder (string) – the location where to save the image
  • ext (string) – Format in which the image should be saved (“png”)
search_faces()[source]

Searches for all faces in the guys we have Results to be stored directly in guys

Takes each image one after the other, and create a guy out of it. The Face of each guy is searched. In case no face is found, a warning is returned and Guy is set to None

set_crop_dims(crop_x, crop_y)[source]

Sets the cropping dimension in case they have been provided by the end user

Parameters:
  • crop_x (int) – dimension of the desired cropping in x (in number of face size)
  • crop_y – dimension of the desired cropping in y (in number of face size)
show_faces(mytime=1000)[source]

Show all faces that have been found for the guys. The time for which each image will be displayed can be chosen.

Parameters:mytime (int) – time for which the image should be displayed (in ms) (1000)

Facemoviefier

class Facemoviefier.Facemoviefier[source]

Class defining the interactions with the end user. Should be used as point of entry for all end users.

initCLParser()[source]

Inits and Configures the command line parser designed to help the user configure the application Defines all possible options, and also creats the Helper.

init_facemovie()[source]

Inits the Facemovie parameters, so that it can be run efficiently

..note ::
FIXME : par folder should be known (contained somewhere in the installation)
run()[source]

Runs all the steps needed to get the desired output Checks which parameters have been run, and runs the algorithm accordingly.

Eye

class facemovie.Eye.Eye[source]

Eye-like blob used in the Face Detection algorithm.

Note

This class is not used for now, but should get useful when implementing
the use interaction feature

Face

class facemovie.Face.Face[source]

Face-like blob used in the Face Detection algorithm.

Note

This class is the very root of our detection part for now; as Eye is not yet used. We use Faces to store data while processing images

Guy

class facemovie.Guy.Guy(image_id, date, source)[source]

A new Guy is declared for each input image. A Guy should have a face, and owns the input image.

create_debug_output()[source]

Creates output image If debug is set to true, output image is the input image with a red box around the most probable face.

Note

DEPRECATED

create_video_output(x_size, y_size, x_point, y_point)[source]

Creates image output, centering the face center with the required position If eq_ratio is set to something different than one, input image is scaled so that face/size = eq_ratio

Parameters:
  • x_size (int) – The size of the ouput image in x (in pixels)
  • y_size (int) – The size of the ouput image in y (in pixels)
  • x_point (int) – The center of the output image, where the Guy image has to fit in (in pixels)
  • y_point (int) – The center of the output image, where the Guy image has to fit in (in pixels)
Returns:

IplImage – The ouput image, centered to fit with all other images

find_date(date)[source]

This function takes a date as a string, and returns a date object. Used afterwards to sort images chronologically

Parameters:date (string) – The date where the image was taken
Returns:datetime – Returns a date object according to time library.
Raises :In case of error, set the date to be the current time.
has_face()[source]

Returns True of False whether images have been found for the current image or not.

Returns:boolean – True if at least one face has been found
in_display(time=1000, im_x=640, im_y=480)[source]

Displays the input image, for time ms. Setting time to 0 causes the image to remains open.

Parameters:
  • time (int) – The time for which image stays diaplyed (in ms). 0 causes the frams to remain open
  • im_x (int) – The output of the display frame in x (in pixels)
  • im_y (int) – The output of the display frame in y (in pixels)
load_image()[source]

This function is used to load the image when needed. To reduce memory load, only its location is saved in real time Returns an iplImage.

:returns IplImage - the input image, not modified; loaded using self.source

load_normalized_image()[source]

This function is used to load the normalized image when needed. Normalized images are used so that the face keeps the same size over time To reduce memory load, only the source image location is saved in real time Returns an iplImage.

:returns IplImage - the input image, normalized; loaded using self.source and resized afterwards

normalize_face(reference)[source]

Searches for best size for intermediate image, whose face fits reference size. This method allows faces to always keep the same size during all the video. Changes the center of the image, so that the final image can be resized accordingly.

Parameters:reference (int) – The refence size of the face (in pixels). Defined as the first face size for now
num_faces()[source]

Returns the number of faces found for this guy

Returns:int – The number of faces found for the input image
search_face(face_params)[source]

Search on the picture for a face. Populates faces list. This function is the only one containing scaling information

Set several Guy information, such as the face size, or the virtual center of the image

Parameters:face_params (string) – The type of file to be used to train the classifier.

Once Faces have been found, they are listed and ordered

sort_faces()[source]

Sorts faces by number of neighbours found, most probable one first

Parameters:face_params (string) – The type of file to be used to train the classifier.
Returns:A list of faces, ordered by probability. If no faces is found, returns a void list.
update_center()[source]

Using sorted faces, defines the new center of interest of the output image

Updates the center of the image, using the most probable face as reference. If no face was found, the center is not updated.

training_types

FaceParams

class facemovie.FaceParams.FaceParams(xml_folder, training_type, i_scale=2, h_scale=1.2, h_flags=0, mn=2)[source]

Simple class used to store parameters used for Face detection

Libs

Libs – exif

facemovie.lib.exif.parse_tiff_fortiff(tiff, mode)[source]

Parse a real tiff file, not an EXIF tiff file.

Indices and tables

Table Of Contents

This Page