Direct Graphical Models  v.1.5.3
DirectGraphicalModels::CTrainLink Class Referenceabstract

Base abstract class for link (inter-layer edge) potentials training. More...

#include <TrainLink.h>

Inheritance diagram for DirectGraphicalModels::CTrainLink:
Collaboration diagram for DirectGraphicalModels::CTrainLink:

Public Member Functions

 CTrainLink (byte nStatesBase, byte nStatesOccl, word nFeatures)
 Constructor. More...
 
virtual ~CTrainLink (void)
 
void addFeatureVec (const Mat &featureVectors, const Mat &gtb, const Mat &gto)
 Adds a block of new feature vectors. More...
 
void addFeatureVec (const vec_mat_t &featureVectors, const Mat &gtb, const Mat &gto)
 Adds a block of new feature vectors. More...
 
virtual void addFeatureVec (const Mat &featureVector, byte gtb, byte gto)=0
 Adds a feature vector. More...
 
virtual void train (bool doClean=false)
 Random model training. More...
 
Mat getLinkPotentials (const Mat &featureVector, float weight=1.0f) const
 Returns the link potential, based on the feature vector. More...
 
- Public Member Functions inherited from DirectGraphicalModels::ITrain
 ITrain (byte nStates, word nFeatures)
 Constructor. More...
 
virtual ~ITrain (void)
 
word getNumFeatures (void) const
 Returns number of features. More...
 
- Public Member Functions inherited from DirectGraphicalModels::CBaseRandomModel
 CBaseRandomModel (byte nStates)
 Constructor. More...
 
virtual ~CBaseRandomModel (void)
 
virtual void reset (void)=0
 Resets class variables. More...
 
virtual void save (const std::string &path, const std::string &name=std::string(), short idx=-1) const
 Saves the training data. More...
 
virtual void load (const std::string &path, const std::string &name=std::string(), short idx=-1)
 Loads the training data. More...
 
byte getNumStates (void) const
 Returns number of features. More...
 

Protected Member Functions

virtual Mat calculateLinkPotentials (const Mat &featureVector) const =0
 Calculates the link potential, based on the feature vector. More...
 
- Protected Member Functions inherited from DirectGraphicalModels::CBaseRandomModel
virtual void saveFile (FILE *pFile) const =0
 Saves the random model into the file. More...
 
virtual void loadFile (FILE *pFile)=0
 Loads the random model from the file. More...
 
std::string generateFileName (const std::string &path, const std::string &name, short idx) const
 Generates name of the data file for storing random model parameters. More...
 

Protected Attributes

byte m_nStatesBase
 
byte m_nStatesOccl
 
- Protected Attributes inherited from DirectGraphicalModels::ITrain
word m_nFeatures
 The number of features (length of the feature vector) More...
 
- Protected Attributes inherited from DirectGraphicalModels::CBaseRandomModel
byte m_nStates
 The number of states (classes) More...
 

Detailed Description

Base abstract class for link (inter-layer edge) potentials training.

Author
Sergey G. Kosov, serge.nosp@m.y.ko.nosp@m.sov@p.nosp@m.roje.nosp@m.ct-10.nosp@m..de

Definition at line 15 of file TrainLink.h.

Constructor & Destructor Documentation

◆ CTrainLink()

DirectGraphicalModels::CTrainLink::CTrainLink ( byte  nStatesBase,
byte  nStatesOccl,
word  nFeatures 
)
inline

Constructor.

Parameters
nStatesBaseNumber of states (classes) for the base layer of the graphical model
nStatesOcclNumber of states (classes) for the occlusion layer of the graphical model
nFeaturesNumber of features

Definition at line 24 of file TrainLink.h.

◆ ~CTrainLink()

virtual DirectGraphicalModels::CTrainLink::~CTrainLink ( void  )
inlinevirtual

Definition at line 30 of file TrainLink.h.

Member Function Documentation

◆ addFeatureVec() [1/3]

void DirectGraphicalModels::CTrainLink::addFeatureVec ( const Mat &  featureVectors,
const Mat &  gtb,
const Mat &  gto 
)

Adds a block of new feature vectors.

Used to add multiple featureVectors, corresponding to the ground-truth states (classes) gtb and gto for training

