forked from aclapes/segmenthreetion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GridPredictor.h
80 lines (59 loc) · 1.69 KB
/
GridPredictor.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// GridPredictor.h
// segmenthreetion
//
// Created by Albert Clapés on 02/03/14.
//
//
#ifndef __segmenthreetion__GridPredictor__
#define __segmenthreetion__GridPredictor__
#include <iostream>
#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/ml/ml.hpp>
#include "em.h"
#include "GridMat.h"
using namespace std;
template<typename PredictorT>
class GridPredictorBase
{
public:
GridPredictorBase(int hp, int wp);
~GridPredictorBase();
// void setParameters(GridMat parameters);
void setDimensionalityReduction(cv::Mat variances);
PredictorT* at(unsigned int i, unsigned int j);
cv::PCA* getPCA(unsigned int, unsigned j);
protected:
GridMat m_data;
GridMat m_categories;
unsigned int m_hp, m_wp;
vector<PredictorT*> m_pPredictors;
vector<cv::PCA*> m_pPCAs;
GridMat m_projData;
bool m_bDimReduction;
cv::Mat m_variances;
};
template<typename PredictorT>
class GridPredictor : public GridPredictorBase<PredictorT>
{
};
template<>
class GridPredictor<cv::EM40> : public GridPredictorBase<cv::EM40>
{
public:
GridPredictor(int hp, int wp);
void setNumOfMixtures(cv::Mat nmixtures);
void setEpsilons(cv::Mat epsilons);
void setLoglikelihoodThreshold(cv::Mat loglikes);
void train(GridMat data);
void predict(GridMat data, GridMat& loglikelihoods);
void predict(GridMat data, GridMat& predictions, GridMat& loglikelihoods, GridMat& distsToMargin);
private:
cv::Mat m_nmixtures;
cv::Mat m_epsilons;
cv::Mat m_logthreshold;
};
#endif /* defined(__segmenthreetion__GridPredictor__) */