parent
d9fc6240c5
commit
7cf0392991
@ -1,48 +1,37 @@
|
|||||||
#ifndef EASYPR_SVM_TRAIN_H
|
#ifndef EASYPR_TRAIN_SVMTRAIN_H_
|
||||||
#define EASYPR_SVM_TRAIN_H
|
#define EASYPR_TRAIN_SVMTRAIN_H_
|
||||||
|
|
||||||
|
#include "easypr/train/train.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <opencv2/opencv.hpp>
|
|
||||||
#include "easypr/config.h"
|
#include "easypr/config.h"
|
||||||
|
|
||||||
namespace easypr {
|
namespace easypr {
|
||||||
|
|
||||||
class SvmTrain {
|
class SvmTrain : public ITrain {
|
||||||
public:
|
public:
|
||||||
typedef enum {
|
typedef struct {
|
||||||
kForward = 1, // correspond to "has plate"
|
std::string file;
|
||||||
kInverse = 0 // correspond to "no plate"
|
SvmLabel label;
|
||||||
} Label;
|
} TrainItem;
|
||||||
|
|
||||||
SvmTrain(const char* forward_data_folder, const char* inverse_data_folder);
|
SvmTrain(const char* plates_folder, const char* xml);
|
||||||
|
|
||||||
void train(bool divide = true, float divide_percentage = 0.7,
|
virtual void train();
|
||||||
const char* out_svm_folder = kDefaultSvmPath);
|
|
||||||
|
|
||||||
void runTest(const char* svm_path = kDefaultSvmPath);
|
virtual void test();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*
|
void prepare();
|
||||||
* divide images into train part and test part by percentage
|
|
||||||
*/
|
|
||||||
void divide(const char* images_folder, float percentage = 0.7);
|
|
||||||
|
|
||||||
void getTrain();
|
virtual cv::Ptr<cv::ml::TrainData> tdata();
|
||||||
|
|
||||||
void getTest();
|
cv::Ptr<cv::ml::SVM> svm_;
|
||||||
|
const char* plates_folder_;
|
||||||
const char* forward_;
|
const char* svm_xml_;
|
||||||
const char* inverse_;
|
std::vector<TrainItem> train_file_list_;
|
||||||
|
std::vector<TrainItem> test_file_list_;
|
||||||
// these two variables are used for cv::CvSVM::train_auto()
|
};
|
||||||
cv::Mat classes_;
|
|
||||||
cv::Ptr<cv::ml::TrainData> trainingData_;
|
|
||||||
|
|
||||||
// these two variables are used for cv::CvSVM::predict()
|
|
||||||
std::vector<cv::Mat> test_imgaes_;
|
|
||||||
std::vector<Label> test_labels_;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //EASYPR_SVM_TRAIN_H
|
#endif // EASYPR_TRAIN_SVMTRAIN_H_
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue