Main Page | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members

ARLib::Application::ARAppBase Class Reference

The ARAppBase class defines default functionality for the ARApplication class. More...

#include <arappbase.h>

List of all members.

Public Types

enum  IncrementModes { INCREMENT_MODE_ZOOM = 0, INCREMENT_MODE_PARAM = 1, INCREMENT_MODE_DISPLAY = 2 }
 Values denoting the current operation of the +/- keys e.g zoom, paramater update or element display. More...

Public Member Functions

virtual void OnInit (int *argc, char *argv[])
 Called when application is first started.
virtual void OnKeyPress (unsigned int state, unsigned int key, int x, int y, bool &actioned)
 Called when a key is pressed.
virtual void OnEraseBackground ()
 Called when the background needs clearing.
virtual void OnUpdate ()
 Called when the OpenGL window needs repainting.
virtual void OnPostUpdate ()
 Called after update but before OpenGL buffer is displayed on the screen.
virtual void OnResize (int width, int height)
 Called when the window has been resized.
virtual void OnDisplayMessage (const char *message)
 Called when the passed message text should be displayed on the screen.
virtual void OnDisplayUpdateModeValue (unsigned int id, const Utility::ARString &name)
 Called when the Update Mode parameter values needs displaying.
virtual void OnDisplayDisplayModeValue (bool *value, const Utility::ARString &name)
 Called when the Display mode value needs to be displayed.
virtual void OnIncrementUpdateModeValue (unsigned int id, int increment)
 Called when a particular update mode value needs updating.
virtual void OnDisplayFPS (unsigned int fps)
 Called when the frames per second needs to be displayed.
virtual void OnDisplayFrameNo (unsigned int frameNo)
 Called then the current frame number needs to be displayed.
virtual void OnDisplayFocalLength (int FocalLengthU, int FocalLengthV)
 Called when the focal length values need to be displayed.
virtual void OnDisplayMarkerEdge (Detection::ARBoundingBox *marker, Graphics::ARImage *image)
 Called when the edge around the detected marker needs to be drawn.
virtual void OnDisplayMarkerBox (Detection::ARBoundingBox *marker, Graphics::ARImage *image)
 Called when the bounding box needs to be drawn around the detected marker.
virtual void OnDisplayMarkerCorners (Detection::ARBoundingBox *marker, Graphics::ARImage *image)
 Called when the current marker corners need to be drawn.
virtual void OnDisplayMarkerId (Detection::ARBoundingBox *marker, Graphics::ARImage *image)
 Called when the current marker Id needs to be drawn.
virtual void OnDisplayAR (Detection::ARBoundingBox *marker)
 Called when the OpenGL object needs to be displayed for the current detected marker.
virtual void OnInitDisplayAR ()
 Called prior to displaying augmented objects.
virtual void OnSetMarkerPose (Detection::ARBoundingBox *marker)
 Called when the OpenGL projection and modelview matrices need to be set.
virtual void OnSegmentImage (Graphics::ARImage *image)
 Called when the current frame image needs to be segmented.
virtual void OnGetApplicationTitle (Utility::ARString &title)
 Called to retrive the title for the application.
virtual void OnGetDetailHelp (Utility::ARString &help)
 Called when detailed help text is needed for the current application.
virtual void OnInitHelp ()
 Called when help keys and command line switches should be defined.
void AddHelpSwitch (const Utility::ARString &Switch, const Utility::ARString &Description)
 Method for adding help for a particular command line switch.
void AddHelpKey (const Utility::ARString &Key, const Utility::ARString &Description)
 Method for adding help for a particular user key switch.
void Update ()
 Call this method to repaint screen.
int GetWinWidth ()
 Returns the width of the current window.
Utility::ARRecti GetWinRect ()
 Returns the window rectangle.
int GetWinHeight ()
 Returns the height of the current window.
int GetZoom ()
 Returns the zoom factor for the current viewport.
Graphics::ARImageGetImage ()
 Returns a pointer to the current image.
int GetMode ()
 Returns the current mode of operation (e.g. video streaming or static images).
int GetChannel ()
 Returns the current image channel/s that are being displayed.
Detection::ARMarkersGetMarkers ()
 Returns the current marker definitions.
Utility::ARConfigurationGetConfig ()
 Returns a pointer to the current configuration data.
bool GetConfigValue (const char *section, const char *item, Utility::ARString &value, const char *defvalue=0)
 Retrieves the value associated with the section/item combination from the configuration file.
bool GetConfigValues (const char *section, const char *item, std::vector< Utility::ARString > &values, const char *defvalue=0)
 Retrieves multiple values associated with the section/item combination from the configuration file.
int GetActualFPS ()
 Returns the actual frames per second being processed.
int GetFrameNo ()
 Returns the current frame number.
void AddUpdateMode (unsigned int id, const Utility::ARString &name)
 Adds an updateable parameter to the current list.
bool NextUpdateMode (bool forwards=true)
 Cycles through the available parameter update modes.
void AddDisplayMode (bool *value, const Utility::ARString &name)
 Adds an element that can be turned on or off.
bool NextDisplayMode (bool forwards=true)
 Cycles through the available element display modes.
void DrawBuffer (int x, int y, const char *buffer, const Graphics::ARColour &colour, void *font=GLUT_BITMAP_HELVETICA_18)
 Draws text to the current window.
void DrawBuffer (Utility::ARRecti rect, const char *buffer, int flags, Graphics::ARColour colour, void *font=GLUT_BITMAP_HELVETICA_18)
 Draws text to the current window.
void SetTimedMessage (const char *message)
 This method will display a message on the screen for a fixed duration.
int GetMarkerCount ()
 Returns the number of detected markers in the current frame.

Protected Member Functions

bool GetSnapshotFilename (Utility::ARString &filename)
 Returns the next available snapshot filename.

Protected Attributes

int markerCount
 The number of currently detected markers.
std::vector< ARUpdateMode > updateModes
 The _updateModes vector stores the various update modes that the user can cycle through.
int updateModeIdx
 Holds the index position of the current Update Parameters mode item.
std::vector< ARDisplayMode > displayModes
 The _displayModes vector stores the various element visibility modes that the user can cycle through.
int displayModeIdx
 Holds the index position of the current Element visibility mode item.
unsigned int incrementMode
 Denotes the current operation for the arrow keys. The value can be one of the IncrementModes enumeration.
int zoom
 Denotes the zoom level of the current view.
bool showUI
 Overide for the displaying of UI elements.
bool showFPS
 Denotes whether the frames per second should be displayed.
bool showFrameNo
 Denotes whether the current frame number should be displayed.
bool showFocalLength
 Denotes whether the current frame focal length should be displayed.
bool showBoundingBoxes
 Denotes whether bounding boxes should be drawn around potential marker regions.
bool showCorners
 Denotes whether corners of potential markers should be displayed.
bool showMarkerEdge
 Denotes whether a line should be draw around the detected marker.
bool showMarkerId
 Denotes whether the marker id should be displayed against the detected marker.
bool showAR
 Denotes whether the augmented elemented should be displayed.
int channel
 Denotes the current colour channel being display. The value can be one of the Channel enumeration.
int otsuOffset
 Denotes the amount the dynamic Otsu threshold value should be adjusted by.
bool useLuminance
unsigned int minArea
 Denotes the number of pixels that a bounding box must be to be deemed valid.
int fixedFocalLengthU
 Denotes the fixed focal length in the U direction.
int fixedFocalLengthV
 Denotes the fixed focal length in the V direction.
int currentFocalLengthU
 Denotes the current focal length in the U direction.
int currentFocalLengthV
 Denotes the current focal length in the V direction.
bool useFixedFocalLength
 Denotes whether to use fixed focal lengths or dyanamically calculate them based on marker position.
Detection::ARDetection detection
 The main marker detection object.
Utility::ARString defaultModelsConfigPath
 The default path to the models.conf file.
Utility::ARConfiguration modelsConfig
 The models configuration data.
Utility::ARString timedMessage
 Message to display for a short time.
Utility::ARPoint3Di rotation
 Specifies the default rotation of each object prior to being displayed.
bool takeSnapshot
 Denotes whether a snaphot tiff file should be saved after the next frame is rendered.
Utility::ARString snapshotLocation
 Defines the folder to write snapshots to.
Utility::ARString snapshotPrefix
 Defines the prefix to use when writing out snapshots. The final file name will be <snapshotprefix>.n.tif.


Detailed Description

The ARAppBase class defines default functionality for the ARApplication class.

To create custom application functionality, a new class should be created which is derived from the ARAppBase class.


Member Enumeration Documentation

enum ARLib::Application::ARAppBase::IncrementModes
 

Values denoting the current operation of the +/- keys e.g zoom, paramater update or element display.

Enumeration values:
INCREMENT_MODE_ZOOM  = (0) Updates zoom.
INCREMENT_MODE_PARAM  = (0) Updates configuration parameters.
INCREMENT_MODE_DISPLAY  = (0) Turning element visibility on or off.


Member Function Documentation

void ARAppBase::AddDisplayMode bool *  value,
const Utility::ARString name
 

Adds an element that can be turned on or off.

Update modes can be cycled using the relevant key. The +/- keys can then be used to turn the element on or off e.g. turn on/off the showing of fps.

Parameters:
value A pointer to the associated boolean value.
name A name to display for the parameter.

void ARAppBase::AddHelpKey const Utility::ARString Key,
const Utility::ARString Description
 

Method for adding help for a particular user key switch.

Parameters:
Key The key e.g. "F1".
Description The description of the key e.g. "Displays help."

void ARAppBase::AddHelpSwitch const Utility::ARString Switch,
const Utility::ARString Description
 

Method for adding help for a particular command line switch.

Parameters:
Switch The switch e.g. "filename <name>".
Description The description of the switch e.g. "Load the specified <name>."

void ARLib::Application::ARAppBase::AddUpdateMode unsigned int  id,
const Utility::ARString name
 

Adds an updateable parameter to the current list.

Updateable parameters can be cycled using the relevant key. The +/- keys can then be used to increment or decrement the associated value.

Parameters:
id A unique identifier for the parameter.
name A name to display for the parameter.

void ARLib::Application::ARAppBase::DrawBuffer Utility::ARRecti  rect,
const char *  buffer,
int  flags,
Graphics::ARColour  colour,
void *  font = GLUT_BITMAP_HELVETICA_18
 

Draws text to the current window.

Parameters:
rect The bounding rectangle for the text.
buffer A null terminated char buffer.
flags Denotes how to justify the text with the rectangle. This is a bitmask value and acceptible values from from the DrawBufferFlags enumeration.
colour The colour of the text.
font The font to use. The fonts are defined by the Glut library (Refer to Glut documentation (glutBitmapCharacter) for available fonts.

void ARLib::Application::ARAppBase::DrawBuffer int  x,
int  y,
const char *  buffer,
const Graphics::ARColour colour,
void *  font = GLUT_BITMAP_HELVETICA_18
 

Draws text to the current window.

Parameters:
x The column coordinate for the first character.
y The row coordinate for the first character.
buffer A null terminated char buffer.
colour The colour of the text.
font The font to use. The fonts are defined by the Glut library (Refer to Glut documentation (glutBitmapCharacter) for available fonts.

int ARAppBase::GetActualFPS  ) 
 

Returns the actual frames per second being processed.

Returns:
An integer representing the number of frames being processed per second.

int ARLib::Application::ARAppBase::GetChannel  ) 
 

Returns the current image channel/s that are being displayed.

Returns:
A value from the Channel enumeration.

bool ARAppBase::GetConfigValue const char *  section,
const char *  item,
Utility::ARString value,
const char *  defvalue = 0
 

Retrieves the value associated with the section/item combination from the configuration file.

Parameters:
section The section that the item belongs to.
item The item name to retrieve the value for.
value The ARString argument to receive the associated value;
defvalue The value to use if the section/item does not exist.
Returns:
True if the section/item exists otherwise false.

bool ARLib::Application::ARAppBase::GetConfigValues const char *  section,
const char *  item,
std::vector< Utility::ARString > &  values,
const char *  defvalue = 0
 

Retrieves multiple values associated with the section/item combination from the configuration file.

Parameters:
section The section that the item belongs to.
item The item name to retrieve the value for.
values The ARString vector argument to receive the associated values;
defvalue The value to use if the section/item does not exist.
Returns:
True if the section/item exists otherwise false.

int ARAppBase::GetFrameNo  ) 
 

Returns the current frame number.

Returns:
An Integer value representing the frame number.

ARImage * ARAppBase::GetImage  ) 
 

Returns a pointer to the current image.

Returns:
An integer value containing the zoom factor. A value of 1 is normal 1 to 1 mapping, 2 is twice normal size and so on.