Parameters
featureVectorsMulti-channel matrix, each element of which is a multi-dimensinal point: Mat(type: CV_8UC<nFeatures>)
gtbMatrix, each element of which is a ground-truth state (class), corresponding to the base layer
gtoMatrix, each element of which is a ground-truth state (class), corresponding to the occlusion layer

Definition at line 6 of file TrainLink.cpp.

◆ addFeatureVec() [2/3]

void DirectGraphicalModels::CTrainLink::addFeatureVec ( const vec_mat_t &  featureVectors,
const Mat &  gtb,
const Mat &  gto 
)

Adds a block of new feature vectors.

Used to add multiple featureVectors, corresponding to the ground-truth states (classes) gtb and gto for training

Parameters
featureVectorsVector of size nFeatures, each element of which is a single feature - image: Mat(type: CV_8UC1)
gtbMatrix, each element of which is a ground-truth state (class), corresponding to the base layer
gtoMatrix, each element of which is a ground-truth state (class), corresponding to the occlusion layer

Definition at line 12 of file TrainLink.cpp.

◆ addFeatureVec() [3/3]

virtual void DirectGraphicalModels::CTrainLink::addFeatureVec ( const Mat &  featureVector,
byte  gtb,
byte  gto 
)
pure virtual

Adds a feature vector.

Used to add featureVector, corresponding to the ground-truth states (classes) gtb and gto for training. Here the couple {gtb, gto} corresponds to the nodes from base aod occlusion layers.

Parameters
featureVectorMulti-dimensinal point: Mat(size: nFeatures x 1; type: CV_8UC1), corresponding to both nodes of the link.
gtbThe ground-truth state (class) of the first node of the edge, corresponding to the base layer
gtoThe ground-truth state (class) of the second node of the edge, corresponding to the occlusion layer

Implemented in DirectGraphicalModels::CTrainLinkNested< Trainer >.

◆ calculateLinkPotentials()

virtual Mat DirectGraphicalModels::CTrainLink::calculateLinkPotentials ( const Mat &  featureVector) const
protectedpure virtual

Calculates the link potential, based on the feature vector.

This function calculates the potentials of an edge, described with the sample featureVector, correspondig to the both nodes defining that edge. The resulting potentials of the two nodes being in each possible state (one class from occlusion layer occlusion another class from the base layer), are united in the edge potential matrix:

\[edgePot[nStates][nStates] = f(\textbf{f}[nFeatures])\]

Functions \( f \) must be implemented in derived classes.

Parameters
featureVectorMulti-dimensinal point \(\textbf{f}\): Mat(size: nFeatures x 1; type: CV_{XX}C1), corresponding to both nodes of the link
Returns
The edge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1)

Implemented in DirectGraphicalModels::CTrainLinkNested< Trainer >.

Here is the caller graph for this function:

◆ getLinkPotentials()

Mat DirectGraphicalModels::CTrainLink::getLinkPotentials ( const Mat &  featureVector,
float  weight = 1.0f 
) const

Returns the link potential, based on the feature vector.

This function calls calculateLinkPotentials() function, which should be implemented in derived classes. After that, the resulting edge potential is powered by parameter weight.

Parameters
featureVectorMulti-dimensinal point \(\textbf{f}\): Mat(size: nFeatures x 1; type: CV_{XX}C1), corresponding to both nodes of the link
weightThe weighting parameter
Returns
Edge potentials on success: Mat(size: nStates x nStates; type: CV_32FC1)

Definition at line 18 of file TrainLink.cpp.

Here is the call graph for this function:

◆ train()

virtual void DirectGraphicalModels::CTrainLink::train ( bool  doClean = false)
inlinevirtual

Random model training.

Auxilary function for training - some derived classes may use this function inbetween training and classification phases

Note
This function must be called inbetween the training and classification phases
Parameters
doCleanFlag indicating if the memory, keeping the trining data should be released after training

Implements DirectGraphicalModels::ITrain.

Reimplemented in DirectGraphicalModels::CTrainLinkNested< Trainer >.

Definition at line 58 of file TrainLink.h.

Member Data Documentation

◆ m_nStatesBase

byte DirectGraphicalModels::CTrainLink::m_nStatesBase
protected

Definition at line 85 of file TrainLink.h.

◆ m_nStatesOccl

byte DirectGraphicalModels::CTrainLink::m_nStatesOccl
protected

Definition at line 86 of file TrainLink.h.


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