-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkMeansClassifier.hpp
36 lines (26 loc) · 1.12 KB
/
kMeansClassifier.hpp
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
#ifndef __KMEANS_CLASSIFIER_HPP__
#define __KMEANS_CLASSIFIER_HPP__
#include "Utils.hpp"
#include <opencv2/core.hpp>
#include <cmath>
#include <numeric>
#include "DatasetHelper.hpp"
class KMeansClassifier {
public:
KMeansClassifier(double decisionRatio): decisionRatio(decisionRatio){}
void clusterSeaKps(std::vector<std::vector<double>>& seaKps, int k, bool printComp);
void clusterboatsKps(std::vector<std::vector<double>>& boatsKps, int k, bool printComp);
void clusterbgKps(std::vector<std::vector<double>>& bgKps, int k, bool printComp);
int predictLabel(std::vector<double>& descriptor);
std::vector<int> predictBoatsBatch(cv::Mat& descriptors, float threshold);
void save(cv::String& inputDirectory);
void load(cv::String& inputDirectory, bool bg = true);
private:
double decisionRatio;
//std::vector<std::vector<double>> seaCentroids;
//std::vector<std::vector<double>> boatsCentroids;
//std::vector<std::vector<double>> bgCentroids;
cv::Mat seaCMat, boatsCMat, boatsCMat32, bgCMat;
};
double cluster(std::vector<std::vector<double>>& input, int k,cv::Mat& output);
#endif