forked from skaringa/emeocv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageProcessor.h
57 lines (48 loc) · 1.48 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
/*
* ImageProcessor.h
*
*/
#ifndef IMAGEPROCESSOR_H_
#define IMAGEPROCESSOR_H_
#include <vector>
#include <opencv2/imgproc/imgproc.hpp>
#include "ImageInput.h"
#include "Config.h"
using namespace cv;
class ImageProcessor {
public:
ImageProcessor(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();
private:
void rotate(double rotationDegrees);
void findCounterDigits();
void findAlignedBoxes(std::vector<cv::Rect>::const_iterator begin,
std::vector<cv::Rect>::const_iterator end, std::vector<cv::Rect>& result);
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();
void filterContours(std::vector<std::vector<cv::Point> >& contours, std::vector<cv::Rect>& boundingBoxes,
std::vector<std::vector<cv::Point> >& filteredContours);
cv::Mat _img;
cv::Mat _imgGray;
cv::Mat _imgCalque;
cv::Mat _imgCalqueGray;
std::vector<cv::Mat> _digits;
Config _config;
bool _debugWindow;
bool _debugSkew;
bool _debugEdges;
bool _debugDigits;
};
#endif /* IMAGEPROCESSOR_H_ */