Wavelet and Image class library  1.3.2
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
ColorVideo Class Reference

#include <ColorVideo.hh>

Inheritance diagram for ColorVideo:
Inheritance graph
[legend]
Collaboration diagram for ColorVideo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ColorVideo (void)
 ColorVideo (const ColorVideo &cv)
 ColorVideo (int colors, clrmodel colormodel, int rows, int cols, int frames)
virtual ~ColorVideo (void)
virtual void swapColors (int ch1, int ch2)
void colormodelVideo (clrmodel model)
ImagecurrentFrameChannel (int num=0)
ColorImagecurrentFrame (void)
double frameRate (void) const
void frameRate (double fr)
int current (void) const
void current (int current)
int frames (void) const
void reframe (int frames, bool keephead)
void resize (int rows, int cols)
void read (char const *fname, int from=0, int to=0, int rawy=0, int rawx=0, int colors=3, clrmodel cmodel=cm_rgb, int skip=512)
void read (char const *fname, filetype ftype, int from=0, int to=0, int rawy=0, int rawx=0, int colors=3, clrmodel cmodel=cm_rgb, int skip=512)
void write (char const *fname, int rawskip=512, bool beautify=false)
void write (char const *fname, filetype ftype, int rawskip=512, bool beautify=false)
virtual coeff smax (void) const
virtual coeff smin (void) const
virtual bool equals (ColorBuffer &buf) const
virtual bool epsilons (ColorBuffer &buf, coeff epsilon) const
bool epsilonsFrames (int f1, int f2, coeff epsilon) const
bool equalsFrames (int f1, int f2) const
virtual void truncate (coeff min=0, coeff max=255)
virtual void beautify (int yoffs=0, int xoffs=0, int ysize=0, int xsize=0)
virtual coeff averageColor (int fromY=0, int fromX=0, int toY=-1, int toX=-1)
virtual unsigned char * toPixmap (clrmodel cmodel)
ColorVideoclone (void) const

Static Public Member Functions

static void videoDimensions (const char *fname, int &y, int &x, int &z, int colors, int skip=0)

Protected Member Functions

virtual void destroy (void)
bool epsilonsVideo (ColorVideo &cv, coeff epsilon) const
void init (int colors, clrmodel cmodel, int rows, int cols, int frames)

Protected Attributes

int m_frames
int m_current
int m_xyzsize
VideoArray< coeff > ** m_arrays
ColorImagem_colorImage
double m_frameRate

Detailed Description

An wrapper for videos containing several color components. Objects may import and export different video formats, such as RAW. The color models can be changed (RGB or YUV).

Definition at line 24 of file ColorVideo.hh.


Constructor & Destructor Documentation

Default Constructor. Creates objects and sets actual start values.

Copy Constructor.

Parameters:
cvthe other color video
ColorVideo::ColorVideo ( int  colors,
clrmodel  colormodel,
int  rows,
int  cols,
int  frames 
)

Constructor setting a particular size etc. Initialization not done.

Parameters:
colorsthe number of colors
colormodelthe initial color model
rowsthe number of rows
colsthe number of cols
framesthe number of frames
virtual ColorVideo::~ColorVideo ( void  ) [virtual]

Destructor. Frees allocated objects.


Member Function Documentation

virtual coeff ColorVideo::averageColor ( int  fromY = 0,
int  fromX = 0,
int  toY = -1,
int  toX = -1 
) [virtual]

Return the average color for a rectangular region inside the video drawn from one point within and the second point just outside the region

Parameters:
fromYthe first point's row
fromXthe first point's col
toYthe second point's row (-1 if lower video border)
toXthe second point's col (-1 if right video border)
Returns:
the average color

Reimplemented from ColorBuffer.

virtual void ColorVideo::beautify ( int  yoffs = 0,
int  xoffs = 0,
int  ysize = 0,
int  xsize = 0 
) [virtual]

Do an intelligent kind of beautification considering previous transform steps. The original data will be overwritten, so this should only be used on clones or if the video is not going to be transformed afterwise. One region inside the video could be the low-pass subband and should thus be handled separately. If that is desired, the {ysize} and {xsize} parameters should be set to nonzero values. Note that the current implementation is very memory consuming.

Parameters:
ysizethe horizontal size of the region that should be handled separately
xsizethe vertical size of the region that should be handled separately
yoffsthe horizontal offset of the region that should be handled separately
xoffsthe vertical offset of the region that should be handled separately

Implements ColorBuffer.

ColorVideo* ColorVideo::clone ( void  ) const

Produce a copy of this video

Returns:
the copy

