-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathDetectChars.h
73 lines (45 loc) · 2.36 KB
/
DetectChars.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// DetectChars.h
#ifndef DETECT_CHARS_H
#define DETECT_CHARS_H
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/ml/ml.hpp>
#include "Main.h"
#include "PossibleChar.h"
#include "PossiblePlate.h"
#include "Preprocess.h"
// global constants ///////////////////////////////////////////////////////////////////////////////
// constants for checkIfPossibleChar, this checks one possible char only (does not compare to another char)
const int MIN_PIXEL_WIDTH = 2;
const int MIN_PIXEL_HEIGHT = 8;
const double MIN_ASPECT_RATIO = 0.25;
const double MAX_ASPECT_RATIO = 1.0;
const int MIN_PIXEL_AREA = 80;
// constants for comparing two chars
const double MIN_DIAG_SIZE_MULTIPLE_AWAY = 0.3;
const double MAX_DIAG_SIZE_MULTIPLE_AWAY = 5.0;
const double MAX_CHANGE_IN_AREA = 0.5;
const double MAX_CHANGE_IN_WIDTH = 0.8;
const double MAX_CHANGE_IN_HEIGHT = 0.2;
const double MAX_ANGLE_BETWEEN_CHARS = 12.0;
// other constants
const int MIN_NUMBER_OF_MATCHING_CHARS = 3;
const int RESIZED_CHAR_IMAGE_WIDTH = 20;
const int RESIZED_CHAR_IMAGE_HEIGHT = 30;
const int MIN_CONTOUR_AREA = 100;
// external global variables //////////////////////////////////////////////////////////////////////
extern const bool blnShowSteps;
extern cv::Ptr<cv::ml::KNearest> kNearest;
// function prototypes ////////////////////////////////////////////////////////////////////////////
bool loadKNNDataAndTrainKNN(void);
std::vector<PossiblePlate> detectCharsInPlates(std::vector<PossiblePlate> &vectorOfPossiblePlates);
std::vector<PossibleChar> findPossibleCharsInPlate(cv::Mat &imgGrayscale, cv::Mat &imgThresh);
bool checkIfPossibleChar(PossibleChar &possibleChar);
std::vector<std::vector<PossibleChar> > findVectorOfVectorsOfMatchingChars(const std::vector<PossibleChar> &vectorOfPossibleChars);
std::vector<PossibleChar> findVectorOfMatchingChars(const PossibleChar &possibleChar, const std::vector<PossibleChar> &vectorOfChars);
double distanceBetweenChars(const PossibleChar &firstChar, const PossibleChar &secondChar);
double angleBetweenChars(const PossibleChar &firstChar, const PossibleChar &secondChar);
std::vector<PossibleChar> removeInnerOverlappingChars(std::vector<PossibleChar> &vectorOfMatchingChars);
std::string recognizeCharsInPlate(cv::Mat &imgThresh, std::vector<PossibleChar> &vectorOfMatchingChars);
#endif // DETECT_CHARS_H