\section{Introduction}
{\em Pfinder} is a real-time system for tracking and interpretation of people. It
runs on a standard SGI Indy computer, and has performed reliably on
thousands of people in many different physical locations.  The system uses
a multi-class statistical model of color and shape to segment a person
from a background scene, and then to find and track people's
head and hands in a wide range of viewing conditions.
Pfinder produces a real-time representation of a user useful for applications
such as wireless interfaces, video databases, and low-bandwidth coding,
without cumbersome wires or attached sensors.

\section{Structure}

The structure of the program is shown in figure \ref{fig1}.

The code is written in C and in C++ because of historical reasons. It is basically composed of two different
types of code:
\begin{enumerate}
\item Backsub code: All the modules coming from this code start by {\bf bs} and it's
written in C. It performs tasks as
segmentating the background from the foreground (bsClassify.c), finding the silhouette
of the person (bsSegment.c) or determining the color classes of the foreground blobs (bsColor.c).
\item pfinder code: This is C++ code that extracts the contour of the person (pfContour.c++), 
the features (pfFeatures.c++), interprets the gestures (pfGestures.c++), applies connectivity
constraints in the growing process (pfMorphology.c++).
\end{enumerate}
 
The principal parts of it are:

\subsection{Main program: pfinder-main.c++}

The main program can be called with the following options:

 pfinder [-{nvX}] [-alive] [-expert] [-b <number>] [-d <decimati>] \\
[-D <number>] [-T] [-t] [-R] [-single] [-seeds] [-S] [-E <erode>] \\
[-w <width>] [-h <height>] [-size <height> <width>] [-z <zoom>] \\
[-f <max>] [-in <conn>] [-nb <number>] [-mn <stdev>] [-an <stdev>] \\
[-gs <x> <y>] [-gl <x> <y>] [-gp <sit> <bent>] [-gm <move>] [-pg] \\
[-plrf <freq>] [-plrm] [-hand <min> <max>] [-noslow] [-help] \\
[-dumpfile <file>] [-statfile <file>] [-contourfile <file>] [-savefile <file>] [-chroma <chroma>] 

Required Arguments:


Optional Arguments:

        -n : Toggle whether to use ALIVE interface [1|0]

        -v : Main program verbose mode on [0|1]
                bsColor and VL modules verbose

        -X : Use X Interface [1|0]

        -alive : Alive Demo

        -expert : Expert Mode (anti-ALIVE)

        -b <number> : 
                <number> = Number of BG Frames (integer) [40]

        -d <decimati> : 
                <decimati> = Decimation factor (integer) [1]

        -D <number> : Dump mode on, images from VL to cout
                <number> = Number of frames to dump (integer) [0]

        -T : Thad mode: track green and red blobs

        -t : Stat mode: vlob centers to cout

        -R : Read mode on, images fm cin

        -single : loop on first captured image [0|1]

        -seeds : mark zoomgrow seeds on image [0|1]

        -S : Save mode on, bitmaps to cout

        -E <erode> : 
                <erode> = erode multiple (integer) [10]

        -w <width> : 
                <width> = Width of images (integer) [640]

        -h <height> : 
                <height> = Height of images (integer) [480]

        -size <height> <width> : 
                <height> = Height of images (integer) [480]
                <width> = Width of images (integer) [640]

        -z <zoom> : 
                <zoom> = Zoom factor (integer) [4]

        -f <max> : 
                <max> = Max number of foreground classes (integer) [8]


        -in <conn> : 
                <conn> = 
                        0: INDY_COMPOSITE
                        1: INDY_SVIDEO
                        0: GALILEO_SVIDEO_1
                        1: GALILEO_SVIDEO_2
                        2: GALILEO_SVIDEO_3
                        3: GALILEO_COMPOSITE_1
                        4: GALILEO_COMPOSITE_2
                        5: GALILEO_COMPOSITE_3
                        6: GALILEO_YRB_1
                        7: GALILEO_YRB_2
                                 (integer) [1]

        -nb <number> : 
                <number> = Number of VL buffers to use (integer) [3]

        -mn <stdev> : 
                <stdev> = KF: Std dev of mmt noise (float) [1]

        -an <stdev> : 
                <stdev> = KF: Std dev of accel noise (float) [1]

        -gs <x> <y> : 
                <x> = x small (float) [0.3]
                <y> = y small (float) [-0.35]

        -gl <x> <y> : 
                <x> = x large (float) [0.38]
                <y> = y large (float) [0]

        -gp <sit> <bent> : 
                <sit> = sit (float) [0.8]
                <bent> = bent (float) [0.9]

        -gm <move> : 
                <move> = move (float) [2]

        -pg : print gestures [0|1]

        -plrf <freq> : 
                <freq> = freq of report (integer) [10000]

        -plrm : report moves [0|1]

        -hand <min> <max> : 
                <min> = min hand (integer) [40]
                <max> = max hand (integer) [80]

        -noslow : Turn off rate reporting [1|0]

        -help : Prints usage

        -dumpfile <file> : 
                <file> = File to dump input to (string) []

        -statfile <file> : 
                <file> = File to save statistics to (string) []

        -contourfile <file> : 
                <file> = File ot save contours to (string) []
        -savefile <file> : 
                <file> = File to save segments to (string) []

        -chroma <chroma> : use chromakey instead of aquiring background
                <chroma> = chroma to key on %2x%2x%2x (string) []



The first taks to do is the initialization of all the structures handled by the program.
Depending on the options typed by the user some special initializations must be done. Among the
initializations that are performed, we have: {\em lite::initialize()} for initialising {\em lite.c++},
{\em bsClassifyInitialize} for the background classes, {\em bsXInitialize} for the X interface as well
as the procedures for creating the user's display.

The program can read the input images from a file or from the camera. In both cases, it starts an
infinite loop and process each frame by calling the internal function {\em processFrame}. If there is
an X user interface, then it also handles all the events coming from the client.  

\subsubsection{processFrame( iveImage *image)}

\begin{enumerate}
\item Background extraction:
Before starting the processing of the input images, pfinder needs to characterize the background.
In order to do that, it reads the first {\em numberOfBGFrames} of the sequence. These frames 
cannot have any moving object in them because the program assumes that they are just background and
extracts all the background information. Once it has read the frame number {\em numberOfBGFrames}, it
calls the {\em bsClassifyMakeBackgroundClasses} to make the background classes:
 

\item Images processing:


\end{enumerate}
