1 #ifndef APPARIENCEMODELLEARNING_H 2 #define APPARIENCEMODELLEARNING_H 5 #include <opencv/highgui.h> 6 #include "opencv2/opencv.hpp" 9 #include <src/footballConstants.h> 11 enum typeDistanceMetric{
32 cv::Ptr<cv::ml::EM> emAl;
34 typeCluster typeTrained;
35 std::map< soccerClass, unsigned long> nSamples;
36 unsigned long pSamples;
38 std::vector<sampleAppModel> samples;
40 clusters2D_BOF ClustersUV;
41 clusters3D_BOF ClustersLUV;
42 clusters1D_BOF ClustersL;
50 apparienceModelLearning(QString name,
int cls = 15,
double bottomTh=0.0,
double topTh=100.0, typeDistanceMetric type = Complete);
56 void generateMetaPrototypesFor3DCluster(
int n_clusters);
57 void generateMetaPrototypesFor2DCluster(
int n_clusters);
58 void generateMetaPrototypesFor1DCluster(
int n_clusters);
60 void saveModel(QString directory);
61 bool readChroma_Model(QString filePath);
62 bool readLuma_Model(QString filePath);
63 bool readLuv_Model(QString filePath);
67 bool getWeights(cv::Mat &mat);
68 bool getMeans(cv::Mat &mat);
69 bool getCovs(std::vector< cv::Mat > &vmat);
71 cv::Ptr<cv::ml::EM> getEM();
72 bool getSamplesFromCSV(QString filePath,
int part, soccerClass cl);
74 clusters2D_BOF getClusters2D_BOF();
75 clusters1D_BOF getClusters1D_BOF();
76 clusters3D_BOF getClusters3D_BOF();
78 static cv::Vec3d valueLUVConvert(cv::Vec3d val);
79 static cv::Vec2d valueUVConvert(cv::Vec2d val);
80 static cv::Scalar valueLUVConvertInv(cv::Scalar val);
83 double* create1DFeature_Histogram(soccerClass clase,
bool showH =
false);
84 double* create2DFeature_Histogram(soccerClass clase,
bool showH =
false);
85 double* create3DFeature_Histogram(soccerClass clase,
bool showH =
false);
88 static double BhattacharryaDistance(
double *h1,
double *h2,
int size);
89 static double chiSquare(
double *h1,
double *h2,
int size);
90 static double intersectionDist(
double *h1,
double *h2,
int size);
91 static double correlationDist(
double *h1,
double *h2,
int size);
93 static bool evaluatePixeltoCluster(cv::Vec2d value, std::vector < cv::Vec2d > cluster,
int type);
94 static bool evaluatePixeltoCluster(cv::Vec3d value, std::vector < cv::Vec3d > cluster,
int type);
95 static bool evaluatePixeltoCluster(
double value, std::vector < double > cluster,
int type);
96 static void showHistogram(
int *count,
const clusters2D_BOF &clusters, QString name =
"UNKNOWN");
97 static void showHistogram(
int *count,
const clusters3D_BOF &clusters, QString name =
"UNKNOWN");
98 static void showHistogram(
int *count,
const clusters1D_BOF &clusters, QString name =
"UNKNOWN");
99 static void printClusters(clusters2D_BOF clusters);
100 static void printClusters(clusters1D_BOF clusters);
101 static void printClusters(clusters3D_BOF clusters);
102 static bool filterByLuma(
double l,
double bottomTh,
double topTh);
107 bool trainEM(typeCluster typeCl);
110 void eraseSamples(
unsigned long init,
unsigned long end);
113 double calcDist(cv::Vec2d p1, cv::Vec2d p2);
114 cv::Point findMinDist(cv::Mat proximityMat);
115 double distNewCluster(cv::Point rsPoint,
int k, cv::Mat distanceMat, typeDistanceMetric type,
int nr,
int ns);
125 typeDistanceMetric dMetric;
128 unsigned int samplesToMap(cv::Mat &mat, soccerClass clase, typeCluster type);
130 unsigned int countAllSamples();
134 #endif // APPARIENCEMODELLEARNING_H Definition: apparienceModelLearning.h:46
Definition: apparienceModelLearning.h:29
Definition: apparienceModelLearning.h:20