Project 3 Classes

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


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.


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 is derived from FileReader. It is used for reading binary files.


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


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


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


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).


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


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:


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.


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


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.


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]


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 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 is derived from ImageFormat. This image format allows you to load targa images.


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


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 is derived from Arguments. It has functionality to handle the arguments passed to the program when it is invoked from the command line.


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.