Convert the video to a new colormodel. This applies the `ColorBuffer::colormodel()' operation on the whole video instead of only the current frame.

Parameters:
modelthe new colormodel ({cm_rgb} or {cm_yuv})
int ColorVideo::current ( void  ) const [inline]

Returns the number of the current frame.

Returns:
the current frame (counted from 0)

Definition at line 83 of file ColorVideo.hh.

References m_current.

void ColorVideo::current ( int  current)

Returns the number of the current frame.

Returns:
the current frame (counted from 0)
ColorImage& ColorVideo::currentFrame ( void  ) [inline]

Returns a reference to a color video containing the color channels of the current frame.

Returns:
the frame as a reference to an ColorImage object

Definition at line 71 of file ColorVideo.hh.

References m_colorImage.

Image& ColorVideo::currentFrameChannel ( int  num = 0) [inline]

Returns a reference to one of the color channels of the current frame. {Don't change the dimensions of single channels unless you know what you're doing!}

Parameters:
numthe number of the color channel
Returns:
the frame as a reference to an VideoFrame object

Definition at line 66 of file ColorVideo.hh.

References ColorBuffer::m_images.

virtual void ColorVideo::destroy ( void  ) [protected, virtual]

Deletes allocated objects.

Reimplemented from ColorBuffer.

virtual bool ColorVideo::epsilons ( ColorBuffer buf,
coeff  epsilon 
) const [virtual]

Rough comparison. See if two videos are similar according to a given {epsilon} (important for floating-point comparisons).

Parameters:
bufthe other {ColorBuffer} object
epsilonthe epsilon
Returns:
if both are identical: {true}, else {false}

Reimplemented from ColorBuffer.

bool ColorVideo::epsilonsFrames ( int  f1,
int  f2,
coeff  epsilon 
) const

Rough comparison. See if this and another frame are similar according to a given {epsilon} (important for floating-point comparisons).

Exceptions:
invalid_argumentone of the frames is out of bounds
Parameters:
f1the first frame
f2the second frame
epsilonthe epsilon
Returns:
if both are identical: {true}, else {false}
bool ColorVideo::epsilonsVideo ( ColorVideo cv,
coeff  epsilon 
) const [protected]

Compares two videos

Parameters:
cvthe other video
epsilonthe min difference
Returns:
true if they equal according to epsilon
virtual bool ColorVideo::equals ( ColorBuffer buf) const [virtual]

Compares two videos. Return {true} if both are equal.

Parameters:
bufThe other {ColorBuffer} object
Returns:
if equals: {true}, else {false}

Reimplemented from ColorBuffer.

bool ColorVideo::equalsFrames ( int  f1,
int  f2 
) const

Exact comparison. See if two frames are similar.

Exceptions:
invalid_argumentone of the frames is out of bounds
Parameters:
f1the first frame
f2the second frame if both are identical: {true}, else {false}
double ColorVideo::frameRate ( void  ) const [inline]

Returns the frame rate

Returns:
the frameRate

Definition at line 75 of file ColorVideo.hh.

References m_frameRate.

void ColorVideo::frameRate ( double  fr) [inline]

Sets the frame rate

Parameters:
frthe frameRate

Definition at line 79 of file ColorVideo.hh.

References m_frameRate.

int ColorVideo::frames ( void  ) const [inline]

Returns the number of frames

Returns:
the number of frames

Definition at line 91 of file ColorVideo.hh.

References m_frames.

void ColorVideo::init ( int  colors,
clrmodel  cmodel,
int  rows,
int  cols,
int  frames 
) [protected]

Allocate objects and set standard values.

Exceptions:
invalid_argumentif any of the arguments does not make sense
Parameters:
colorsthe number of colors
cmodelthe initial color model
rowsthe number of rows
colsthe number of cols
framesthe number of frames
void ColorVideo::read ( char const *  fname,
int  from = 0,
int  to = 0,
int  rawy = 0,
int  rawx = 0,
int  colors = 3,
clrmodel  cmodel = cm_rgb,
int  skip = 512 
)

Read the video. All steps independent of the file format will be performed, like testing for file readability etc.

Exceptions:
invalid_argumentinvalid file format
ios_base::failurea read error has occured [not supported by all libraries, so eventually {invalid_argument} instead]
Parameters:
fnamethe file name to read from
rawythe number of rows (only needed for RAW format)
rawxthe number of cols (only needed for RAW format)
colorsthe number of colors (if known, necessary for raw videos)
fromthe frame to start with (from 0)
toone greater than the last frame, if equal to `from' then the whole video will be read, if 0, then the video will be read from `from' to the end
cmodelthe color model
skipthe amount of bytes to skip as a header before contents
void ColorVideo::read ( char const *  fname,
filetype  ftype,
int  from = 0,
int  to = 0,
int  rawy = 0,
int  rawx = 0,
int  colors = 3,
clrmodel  cmodel = cm_rgb,
int  skip = 512 
)

Read an video. Reads an video from a file using the specified file type. Currently PGM, RAW and PFI are supported.

