#pragma once #include #include #include #include #include #include #include #include #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 splitTime(cv::Mat img) throw(string); //·Ö¸ôСÊý£¬ÖмäµÄ¿ÕMat±íʾСÊýµã static list splitDecimal(cv::Mat img) throw(string); //½«0-9µÄÊý×ÖͼƬ×ö¸ñʽ»¯ static cv::Mat formatNumLevel2(cv::Mat num) throw(string); public: static void init(); //·Ö¸ôͼƬ static list divideImg(cv::Mat img); static list divideImg(cv::Mat img,bool save); /* * ·Ö¸ôÿһÐеÄÊý×ÖÊý¾Ý£¬¸ñʽΪxx:xx:xx xxxx.xx xxxxx * */ static void splitRowNumDataForOpenCL(cv::Mat img, list 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 splitNum(cv::Mat img) throw(string); static list 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); };