forked from skaringa/emeocv
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathImageProcessor.h
72 lines (53 loc) · 1.65 KB
/
ImageProcessor.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
/*
* ImageProcessor.h
*
*/
#ifndef IMAGEPROCESSOR_H_
#define IMAGEPROCESSOR_H_
#include <vector>
#include <opencv2/imgproc/imgproc.hpp>
#include "Config.h"
#include "ImageInput.h"
#include "AbstractDigitBoundingBoxesExtractor.h"
class ImageProcessor
{
public:
ImageProcessor(const Config& config);
~ImageProcessor();
void reloadConfig(const Config& config);
void setOrientation(int rotationDegrees);
void setInput(cv::Mat& img);
void process();
const std::vector<cv::Mat>& getOutput();
void debugWindow(bool bval = true);
void debugSkew(bool bval = true);
void debugEdges(bool bval = true);
void debugDigits(bool bval = true);
void showImage();
void saveConfig();
void loadConfig();
cv::Mat resize(cv::Mat& image, cv::Size size);
cv::Mat replaceRedWithBlack(cv::Mat& img);
private:
void rotate(double rotationDegrees);
void findCounterDigits();
std::vector<cv::Rect> findAlignedBoxesFromCounterArea(cv::Mat edges);
std::vector<cv::Rect> findAlignedBoxesFromCounterAreaManual(cv::Mat edges);
cv::Rect findCounterArea(cv::Mat& edges);
float detectSkew();
void drawLines(std::vector<cv::Vec2f>& lines);
void drawLines(std::vector<cv::Vec4i>& lines, int xoff = 0, int yoff = 0);
cv::Mat cannyEdges(cv::Mat& image, int lower, int upper);
void createGray();
cv::Mat _img;
cv::Mat _imgGray;
cv::Rect2d _digitsRegion;
std::vector<cv::Mat> _digits;
Config _config;
bool _debugWindow;
bool _debugSkew;
bool _debugEdges;
bool _debugDigits;
AbstractDigitBoundingBoxesExtractor* _boundingBoxExtractor;
};
#endif /* IMAGEPROCESSOR_H_ */