-
Notifications
You must be signed in to change notification settings - Fork 0
/
randomforest.h
43 lines (35 loc) · 1.07 KB
/
randomforest.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
#ifndef RANDOMFOREST_H
#define RANDOMFOREST_H
#include <QObject>
#include <QSize>
#include <opencv2/ml/ml.hpp>
class RandomForest : public QObject
{
Q_OBJECT
public:
explicit RandomForest(QObject *parent = 0);
void train(QString filename,
int positiveCount,
int negativeCount,
int numOfFeatures);
void test(QString filename, int numOfSamples, int numOfFeatures);
float predict(const cv::Mat& sample);
float predict_prob(const cv::Mat& sample);
QSize workSize() const;
void setWorkSize(QSize size);
int numOfFeatures() const;
void setNumOfFeatures(int numOfFeatures);
cv::Mat computeFeatureVectors(QString imgPath, int w, int h);
cv::Mat computeFeatureVectors(cv::Mat inputImage, int w, int h);
private:
int loadData(const char* filename,
cv::Mat samples,
cv::Mat lables,
int numOfSamples,
int numOfFeatures);
private:
CvRTrees m_randomForest;
QSize m_workSize;
int m_numOfFeatures;
};
#endif // RANDOMFOREST_H