classes package

Submodules

classes.auxiliary module

class classes.auxiliary.Auxiliary(sizeX=100, sizeY=100, interpolation=2)[source]

Class that provides some auxiliary functions.

calcAccuracy(recognizedImages, totalFaceImages)[source]

Calculates the accuracy (percentage) using the formula: acc = recognizedImages / totalFaceImages * 100 :param recognizedImages: The number of recognized face images. :param totalFaceImages: The number of total face images. :return: The accuracy.

concatenateImages(leftImage, rightImage)[source]

Concatenate two images side by side (horizontally) and returns a new one. :param leftImage: The image that should be put to the left. :param rightImage: The image that should be put to the right. :return: The new concatenated image.

extractFilesPaths(path)[source]

Extract all paths for all files type. :param path: The directory path. :return: A list with all paths for all files.

extractImagesPaths(path)[source]

Extract all paths for each image in a directory. :param path: The directory path. :return: A list with all file paths.

getDefaultSize()[source]

Get the default image size defined (default is 100x100).

getInterpolationMethodName()[source]

Get the selected interpolation method name. :return: A string containing the interpolation method name.

isGrayscale(image)[source]

Check if an image is in grayscale. :param image: The image. :return: True if the image is in grayscale.

loadAllImagesForTest(testPath)[source]

Load all images for test. :param testPath: The test path. :return: Three lists with the images, labels and file names.

loadAllImagesForTrain(trainPath)[source]

Load all images for training. :param trainPath: The train path. :return: Three lists with the images, labels and file names.

loadImage(path)[source]

Load an image based on the path passed by parameter. :param path: The path to the image file. :return: The image object.

preprocessImage(path)[source]

Preprocess an image. Load an image, convert to grayscale and resize it. :param path: The image path. :return: The preprocessed image.

resizeImage(image, sizeX, sizeY, interpolationMethod)[source]

Resize an image. :param image: The image object. :param sizeX: The image width. :param sizeY: The image height. :param interpolationMethod: The interpolation method. :return: The resized image.

saveImage(fileName, image)[source]

Save an image based on the fileName passed by parameter. :param fileName: The file name. :param image: The image.

setDefaultSize(sizeX, sizeY)[source]

Set the default size. :param sizeX: Image width. :param sizeY: Image height.

toGrayscale(image)[source]

Convert an image to grayscale :param image: The image. :return: The image in grayscale.

writeTextFile(content, fileName)[source]

Write the content to a text file based on the file name. :param content: The content as a string. :param fileName: The file name (e.g. home/user/test.txt)

classes.ensemble module

class classes.ensemble.Ensemble(fralgorithms=[], auxiliary=<classes.auxiliary.Auxiliary instance>, voting=<classes.voting.Voting instance>)[source]

Class that provides an interface for the Ensemble

recognizeFaces(testPath)[source]

Function that tries to recognize each face (path passed by parameter).

reset()[source]

Reset all lists and results. It is used to reset all values to re-train the algorithm

resetResults()[source]

Reset results (including the test lists and the predictions) It is used to reset only the results of the tests

train(trainPath)[source]

Function responsible for train the face recognition algorithm based on the image files from the trainPath.

classes.face_recognition module

class classes.face_recognition.FaceRecognition(algorithm, auxiliary=<classes.auxiliary.Auxiliary instance>, threshold=-1)[source]

Class that provides an interface to the face recognition algorithms

recognizeFaces(testPath)[source]

Function that tries to recognize each face (path passed by parameter).

reset()[source]

Reset all values, including train and test paths

resetResults()[source]

Reset all results

train(trainPath)[source]

Function responsible for train the face recognition algorithm based on the image files from the trainPath.

classes.report module

class classes.report.Report(object)[source]

Class that provides an interface to generate reports

generateFullReport()[source]

Generate the full report. Return the content containing the information about each predicted image.

generateReportSummary()[source]

Generate a report summary with informations about the test. Return the content as a string.

printResults()[source]

Function used to show the results

saveAllResults(path=”)[source]

Function used to automatically save the report in a defined folder. Save the entire results, including the summary report, full report and all images.

saveReport(path=”)[source]

Function used to automatically save the report in a defined folder. Save only the text report not the images.

classes.voting module

class classes.voting.Voting(votingScheme=0, weights=[])[source]

Class the provides voting methods for the ensemble.

MAJORITY = 0
WEIGHTED = 1
getVotingSchemeName()[source]

Get the name of the selected voting scheme to be used in the report.

majorityVoting(subjects)[source]

Majority voting. Return -1 for empty list

vote(subjects, weights=[])[source]

Call the selected voting scheme

weightedVoting(subjects, weights)[source]

Weighted voting.

Module contents