-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimg_handler.h
More file actions
67 lines (56 loc) · 2.11 KB
/
img_handler.h
File metadata and controls
67 lines (56 loc) · 2.11 KB
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
#ifndef IMG_HANDLER_H
#define IMG_HANDLER_H
#include "all_headers.h"
#define IMG_HANDLER_DEBUG 0
#define BOTTOM_STICK_LENGTH 7 //11
#define UPPER_SICK_LENGTH 25 //25
#define MIN_TEXT_BLOCK_AREA 50
using namespace std;
using namespace cv;
struct Piece{
Mat pic;
Rect coord;
};
enum cmp_enum{
less,
equal,
large,
cross,
};
void vertical_hist(Mat src, Mat& dst,int cols = 250);
void vertical_hist(Mat src,vector<int>& hist);
void horizontal_hist(Mat src, Mat& dst,int rows = 180);
void horizontal_hist(Mat src,vector<int>& hist);
void cut_text_line(Mat in,vector<Mat>& out,int threshold= 1);
void cut_words(Mat in,vector<vector<Mat>>& out,int threshold= 10);
void drop_non_text(Piece src, Piece &dst);
void drop_non_text(vector<Piece> src,vector<Piece> &dst);
void filter_pieces(Mat src_img, vector<Piece> src_vec, vector<Piece> &dst,int min_area = 100);
void my_inv(Mat in);
void my_grad(Mat src, Mat &dst);
void find_bound_rects(Mat src, vector<Rect> &dst);
void find_bound_rects_rgb(Mat src,vector<Rect> &b_rect); // find bound rect for color Mat
void to_Piece(vector<Mat> pic, vector<Rect> rect, vector<Piece> &dst);
void blend_with_mask(Mat &base, Mat &src, Mat &mask, Mat &out);
void matchTemplateCoords(Mat img, Mat templ,Mat mask,Point& matchLoc);
void matchTemplateCoords(Mat img, Mat templ,Point& matchLoc);
void add_white_border(Mat src, Mat &dst, int border_size = 1);
void fill_block_white(Mat src, Mat &dst, Rect block);
//void insert(Mat src, Mat inset, Point coord);
void vec_imshow(string name, vector<Mat> src);
void vec_imshow(string name, vector<Piece> src);
void show_rects(Mat src, vector<Rect> rects, string title);
void thresh_otsu(Mat src,Mat &dst);
void my_find_contours(Mat src, vector<Rect> &b_rect, int border = 10);
bool same_shape(Mat a, Rect b);
bool piece_is_word(Mat dst, int threshold = 1);
bool is_white(Mat src);
template<typename T>
int expected_value(vector<T> row);
template<typename T>
int median(vector<T> row);
int countNonZero_rgb(Mat src);
double cmp(Mat x, Mat y); // 1 - equal, 0 - different
double cmp_templ(Mat x, Mat y);
cmp_enum cmp_shape(Mat x, Mat y);
#endif // IMG_HANDLER_H