Direct Graphical Models
v.1.7.0
|
Base abstract class for link (inter-layer edge) potentials training. More...
#include <TrainLink.h>
Public Member Functions | |
CTrainLink (byte nStatesBase, byte nStatesOccl, word nFeatures) | |
Constructor. More... | |
virtual | ~CTrainLink (void)=default |
void | addFeatureVec (const Mat &featureVectors, const Mat >b, const Mat >o) |
Adds a block of new feature vectors. More... | |
void | addFeatureVec (const vec_mat_t &featureVectors, const Mat >b, const Mat >o) |
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)=default |
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 states (classes) 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 |
Number of states (classes) at the base layer of ML-CRF. More... | |
byte | m_nStatesOccl |
Number of states (classes) at the occlusion layerts of ML-CRF. More... | |
Protected Attributes inherited from DirectGraphicalModels::CBaseRandomModel | |
byte | m_nStates |
The number of states (classes) More... | |
Base abstract class for link (inter-layer edge) potentials training.
The link potentials (or occlusion potentials) are used in the multi-layer CRF model. Refer to
Labeling of Partially Occluded Regions via the Multi-Layer CRF paper for more details.
Definition at line 17 of file TrainLink.h.
|
inline |
Constructor.
nStatesBase | Number of states (classes) for the base layer of the graphical model |
nStatesOccl | Number of states (classes) for the occlusion layer of the graphical model |
nFeatures | Number of features |
Definition at line 26 of file TrainLink.h.
|
virtualdefault |
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
featureVectors | Multi-channel matrix, each element of which is a multi-dimensinal point: Mat(type: CV_8UC<nFeatures>) |
gtb | Matrix, each element of which is a ground-truth state (class), corresponding to the base layer |
gto | Matrix, each element of which is a ground-truth state (class), corresponding to the occlusion layer |
Definition at line 6 of file TrainLink.cpp.
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
featureVectors | Vector of size nFeatures, each element of which is a single feature - image: Mat(type: CV_8UC1) |
gtb | Matrix, each element of which is a ground-truth state (class), corresponding to the base layer |
gto | Matrix, each element of which is a ground-truth state (class), corresponding to the occlusion layer |
Definition at line 12 of file TrainLink.cpp.
|
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.
featureVector | Multi-dimensinal point: Mat(size: nFeatures x 1; type: CV_8UC1), corresponding to both nodes of the link. |
gtb | The ground-truth state (class) of the first node of the edge, corresponding to the base layer |
gto | The ground-truth state (class) of the second node of the edge, corresponding to the occlusion layer |
Implemented in DirectGraphicalModels::CTrainLinkNested< Trainer >.
|
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.
featureVector | Multi-dimensinal point \(\textbf{f}\): Mat(size: nFeatures x 1; type: CV_{XX}C1), corresponding to both nodes of the link |
Implemented in DirectGraphicalModels::CTrainLinkNested< Trainer >.
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.
featureVector | Multi-dimensinal point \(\textbf{f}\): Mat(size: nFeatures x 1; type: CV_{XX}C1), corresponding to both nodes of the link |
weight | The weighting parameter |
Definition at line 18 of file TrainLink.cpp.
|
inlinevirtual |
Random model training.
Auxilary function for training - some derived classes may use this function inbetween training and classification phases
doClean | Flag indicating if the memory, keeping the trining data should be released after training |
Implements DirectGraphicalModels::ITrain.
Reimplemented in DirectGraphicalModels::CTrainLinkNested< Trainer >.
Definition at line 60 of file TrainLink.h.
|
protected |
Number of states (classes) at the base layer of ML-CRF.
Definition at line 87 of file TrainLink.h.
|
protected |
Number of states (classes) at the occlusion layerts of ML-CRF.
Definition at line 88 of file TrainLink.h.