-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecogniserKNearest.h
32 lines (25 loc) · 935 Bytes
/
RecogniserKNearest.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
#ifndef RECOGNISERKNEAREST_H_
#define RECOGNISERKNEAREST_H_
#include <opencv2/opencv.hpp>
#include "ocr.h"
namespace ocr {
class RecogniserKNearest : public Recogniser {
private:
static unsigned int MAX_DISTANCE;
cv::Mat prepareSample(const cv::Mat & img, bool black_on_white = false);
void initModel();
cv::Mat _samples;
cv::Mat _responses;
CvKNearest* _pModel;
public:
RecogniserKNearest(const char *filename = NULL);
virtual ~RecogniserKNearest();
void learn(const cv::Mat & img, char key);
void learn(const std::vector<cv::Mat> & images, const std::string &answers);
virtual char recognise(const cv::Mat & img, bool black_on_white = false);
void saveTrainingData(const char *filename);
void loadTrainingData(const char *filename);
static void learnOcr(cv::VideoCapture &pImageInput, const std::string &answers, const char *filename);
};
}
#endif /* RECOGNISERKNEAREST_H_ */