ARMarkers * ARAppBase::GetMarkers  ) 
 

Returns the current marker definitions.

Returns:
A Pointer to the current ARMarkers object.

int ARAppBase::GetMode  ) 
 

Returns the current mode of operation (e.g. video streaming or static images).

Returns:
A value from the Mode enumeration.

bool ARLib::Application::ARAppBase::GetSnapshotFilename Utility::ARString filename  )  [protected]
 

Returns the next available snapshot filename.

Parameters:
filename Parameter to return the filename in.
Returns:
True if successful other false is returned.

int ARAppBase::GetWinHeight  ) 
 

Returns the height of the current window.

Returns:
An integer value containing the height in pixels of the window.

Utility::ARRecti ARLib::Application::ARAppBase::GetWinRect  )  [inline]
 

Returns the window rectangle.

Returns:
A RECT type containing the window coordinates.

int ARAppBase::GetWinWidth  ) 
 

Returns the width of the current window.

Returns:
An integer value containing the width in pixels of the window.

int ARLib::Application::ARAppBase::GetZoom  )  [inline]
 

Returns the zoom factor for the current viewport.

Returns:
An integer value containing the zoom factor. A value of 1 is normal 1 to 1 mapping, 2 is twice normal size and so on.

bool ARAppBase::NextDisplayMode bool  forwards = true  ) 
 

Cycles through the available element display modes.

Display modes allow visual aspects to be turned on or off using the +/- keys.

Parameters:
forwards Specify true to move forwards or false to move backwards.
Returns:
false if there are no modes to cycle through.

bool ARAppBase::NextUpdateMode bool  forwards = true  ) 
 

Cycles through the available parameter update modes.

Update modes allow specific configuration options to be updated using the +/- keys.

Parameters:
forwards Specify true to move forwards or false to move backwards.
Returns:
false if there are no modes to cycle through.

void ARAppBase::OnDisplayDisplayModeValue bool *  value,
const Utility::ARString name
[virtual]
 

Called when the Display mode value needs to be displayed.

The function should display the name and the value so that when using the +/- keys, the user can see the new value.

Parameters:
value Pointer to the current boolean value.
name The name to display with the value.

void ARAppBase::OnDisplayFocalLength int  FocalLengthU,
int  FocalLengthV
[virtual]
 

Called when the focal length values need to be displayed.

Parameters:
FocalLengthU The current U direction focal length.
FocalLengthV The current V direction focal length.

void ARAppBase::OnDisplayFPS unsigned int  fps  )  [virtual]
 

Called when the frames per second needs to be displayed.

Parameters:
fps The current frames per second.

void ARAppBase::OnDisplayFrameNo unsigned int  frameNo  )  [virtual]
 

Called then the current frame number needs to be displayed.

Parameters:
frameNo The current frame number.

virtual void ARLib::Application::ARAppBase::OnDisplayMarkerBox Detection::ARBoundingBox marker,
Graphics::ARImage image
[virtual]
 

Called when the bounding box needs to be drawn around the detected marker.

Parameters:
marker The ARBoundingBox marker object containing all the current marker information.
image The image to perform drawing operation on.

virtual void ARLib::Application::ARAppBase::OnDisplayMarkerCorners Detection::ARBoundingBox marker,
Graphics::ARImage image
[virtual]
 

Called when the current marker corners need to be drawn.

The default behaviour draws a small cross at each corner of the marker.

Parameters:
marker The ARBoundingBox marker object containing all the current marker information.
image The image to perform drawing operation on.

virtual void ARLib::Application::ARAppBase::OnDisplayMarkerEdge Detection::ARBoundingBox marker,
Graphics::ARImage image
[virtual]
 

Called when the edge around the detected marker needs to be drawn.

The default behaviour of this method is to draw a line between each of the corners.

Parameters:
marker The ARBoundingBox marker object containing all the current marker information.
image The image to perform drawing operation on.

virtual void ARLib::Application::ARAppBase::OnDisplayMarkerId Detection::ARBoundingBox marker,
Graphics::ARImage image
[virtual]
 

Called when the current marker Id needs to be drawn.

Parameters:
marker The ARBoundingBox marker object containing all the current marker information.
image The image to perform drawing operation on.

void ARAppBase::OnDisplayMessage const char *  message  )  [virtual]
 

