Main Page | Modules | Alphabetical List | Class List | Directories | File List | Class Members | Related Pages

Frame Class Reference

#include <frame.h>

List of all members.


Detailed Description

This class holds the data for a captured image.

The frame class is really just an extended struct. It allocates space for an image of the proper size, but can also do more complicated things like image processing. Color blob detection, saving to file, and displaying an image are just some of the planned features for this class.

Definition at line 56 of file frame.h.

Public Member Functions

 Frame ()
 Constructor.
 Frame (struct camParams params)
 Constructor.
 Frame (int x, int y, int bpp)
 Constructor.
 ~Frame ()
 Deconstructor.
void convertToHSV ()
 Converts a frame to HSV from RGB.
void convertToRGB ()
 Converts a frame to YUV420P from RGB.
int saveToFile (char *file, int fileType)
 Saves an image to file.
void filterNoise ()
 Filters noise out of a threshholded frame.
void copy (struct Frame *dest)
 Copies one frame to another.
threshStats thresh (int min1, int max1, int min2, int max2, int min3, int max3)
 Threshholds an image based on RGB or HSV values.
threshStats thresh (int min1, int max1, int min2, int max2, int min3, int max3, int colorFlag)
 Threshholds an image based on RGB or HSV values.
growStats grow (int pixelThresh, int numObjects)
 Runs the noise reducing grow filter and separates objects.
void setPixel (int x, int y, int r, int g, int b)
 Sets the color of a frame pixel.
void setLine (int x1, int y1, int x2, int y2, int r, int g, int b)
 Draws a line to the Frame buffer.
void clear (int r, int g, int b)
 Fills the frame with the specified color.

Public Attributes

unsigned char * buffer
 Array to hold pixel values.
unsigned char * buffer2
 Array to hold pixel values for conversions.
int width
 Width of frame.
int height
 Height of frame.
int palette
 Palette type of frame.
float redMask
 Percent of red to show (0.0 - 1.0).
float greenMask
 Percent of green to show (0.0 - 1.0).
float blueMask
 Percent of blue to show (0.0 - 1.0).
int masked
 Masking flag.


Constructor & Destructor Documentation

Frame::Frame  ) 
 

Constructor.

Initializes the frame and makes space for it in RAM. Uses a guess for the buffer size.

Definition at line 9 of file frame.cpp.

References blueMask, buffer, greenMask, height, masked, redMask, and width.

Frame::Frame struct camParams  params  ) 
 

Constructor.

Initializes the frame and makes space for it in RAM. Uses captured camera parameters to determine buffer size.

Parameters:
params - camParams struct used to determine buffer size.
Todo:
Add support for palettes other than 24-bit RGB

Frame::Frame int  x,
int  y,
int  bpp
 

Constructor.

Initializes the frame and makes space for it in RAM. Uses supplied parameters to determine buffer size.

Parameters:
x - width of frame.
y - height of frame.
bpp - bits per pixel (24 for RGB).

Definition at line 34 of file frame.cpp.

References blueMask, buffer, greenMask, height, masked, redMask, and width.

Frame::~Frame  ) 
 

Deconstructor.

Ensures that frame space in RAM is cleared and free to the OS.

Definition at line 46 of file frame.cpp.


Member Function Documentation

void Frame::clear int  r,
int  g,
int  b
 

Fills the frame with the specified color.

This method simply iterates through all the pixels in the Frame buffer and colors them to the given color. It uese the setPixel() method.

Parameters:
r - Red value of color.
g - Green value of color.
b - Blue value of color.

Definition at line 133 of file frame.cpp.

References height, setPixel(), and width.

Referenced by Map::render().

void Frame::convertToHSV  ) 
 

Converts a frame to HSV from RGB.

This method uses the RGBtoHSV() function to convert each pixel value form the RGB colorspace to the HSV colorspace.

Definition at line 51 of file frame.cpp.

References buffer, height, and width.

Referenced by Tracker::track().

void Frame::convertToRGB  ) 
 

Converts a frame to YUV420P from RGB.

This method uses the ccvt_420p_rgb32() function from the ccvt libarary to convert each pixel value form the YUV colorspace to the RGB colorspace.

Definition at line 65 of file frame.cpp.

References buffer, buffer2, height, and width.

Referenced by Camera::capture().

void Frame::copy struct Frame dest  ) 
 

Copies one frame to another.

This method simply copies the contents of this frame's buffer into the destination Frame's buffer. Other settings and variables are not passed. Make sure the destination Frame is of the proper type and size!

Parameters:
dest - Destination Frame object.

Definition at line 142 of file frame.cpp.

References buffer, height, and width.

Referenced by Tracker::track().

void Frame::filterNoise  ) 
 

Filters noise out of a threshholded frame.

This method is needed to filter out the noise that is usually associated with a threshhold operation. In this case, each pixel is checked to see that at least some of the pixels around it are also threshholded. If not, then the pixel in question is removed from the threshhold results.

Definition at line 291 of file frame.cpp.

References buffer, height, and width.

growStats Frame::grow int  pixelThresh,
int  numObjects
 

Runs the noise reducing grow filter and separates objects.

This method scans through a threshholded frame and looks for large groupings of pixels. These groups are identified and the centroid of the blob is calculated. The user can specify the number of groups to search for. Only the largest groups will be returned to the user and the rest will be eliminated.

Parameters:
pixelThresh - Minimum number of pixels in a grown object.
numObjects - Number of grown objects to find.
Returns:
growStats - Statistics on thresholded region.

Definition at line 223 of file frame.cpp.

References buffer, height, growStats::objects, growStats::size, width, growStats::x, Point2D::x, growStats::y, and Point2D::y.

int Frame::saveToFile char *  file,
int  fileType
 

Saves an image to file.

Reads the entire contents of the image buffer and copies it to a file, compressing it as specified by the fileType parameter.

Parameters:
file - Name of file to save
fileType - Type of compression to use (currently PPM or PNG)
Returns:
int - TRUE if successful, FALSE if error
Todo:
Add support for filetypes other than PPM

Definition at line 76 of file frame.cpp.

References buffer, height, and width.

void Frame::setLine int  x1,
int  y1,
int  x2,
int  y2,
int  r,
int  g,
int  b
 

Draws a line to the Frame buffer.

This method uses a fast, integer based line drawing algorithm to write a line to the Frame buffer.

Parameters:
x1 - Starting X coordinate of line.
y1 - Starting Y coordinate of line.
x2 - Ending X coordinate of line.
y2 - Ending Y coordinate of line.
r - Red value of line.
g - Green value of line.
b - Blue value of line.

Definition at line 340 of file frame.cpp.

References height, setPixel(), width, Point2D::x, and Point2D::y.

Referenced by Map::plotLine(), and Map::render().

void Frame::setPixel int  x,
int  y,
int  r,
int  g,
int  b
 

Sets the color of a frame pixel.

This method simply calculates the correct offset in the frame array and set the color to the value specified. This should be much faster than using the gui.setPixel()

Parameters:
x - X coordinate of pixel.
y - Y coordinate of pixel.
r - Red value of pixel.
g - Green value of pixel.
b - Blue value of pixel.

Definition at line 124 of file frame.cpp.

References buffer, and width.

Referenced by clear(), Map::plot(), and setLine().

threshStats Frame::thresh int  min1,
int  max1,
int  min2,
int  max2,
int  min3,
int  max3,
int  colorFlag
 

Threshholds an image based on RGB or HSV values.

This method scans through the entire frame buffer looking for pixel that satisfy the specified commands. For now the selected pixels are simply overwritten with the color bright green. It should be noted that the first min and max paramaters will roll over if the max is less than the min. This is useful for hue, where the span rolls back over at the color red.

Parameters:
min1 - Minimum red or hue value.
max1 - Maximum red or hue value.
min2 - Minimum green or saturation value.
max2 - Maximum green or saturation value.
min3 - Minimum blue or value value.
max3 - Maximum blue or value value.
colorFlag - If != 0, image will be colored with binary threshhold results.
Returns:
threshStats - Statistics on thresholded region.

Definition at line 154 of file frame.cpp.

References buffer, height, width, threshStats::x, and threshStats::y.

threshStats Frame::thresh int  min1,
int  max1,
int  min2,
int  max2,
int  min3,
int  max3
 

Threshholds an image based on RGB or HSV values.

This method is the old version of thresh. Please use the newer version which has support for colorFlag. This method will automatically initiate the binary coloring feature of the original thresh() method.

Parameters:
min1 - Minimum red or hue value.
max1 - Maximum red or hue value.
min2 - Minimum green or saturation value.
max2 - Maximum green or saturation value.
min3 - Minimum blue or value value.
max3 - Maximum blue or value value.
colorFlag - If != 0, image will be colored with binary threshhold results.
Returns:
threshStats - Statistics on thresholded region.

Definition at line 147 of file frame.cpp.


Member Data Documentation

int Frame::palette
 

Palette type of frame.

(see v4l API)

Definition at line 235 of file frame.h.


The documentation for this class was generated from the following files:
Generated on Wed Aug 31 15:16:39 2005 for Chair by  doxygen 1.4.2