Exceptions:
invalid_argumentthe file type is either not supported or could not be determined from the given file name
Parameters:
fnamethe file name, if {NULL}, then {stdin}
ftypethe file type
rawythe number of rows (only needed for RAW format)
rawxthe number of cols (only needed for RAW format)
colorsthe number of colors (if known, necessary for raw videos)
fromthe frame to start with (from 0)
toone greater than the last frame, if equal to `from' then the whole video will be read, if 0, then the video will be read from `from' to the end
cmodelthe color model
skipthe amount of bytes to skip as a header before contents
void ColorVideo::reframe ( int  frames,
bool  keephead 
)

Sets new number of frames. The old frames will be copied to the new ones as far as they fit in. The new number must be greater than zero.

Exceptions:
invalid_argumentthe new number of frames is either negative or zero
Parameters:
framesthe new number of frames.
keepheadif shrinking the video, frames will be deleted at the end.
void ColorVideo::resize ( int  rows,
int  cols 
)

Resize the video. The old values will be copied to the new dimension as far as they fit in. The new dimensions must all be greater than zero.

Exceptions:
invalid_argumentone or both dimensions are either negative or zero
Parameters:
rowsthe new number of rows
colsthe new number of cols
virtual coeff ColorVideo::smax ( void  ) const [virtual]

Returns the maximum value. Signs will be considered.

Exceptions:
invalid_argumentempty video
Returns:
the maximum

Reimplemented from ColorBuffer.

virtual coeff ColorVideo::smin ( void  ) const [virtual]

Returns the maximum value. Signs will be considered.

Exceptions:
invalid_argumentempty video
Returns:
the maximum

Reimplemented from ColorBuffer.

virtual void ColorVideo::swapColors ( int  ch1,
int  ch2 
) [virtual]

Swap two color channels.

Exceptions:
invalid_argumentif the channel specs are out of bounds
Parameters:
ch1the first channel
ch2the second channel

Reimplemented from ColorBuffer.

virtual unsigned char* ColorVideo::toPixmap ( clrmodel  cmodel) [virtual]

Export the video for other applications. This only works if the video has three channels!

Exceptions:
invalid_argumentif the current colormodel or the one passed as parameter is unsupported.
Parameters:
cmodelthe color model in which the video is exported. Currently {cm_rgb} and {cm_yuv} are supported.
Returns:
a new buffer containing the video pixels in the format according on the cmodel parameter

Reimplemented from ColorBuffer.

virtual void ColorVideo::truncate ( coeff  min = 0,
coeff  max = 255 
) [virtual]

Do a dumb kind of beautification by just truncating values to their possible maxima depending on the video format or whatever. The original data will be overwritten, so this should only be used on clones or if the original data is not needed anymore.

Parameters:
minthe minimum allowed value
maxthe maximum allowed value

Reimplemented from ColorBuffer.

static void ColorVideo::videoDimensions ( const char *  fname,
int &  y,
int &  x,
int &  z,
int  colors,
int  skip = 0 
) [static]

Try to determine some of a video file's dimensions: If the file is a raw video, two out of the three need to be specified, for AVI files all three can be determined from the header.

Exceptions:
invalid_argumentif there was an error
Parameters:
fnamethe file name of the video
ythe video's rows
xthe video's columns
zthe video's number of frames
colorsthe number of colors (always 3 with AVI files)
skipthe size of the header (only raw videos)
void ColorVideo::write ( char const *  fname,
int  rawskip = 512,
bool  beautify = false 
)

Write the video. All steps independent of the file format will be performed, like testing for file writeability etc.

Exceptions:
ios_base::failurea read error has occured [not supported by all libraries, so eventually {invalid_argument} instead]
invalid_argumentthe source video has a different number of colors than the target format allows
Parameters:
fnamethe target file name
rawskipthe amount of header area before contents (will be filled with zeroes)
beautifybeautify video that have not had more analysis than synthesis steps?
void ColorVideo::write ( char const *  fname,
filetype  ftype,
int  rawskip = 512,
bool  beautify = false 
)

Write an video. Writes an video to a file using the specified file type.

Parameters:
ftypethe file type
fnamethe file name, if {NULL}, then {stdout}
rawskipthe amount of header area before contents (will be filled with zeroes)
beautifybeautify videos that have not had more analysis than synthesis steps?

Member Data Documentation

An array of {colors} Image objects

Definition at line 328 of file ColorVideo.hh.

All channels of the current frame bundled in a ColorImage object.

Definition at line 330 of file ColorVideo.hh.

Referenced by currentFrame().

int ColorVideo::m_current [protected]

A counter for the current frame

Definition at line 324 of file ColorVideo.hh.

Referenced by current().

double ColorVideo::m_frameRate [protected]

The frame rate (if known)

Definition at line 332 of file ColorVideo.hh.

Referenced by frameRate().

int ColorVideo::m_frames [protected]

A the number of frames

Definition at line 322 of file ColorVideo.hh.

Referenced by frames().

int ColorVideo::m_xyzsize [protected]

The video's total size.

Definition at line 326 of file ColorVideo.hh.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines