| | |
| | | SendMessage(close, WM_CLOSE, 0, 0); |
| | | } |
| | | |
| | | |
| | | std::list<GPCodeArea> THSActionUtil::getListenL2GPAreaAndCode(RecognitionManager* recognitionManager) { |
| | | //截图当前有哪些股票代码 |
| | | list<HWND> wlist = Win32Util::searchWindow("同花顺("); |
| | |
| | | //截图 |
| | | cv::Mat oimg = CaptureUtil::capture(content); |
| | | cv::Mat img = ImgUtil::grayImage(oimg); |
| | | |
| | | oimg.release(); |
| | | //分隔图片 |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | // 获取操作区域 |
| | | std::list<std::list<GPCodeArea>> THSActionUtil::getListenL2GPAreaActionBar() { |
| | | //截图当前有哪些股票代码 |
| | | list<HWND> wlist = Win32Util::searchWindow("同花顺("); |
| | | HWND mainPage = 0; |
| | | list<HWND>::iterator ele; |
| | | for (ele = wlist.begin(); ele != wlist.end(); ele++) { |
| | | HWND hwnd = *ele; |
| | | string str = Win32Util::getWindowName(hwnd); |
| | | if (isL2Screen(str)) { |
| | | cout << hwnd << endl; |
| | | //获取尺寸 |
| | | RECT rc; |
| | | GetWindowRect(hwnd, &rc); |
| | | if (rc.right - rc.left > 200 && rc.bottom - rc.top > 200) { |
| | | mainPage = hwnd; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (mainPage <= 0) { |
| | | throw string("L2监听未打开(25)"); |
| | | } |
| | | |
| | | HWND content = FindWindowExA(mainPage, NULL, "AfxFrameOrView100s", NULL); |
| | | //截图 |
| | | cv::Mat oimg = CaptureUtil::capture(content); |
| | | cv::Mat img = ImgUtil::grayImage(oimg); |
| | | |
| | | oimg.release(); |
| | | //分隔图片 |
| | | |
| | | std::list<GPCodeArea> areaList = splitL2Cate(img); |
| | | std::list<GPCodeArea> fresultList; |
| | | |
| | | int index = 0; |
| | | for (std::list<GPCodeArea>::iterator ele = areaList.begin(); ele != areaList.end(); ele++) { |
| | | GPCodeArea area = *ele; |
| | | |
| | | int startRow = -1; |
| | | int endRow = -1; |
| | | for (int r = area.endy; r >= area.starty; r--) { |
| | | |
| | | if (!ImgDivider::isRowEmpty(img, r, area.startx, (area.endx + area.startx)/2)) { |
| | | if (startRow < 0) |
| | | { |
| | | startRow = r; |
| | | endRow = r; |
| | | } |
| | | endRow = r; |
| | | } |
| | | else { |
| | | if (startRow > 0 && endRow > 0) { |
| | | if (startRow - endRow > 10) { |
| | | GPCodeArea farea; |
| | | farea.startx = area.startx; |
| | | farea.endx = area.endx; |
| | | farea.starty = endRow; |
| | | farea.endy = startRow; |
| | | fresultList.push_back(farea); |
| | | // TODO 暂时打开 |
| | | if (false) { |
| | | string path = "C:\\Users\\Administrator\\Desktop\\ocr\\gpcode\\"; |
| | | path.append("cate_").append(to_string(index)).append(".jpg"); |
| | | cv::imwrite(path, cv::Mat(img, cv::Rect(farea.startx, farea.starty, farea.endx - farea.startx + 1, farea.endy - farea.starty + 1))); |
| | | } |
| | | break; |
| | | } |
| | | else { |
| | | startRow = endRow; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | index++; |
| | | } |
| | | |
| | | index = 0; |
| | | std::list<list<GPCodeArea>> ffresultList; |
| | | //切割每一块的菜单 |
| | | for (std::list<GPCodeArea>::iterator ele = fresultList.begin(); ele != fresultList.end(); ele++) { |
| | | GPCodeArea area = *ele; |
| | | int start_col = area.startx; |
| | | |
| | | list<GPCodeArea> tempList; |
| | | |
| | | for (int c = area.startx; c <= area.endx; c++) { |
| | | //通过第一行的纯黑点做分隔 |
| | | if (img.ptr<uchar>(area.starty)[c] <= 5) { |
| | | if (c - start_col > 10) { |
| | | //获取到分隔点 |
| | | GPCodeArea child; |
| | | child.startx = start_col; |
| | | child.endx = c -1; |
| | | child.starty = area.starty; |
| | | child.endy = area.endy; |
| | | tempList.push_back(child); |
| | | start_col = c; |
| | | |
| | | if (false) { |
| | | string path = "C:\\Users\\Administrator\\Desktop\\ocr\\gpcode\\"; |
| | | path.append("cate_").append(to_string(index)).append("_").append(to_string(c)).append(".jpg"); |
| | | cv::imwrite(path, cv::Mat(img, cv::Rect(child.startx, child.starty, child.endx - child.startx + 1, child.endy - child.starty + 1))); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | index++; |
| | | ffresultList.push_back(tempList); |
| | | } |
| | | |
| | | |
| | | return ffresultList; |
| | | |
| | | } |
| | | |
| | | cv::Mat getTHSTimeCapture() { |
| | | HWND hwnd = THSActionUtil::getMainWin(); |
| | | if (hwnd <= 0) { |