admin
2023-03-07 8b06b1cbf112d55307ea8a6efe711db4e7506d89
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#pragma once
 
 
 
#include <list>
#include <iostream>
#include <math.h>
#include<Windows.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp> 
#ifndef _IMGDIVIDER_INCLUDE_
#define _IMGDIVIDER_INCLUDE_
#include "ImgDivider.h"
#endif 
 
#include "RecognitionUtil.h"
 
#include "win32_screen_shots.h"
 
#ifndef _NUMBER_L2_WIDTH
#define _NUMBER_L2_WIDTH 5
#endif 
 
#ifndef _NUMBER_L2_HEIGHT
#define _NUMBER_L2_HEIGHT 8
#endif 
 
#ifndef _NUMBER_L2_TOTAL_NUMBER
#define _NUMBER_L2_TOTAL_NUMBER 19
#endif 
 
 
#ifndef _NUMBER_GP_CODE_WIDTH
#define _NUMBER_GP_CODE_WIDTH 6
#endif 
 
#ifndef _NUMBER_GP_CODE_HEIGHT
#define _NUMBER_GP_CODE_HEIGHT 10
#endif 
 
#ifndef _NUMBER_GP_CODE_TOTAL_NUMBER
#define _NUMBER_GP_CODE_TOTAL_NUMBER 6
#endif  
 
 
#ifndef _NUMBER_TRADE_QUEUE_WIDTH
#define _NUMBER_TRADE_QUEUE_WIDTH 6
#endif 
 
#ifndef _NUMBER_TRADE_QUEUE_HEIGHT
#define _NUMBER_TRADE_QUEUE_HEIGHT 8
#endif 
 
#ifndef _IMG_BINARY_THRESHOLD
#define _IMG_BINARY_THRESHOLD 64
#endif 
 
 
struct  ImgArea
{
    int startx;
    int starty;
    int endx;
    int endy;
};
 
struct  OCRResult
{
    string text;
    RECT rect;
 
};
 
 
using namespace std;
class ImgUtil
{
public:
    static NumberData NUMS_LEVEL2[10];
    static NumberData NUMS_GP_CODE[10];
    static NumberData NUMS_TRADE_QUEUE[10];
 
 
    //Êý×Ö£¨0-9£©Ò»Î¬Êý¾Ý
    static uchar* numsOneLevel_level2;
    static uchar* numsOneLevel_gpcode;
    static uchar* numsOneLevel_trade_queue;
 
 
private:
    //·Ö¸ôʱ¼ä
    static list<cv::Mat> splitTime(cv::Mat img)  throw(string);
    //·Ö¸ôСÊý£¬ÖмäµÄ¿ÕMat±íʾСÊýµã
    static list<cv::Mat> splitDecimal(cv::Mat img)  throw(string);
 
    //½«0-9µÄÊý×ÖͼƬ×ö¸ñʽ»¯
    static cv::Mat formatNumLevel2(cv::Mat num)  throw(string);
 
 
 
public:
 
    static void init();
 
    //·Ö¸ôͼƬ
    static list<int*> divideImg(cv::Mat img);
 
 
    static list<int*> divideImg(cv::Mat img,bool save);
 
 
    /*
    * ·Ö¸ôÿһÐеÄÊý×ÖÊý¾Ý£¬¸ñʽΪxx:xx:xx xxxx.xx xxxxx
    *
    */
    static  void splitRowNumDataForOpenCL(cv::Mat img, list<int*> data, unsigned char* result, int rowIndex) throw(string);
 
    //ͼƬ»Ò¶È
    static cv::Mat grayImage(cv::Mat src);
 
    //¹¹½¨Ä£°åÊý¾Ý£¬ÓÃÓÚopencl¾ØÕóÔËËãÖеÄÊý×Öʶ±ð
    static uchar* createTemplateNumData(int lines);
 
    static bool isImgSame(cv::Mat m1, cv::Mat m2);
 
    //·Ö¸ôÕûÊý
    static list<cv::Mat> splitNum(cv::Mat img)  throw(string);
 
    static list<cv::Mat> splitNum(cv::Mat img,int threshold_value)  throw(string);
 
    static cv::Mat formatNumGPCode(cv::Mat num)  throw(string);
 
    static cv::Mat formatNumTradeQueue(cv::Mat num)  throw(string);
 
    // ±ê¼ÇMatÖеÄÇøÓò
    static cv::Mat markMat(cv::Mat mat, cv::Rect rect, uchar borderColor, int borderWidth);
};