Project 4 Classes

Please become familiar with the classes of project 4. Especially important are the classes Vector, Image, Face, Faces, EigFaces, User, Users, and Main.

Error

Error objects are thrown as exceptions whenever the code encounters some error that prevents it from continuing. The Error class defines various methods for constructing errors with useful error messages.

FileReader

Objects of classes derived from FileReader are used wherever the code reads any kind of file. FileReader itself is abstract. Methods are defined for reading various data types from files.

BinaryFileReader

BinaryFileReader is derived from FileReader. It is used for reading binary files.

TextFileReader

Like BinaryFileReader, but is used to read text files, like the image list.

FileWriter

Abstract class with methods for writing various data types to files.

BinaryFileWriter

Derived from FileWriter. Implements functionality to write various data types to binary files.

Array

Templatized class used to set up arrays of various objects. Use the resize method to reallocate an Array to a new size (the data in the Array is not preserved).

Vector

Derived from Array. Basically an Array of doubles, but also defines many important operations you will need over and over again in your code:

Image

Derived from Vector. An Image is a Vector with a width, height, and color depth. You can perform all the handy operations above on images. Here are some of the additional operations you can perform:

Face

Derived from Image. Faces are like images, but they have some additional functionality. When you call loadTarga on a face, the image is automatically resampled to the width and height of the face, converted to grayscale, and normalized. Thus the face must have the correct width and height set before you load a file into it. The subimage method of face creates a face from an area of an image. The area must have the same dimensions as the face.

User

Derived from Vector. A user is a vector of coefficients plus the user's name.

Users

A Users object is a database of User objects. It includes operators to find users by index or by name. It also includes functionality to read and write the database to and from file.

Faces

Derived from Array. A Faces object is a database of Face objects. It includes functionality to compute eigenfaces, to output all the faces as Targa files (include "%%" somewhere in the filename, it will be replaced with the file number), and to read and write the entire database to and from file. To access an image from a subroutine within this class, try using (*this)[i]

EigFaces

Derived from Faces. An EigFaces object stores a database of eigenfaces. It also stores the average face. It can be read and written to file just like Faces. Most of the functions you will be writing are methods of EigFaces.

ImageFormat

ImageFormat is an abstract class. Targa is the only class derived from it so far. If you wanted to be able to load other image formats you could derive a new image format from ImageFormat.

Targa

Targa is derived from ImageFormat. This image format allows you to load targa images.

CommandMap

CommandMap simply converts string commands to the values defined in enum Commands.

Arguments

Arguments is an abstract base class that handles arguments to the program. Currently only CommandLineArguments is derived from it. You could derive other useful things from it such as ScriptArguments for reading commands from a script, or RunTimeArguments to allow the user to enter commands at runtime.

CommandLineArguments

CommandLineArguments is derived from Arguments. It has functionality to handle the arguments passed to the program when it is invoked from the command line.

Main

Main is a class that contains the methods that run the program for you. You should add a method to Main for each new command you add to your program. The method should return void and take no arguments. In the method, write the code to carry out your command. You can use the methods of the Arguments class to extract various arguments from the command line. To make your new command get called, you must add a single line in each of Main::Main (main.cpp), CommandMap::CommandMap (commandmap.cpp), and enum Command (arguments.h). The first line stores a pointer to the method in a lookup table indexed by command value. The second line adds an entry to the command map that allows it to translate the command string from the program arguments to the command value. The third line declares the command value. Look at the code for the existing commands for examples.