VAT  3.0
Video Analysis Tool
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
CodebookModel Class Reference

The CodebookModel class This is a class made to interface (some way or another) the way OpenCV handles the Codebook segmentation method with the old C interface. This class works associating a changing image to it (be cautious if you're working with this image in more than one thread) to both learn the model and extract foreground difference masks from it. More...

#include <codebookmodel.h>

Public Member Functions

 CodebookModel ()
 CodebookModel::CodebookModel Default constructor. To use this codebook model you must associate a CommonImage first. Sets default data for the CB model.
 
 CodebookModel (CommonImage *cimg)
 CodebookModel::CodebookModel Constructor. This immediatly associates a CommonImage to use in. More...
 
 ~CodebookModel ()
 CodebookModel::~CodebookModel Destructor.
 
void setCBParameters (std::vector< uchar > params)
 CodebookModel::setCBParameters Sets the bounds for Codebook Parameters for each channel. The passing vector element must have at least 9 elements: triads for each YUV channel: minimum bound, maximum bound and cbBounds. Default value is 3,10 and 10 respectively for each triad. More...
 
bool learnFrame ()
 CodebookModel::learnFrame Makes this codebook model learn the current frame in the associated image.
 
bool updateFGMask ()
 CodebookModel::updateFGMask Uses the codebook model to extract the Foreground Mask from the current frame. You can get the mask using the getFG method. Note: You must take some frames to learn a model! I recommend to run learnFrame() on at least 100 frames before using this function! More...
 
void getFG (cv::Mat &output)
 
void getFG (QImage &output)
 CodebookModel::getFG The same, but with a QImage as an output image. More...
 
double getFGPercentage () const
 CodebookModel::getFGPercentage Retrieves the percentage of the frame that is considered Foreground. To update the Foreground Mask, you must call updateFGMask prior to this function. More...
 
void associateCommonImage (CommonImage *asoc)
 CodebookModel::associateCommonImage Associates another CommonImage to this Codebook model. More...
 
int getLearnedFrames () const
 CodebookModel::getLearnedFrames Gets the amount of frames this codebook model has learned. More...
 
void setRelativeStaleThreshold (double rel)
 CodebookModel::setRelativeStaleThreshold Sets what portion of the retrieved codebooks are considered stale, and thus, deleted. More...
 
double getRelativeStaleThreshold () const
 CodebookModel::getRelativeStaleThreshold Gets the relative stale threshold. Read setRelativeStaleThreshold for more information. More...
 
void clearStales ()
 CodebookModel::clearStales Clears stale entries in the Codebook Model, using the ratio set in setStaleClearRatio().
 
void resetCBModel ()
 CodebookModel::resetCBModel Resets the codebook model.
 

Static Public Member Functions

static double getFGPercentageExtern (const cv::Mat mask)
 CodebookModel::getFGPercentageExtern Same function as getFGPercentage, but for external Mats, in order to apply some external operations (like morphology) first, before evaluating this percentage. More...
 
static void getConnectedComponents (const cv::Mat &fginput, std::vector< cv::Mat > &masks, std::vector< cv::Rect > &boundingBoxes)
 getConnectedComponents Gets all the connected components in the binary input mask (I'll trust it's a binary 0-255, 8-bit uchar image). It returns both a mask and a bounding box for each connected component. Now, why is this a static member of THIS class? Because I can! More...
 

Protected Member Functions

void cleanse ()
 CodebookModel::cleanse Cleanse private variables.
 
void allocateCBData ()
 CodebookModel::allocateCBData Allocates any private data needed.
 
void setCBDefaults ()
 
bool verifyNotNullity ()
 CodebookModel::verifyNotNullity Simply verifies if the associated image is not null. More...
 

Detailed Description

The CodebookModel class This is a class made to interface (some way or another) the way OpenCV handles the Codebook segmentation method with the old C interface. This class works associating a changing image to it (be cautious if you're working with this image in more than one thread) to both learn the model and extract foreground difference masks from it.

Constructor & Destructor Documentation

CodebookModel::CodebookModel ( CommonImage cimg)

CodebookModel::CodebookModel Constructor. This immediatly associates a CommonImage to use in.

Parameters
cimg

Member Function Documentation

void CodebookModel::associateCommonImage ( CommonImage asoc)

CodebookModel::associateCommonImage Associates another CommonImage to this Codebook model.

Parameters
asoc
void CodebookModel::getConnectedComponents ( const cv::Mat &  fginput,
std::vector< cv::Mat > &  masks,
std::vector< cv::Rect > &  boundingBoxes 
)
static

getConnectedComponents Gets all the connected components in the binary input mask (I'll trust it's a binary 0-255, 8-bit uchar image). It returns both a mask and a bounding box for each connected component. Now, why is this a static member of THIS class? Because I can!

Parameters
fginputBinary input mask
masksOutput vector of a binary mask for each connected component
boundingBoxesOutput vector of a bounding box for each connected component
void CodebookModel::getFG ( QImage &  output)

CodebookModel::getFG The same, but with a QImage as an output image.

Parameters
output
double CodebookModel::getFGPercentage ( ) const

CodebookModel::getFGPercentage Retrieves the percentage of the frame that is considered Foreground. To update the Foreground Mask, you must call updateFGMask prior to this function.

Returns
A number between 0 and 100. Returns -1 if no foreground mask was made yet (if it is in a learning phase, for example)
double CodebookModel::getFGPercentageExtern ( const cv::Mat  mask)
static

CodebookModel::getFGPercentageExtern Same function as getFGPercentage, but for external Mats, in order to apply some external operations (like morphology) first, before evaluating this percentage.

Parameters
fgmask
Returns
int CodebookModel::getLearnedFrames ( ) const

CodebookModel::getLearnedFrames Gets the amount of frames this codebook model has learned.

Returns
double CodebookModel::getRelativeStaleThreshold ( ) const

CodebookModel::getRelativeStaleThreshold Gets the relative stale threshold. Read setRelativeStaleThreshold for more information.

Returns
void CodebookModel::setCBParameters ( std::vector< uchar >  params)

CodebookModel::setCBParameters Sets the bounds for Codebook Parameters for each channel. The passing vector element must have at least 9 elements: triads for each YUV channel: minimum bound, maximum bound and cbBounds. Default value is 3,10 and 10 respectively for each triad.

Parameters
paramsA vector with YUV parameters ordered that way.
void CodebookModel::setRelativeStaleThreshold ( double  rel)

CodebookModel::setRelativeStaleThreshold Sets what portion of the retrieved codebooks are considered stale, and thus, deleted.

Parameters
relNumber from 0.0 to 100.0 indicating what percentage of the run time a codebook is considered stale.
bool CodebookModel::updateFGMask ( )

CodebookModel::updateFGMask Uses the codebook model to extract the Foreground Mask from the current frame. You can get the mask using the getFG method. Note: You must take some frames to learn a model! I recommend to run learnFrame() on at least 100 frames before using this function!

Returns
True if the FG mask was successfully updated.
bool CodebookModel::verifyNotNullity ( )
protected

CodebookModel::verifyNotNullity Simply verifies if the associated image is not null.

Returns
True if it's not null.

The documentation for this class was generated from the following files: