VAT  3.0
Video Analysis Tool
codebookmodel.h
1 #ifndef CODEBOOKMODEL_H
2 #define CODEBOOKMODEL_H
3 
4 #include <opencv2/core/core.hpp>
5 #include <opencv2/legacy/legacy.hpp>
6 #include <vector>
7 #include "commonimage.h"
8 
16 {
17 public:
18  CodebookModel();
21 
22  void setCBParameters(std::vector<uchar> params);
23 
24  // Learning step
25  bool learnFrame();
26 
27  // Foreground retrieving step
28  bool updateFGMask();
29  void getFG(cv::Mat& output);
30  void getFG(QImage& output);
31 
32  double getFGPercentage() const;
33  static double getFGPercentageExtern(const cv::Mat mask);
34 
36 
37  int getLearnedFrames() const;
38 
39  // Clear and resetting
40  void setRelativeStaleThreshold(double rel);
41  double getRelativeStaleThreshold() const;
42  void clearStales();
43  void resetCBModel();
44 
45  // Some misc function I didn't know where to put it.
46  static void getConnectedComponents(const cv::Mat& fginput, std::vector<cv::Mat>& masks, std::vector<cv::Rect>& boundingBoxes);
47 
48 protected:
49  void cleanse(); // To change the CB Model, look this function first.
50  void allocateCBData();
51  void setCBDefaults();
52  bool verifyNotNullity();
53 
54 private:
55  // Associated image, which we will learn and extract FG/BG.
56  CommonImage* asocimg;
57 
58  // Relative stale threshold
59  double relstalethreshold;
60 
61  // Stored and retrieved masks
62  cv::Mat fgmask;
63 
64  // Functionality with OpenCV
65  cv::Mat yuvimg;
66  IplImage yuvimgshadow;
67 
68  // The model.
69  CvBGCodeBookModel* cbmodel;
70 };
71 
72 #endif // CODEBOOKMODEL_H
bool verifyNotNullity()
CodebookModel::verifyNotNullity Simply verifies if the associated image is not null.
Definition: codebookmodel.cpp:264
void clearStales()
CodebookModel::clearStales Clears stale entries in the Codebook Model, using the ratio set in setStal...
Definition: codebookmodel.cpp:210
void cleanse()
CodebookModel::cleanse Cleanse private variables.
Definition: codebookmodel.cpp:278
int getLearnedFrames() const
CodebookModel::getLearnedFrames Gets the amount of frames this codebook model has learned...
Definition: codebookmodel.cpp:240
bool updateFGMask()
CodebookModel::updateFGMask Uses the codebook model to extract the Foreground Mask from the current f...
Definition: codebookmodel.cpp:104
void associateCommonImage(CommonImage *asoc)
CodebookModel::associateCommonImage Associates another CommonImage to this Codebook model...
Definition: codebookmodel.cpp:43
double getRelativeStaleThreshold() const
CodebookModel::getRelativeStaleThreshold Gets the relative stale threshold. Read setRelativeStaleThre...
Definition: codebookmodel.cpp:230
~CodebookModel()
CodebookModel::~CodebookModel Destructor.
Definition: codebookmodel.cpp:249
CodebookModel()
CodebookModel::CodebookModel Default constructor. To use this codebook model you must associate a Com...
Definition: codebookmodel.cpp:19
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&#39;ll trust it&#39;s a ...
Definition: codebookmodel.cpp:318
void resetCBModel()
CodebookModel::resetCBModel Resets the codebook model.
Definition: codebookmodel.cpp:201
The CommonImage class This is a class made to solve the headache you&#39;ll probably get when working bot...
Definition: commonimage.h:21
double getFGPercentage() const
CodebookModel::getFGPercentage Retrieves the percentage of the frame that is considered Foreground...
Definition: codebookmodel.cpp:168
void setRelativeStaleThreshold(double rel)
CodebookModel::setRelativeStaleThreshold Sets what portion of the retrieved codebooks are considered ...
Definition: codebookmodel.cpp:220
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.
Definition: codebookmodel.cpp:54
The CodebookModel class This is a class made to interface (some way or another) the way OpenCV handle...
Definition: codebookmodel.h:15
void allocateCBData()
CodebookModel::allocateCBData Allocates any private data needed.
Definition: codebookmodel.cpp:290
bool learnFrame()
CodebookModel::learnFrame Makes this codebook model learn the current frame in the associated image...
Definition: codebookmodel.cpp:82
static double getFGPercentageExtern(const cv::Mat mask)
CodebookModel::getFGPercentageExtern Same function as getFGPercentage, but for external Mats...
Definition: codebookmodel.cpp:180