From 14db1514fec89db599766d4996b4bb1fead0eff0 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 25 八月 2022 17:49:54 +0800 Subject: [PATCH] '完善' --- ConsoleApplication/LimitUpCapture.cpp | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/ConsoleApplication/LimitUpCapture.cpp b/ConsoleApplication/LimitUpCapture.cpp index 0e55f9c..fdcd81c 100644 --- a/ConsoleApplication/LimitUpCapture.cpp +++ b/ConsoleApplication/LimitUpCapture.cpp @@ -2,10 +2,13 @@ #include "THSActionUtil.h" #include <set> #include "Win32Util.h" +#include "TaskChecker.h" OpenCLExcuter* LimitUpCapture::openCLExcuter; bool LimitUpCapture::inited; //是否正在执行 bool LimitUpCapture::running; + +bool LimitUpCapture::kill; CallbackFun_Limit_Up LimitUpCapture::data_callback; @@ -27,6 +30,9 @@ void LimitUpCapture::_run() { while (true) { + if (kill) + break; + TaskChecker::clientLiveTime.limitUp = clock(); if (running && inited) { clock_t start = clock(); list<LimitUpData> codes = captureLimitUpCodes(); @@ -34,6 +40,9 @@ data_callback(codes, context); codes.clear(); Sleep(3000); + } + else { + Sleep(1000); } } } @@ -44,6 +53,7 @@ data_callback = callback; context = contex; running = false; + kill = false; recognitionManager = new RecognitionManager(); openCLExcuter = new OpenCLExcuter(); openCLExcuter->init(); @@ -51,6 +61,14 @@ rt.detach(); inited = true; refreshHWND(); +} +void LimitUpCapture::reCreateRunning() +{ + kill = TRUE; + Sleep(4000); + kill = FALSE; + thread rt(&(LimitUpCapture::_run)); + rt.detach(); } void LimitUpCapture::refreshHWND() { HWND hwnd = getWindow(); @@ -180,7 +198,6 @@ int* rowIndex = (int*)malloc(sizeof(int) * 4 * rowData.size()); int count = 0; for (std::list<int*>::iterator ele = rowData.begin();ele != rowData.end();ele++) { - string path = "C:\\Users\\Administrator\\Desktop\\ocr\\limit_up\\"; path.append(to_string(count)).append(".jpg"); //cv::imwrite(path, cv::Mat(grayImg, cv::Rect((*ele)[0], (*ele)[1], (*ele)[2] - (*ele)[0] + 1, (*ele)[3] - (*ele)[1] + 1))); @@ -346,6 +363,9 @@ list<cv::Point>::iterator ele; for (ele = pointList.begin();ele != pointList.end();ele++) { + if (kill) { + break; + } int x = (*ele).x;//+ menuRect.left; int y = (*ele).y;//+ menuRect.top; printf("x:%d y:%d\n", x, y); @@ -359,6 +379,9 @@ for (int i = 0;i < 3;i++) { + if (kill) { + break; + } int x = wrect.right - 50; int y = wrect.top + 50; SendMessage(win, WM_MOUSEWHEEL, 0, MAKEWORD(x, y)); -- Gitblit v1.8.0