Called when the passed message text should be displayed on the screen.

It is upto the custom implementation to determine how or where the message is displayed. The function is called when a timed message is to be displayed.

Parameters:
message The string to display.

virtual void ARLib::Application::ARAppBase::OnDisplayUpdateModeValue unsigned int  id,
const Utility::ARString name
[virtual]
 

Called when the Update Mode parameter values needs displaying.

The display should show the name and value so that when using the +/- keys, the user can see the new value.

Parameters:
id The unique identifier for the current update mode.
name The name of the parameter.

void ARAppBase::OnGetApplicationTitle Utility::ARString title  )  [virtual]
 

Called to retrive the title for the application.

Parameters:
title The ARString object to return the title text in.

void ARAppBase::OnGetDetailHelp Utility::ARString help  )  [virtual]
 

Called when detailed help text is needed for the current application.

Parameters:
help The ARString object to return the help text in.

void ARAppBase::OnIncrementUpdateModeValue unsigned int  id,
int  increment
[virtual]
 

Called when a particular update mode value needs updating.

/param id The unique identifier for the current update mode. /param increment The amount (positive or negative) by which the value should be incremented.

void ARAppBase::OnInit int *  argc,
char *  argv[]
[virtual]
 

Called when application is first started.

Enables the custom functionality to initialise itself and to process any custom command line switches.

Parameters:
argc Number of arguments.
argv Pointer to an array of switch values.

void ARAppBase::OnInitDisplayAR  )  [virtual]
 

Called prior to displaying augmented objects.

This function enables OpenGL parameters (e.g. lights, setup buffers, etc) to be set prior to displaying each AR element. The default behavior of this function sets up the OpenGL depth buffer and creates the viewport for the AR.

void ARAppBase::OnInitHelp  )  [virtual]
 

Called when help keys and command line switches should be defined.

The methods AddHelpSwitch and AddHelpKey should be called to load the availables command line switches and user keys.

void ARAppBase::OnKeyPress unsigned int  state,
unsigned int  key,
int  x,
int  y,
bool &  actioned
[virtual]
 

Called when a key is pressed.

Parameters:
state A bitmask value denoting various states of the keyboard.
key The ascii value of the key
x The mouse x coordinate when the key was pressed.
y The mouse y coordinate when the key was pressed.
actioned If the key is processed in the OnKeyPress function then the actioned parameter should be set to True so the application performs no further actions. The following code demonstrates decoding the state value
if (state & KEY_EXTENDED) std::cout << "Extended ";
if (state & KEY_SHIFT) std::cout << "Shift ";
if (state & KEY_ALT) std::cout << "Alt ";
if (state & KEY_CTRL) std::cout << "Ctrl ";

If the extended bit is set then the key value is one of the special glut key values e.g. GLUT_KEY_F1,GLUT_KEY_F2, GLUT_KEY_LEFT etc. Refer to Glut documentation for a complete list of special constants (glutSpecialFunc).

void ARAppBase::OnResize int  width,
int  height
[virtual]
 

Called when the window has been resized.

Parameters:
width The new width of the window
height The new height of the window

virtual void ARLib::Application::ARAppBase::OnSegmentImage Graphics::ARImage image  )  [virtual]
 

Called when the current frame image needs to be segmented.

This function should update the alpha channel of the image so that there are only black (0) and white (255) values. The default implementation of this function performs Otsu dynamic thresholding.

Parameters:
image The current image to modify the alpha channel.

void ARAppBase::OnSetMarkerPose Detection::ARBoundingBox marker  )  [virtual]
 

Called when the OpenGL projection and modelview matrices need to be set.

Parameters:
marker The ARBoundingBox marker object containing all the current marker information.

void ARAppBase::SetTimedMessage const char *  message  ) 
 

This method will display a message on the screen for a fixed duration.

Parameters:
message The message to display.


Member Data Documentation

bool ARLib::Application::ARAppBase::showUI [protected]
 

Overide for the displaying of UI elements.

If this value is false then no elements will be shown (regardless of their own show flag)

bool ARLib::Application::ARAppBase::useLuminance [protected]
 

Denotes whether the black and white segmentation should use a luminance formula or a simple average of the red, green and blue component values.


The documentation for this class was generated from the following files:
Generated on Wed Aug 31 18:01:39 2005 for ARLib by  doxygen 1.3.9.1