From 30f434d78b58e3a4198cf5ba5a9e5a0ce1cd5292 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 07 七月 2022 14:32:36 +0800
Subject: [PATCH] 'bug修复'

---
 ConsoleApplication/ScreenDataCapture.cpp |   93 +++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 78 insertions(+), 15 deletions(-)

diff --git a/ConsoleApplication/ScreenDataCapture.cpp b/ConsoleApplication/ScreenDataCapture.cpp
index a7d2008..c8e8fd4 100644
--- a/ConsoleApplication/ScreenDataCapture.cpp
+++ b/ConsoleApplication/ScreenDataCapture.cpp
@@ -24,8 +24,13 @@
 			latest_running_times[index] = clock();
 			//识别数据
 			string code = gpCodes[index];
-			list<TradeData> resultList=captureLevel2TradeData(CaptureUtil::capture(index), index);
-			data_callback(index,code, resultList, context);
+			try {
+				list<TradeData> resultList = captureLevel2TradeData(CaptureUtil::capture(index), index);
+				data_callback(index, code, resultList, context);
+			}
+			catch (...) {
+			
+			}
 		}
 		Sleep(2);
 	}
@@ -173,11 +178,11 @@
 	try {
 		rowDataList = ImgUtil::divideImg(img);
 		if (rowDataList.size() == 0) {
-			throw ERROR_CODE_DIVIDE_IMG_FAIL;
+			throw int(ERROR_CODE_DIVIDE_IMG_FAIL);
 		}
 	}
 	catch (...) {
-		throw ERROR_CODE_DIVIDE_IMG_FAIL;
+		throw int(ERROR_CODE_DIVIDE_IMG_FAIL);
 	}
 	//准备数据
 	int* rowDataOneLevel = (int*)malloc(sizeof(int) * rowDataList.size() * 4);
@@ -196,6 +201,37 @@
 	int* rowSplitDataOneLevel = (int*)malloc(sizeof(int) * rowDataList.size() * 4 * 7);
 	openCLExcuter[identify]->splitL2RowData(imgData, img.cols, img.rows, rowDataOneLevel, rowDataList.size(), rowSplitDataOneLevel);
 	free(rowDataOneLevel);
+
+	/*
+	for (int i = 0;i < rowDataList.size();i++) {
+		string path = "C:\\Users\\Administrator\\Desktop\\ocr\\cancel_time\\";
+		path.append(to_string(identify)).append("_").append(to_string(i)).append(".jpg");
+		int start = 4 * 7 * i;
+		start += 4 * (1);
+		int startx = rowSplitDataOneLevel[start];
+		int starty = rowSplitDataOneLevel[start + 1];
+		int endx = rowSplitDataOneLevel[start + 2];
+		int endy = rowSplitDataOneLevel[start + 3];
+		if (startx > 0) {
+			cv::imwrite(path, cv::Mat(img, cv::Rect(startx, starty, endx - startx + 1, endy - starty + 1)));
+		}
+	}
+	*/
+
+	/*
+	//保存分隔的图片
+	if (true) {
+		int start = 4 * 7 * (558 - 1);
+		start += 4 * (2);
+		int startx=	rowSplitDataOneLevel[start];
+		int starty = rowSplitDataOneLevel[start+1];
+		int endx = rowSplitDataOneLevel[start+2];
+		int endy = rowSplitDataOneLevel[start+3];
+		cv::imshow("价格", cv::Mat(img, cv::Rect(startx, starty, endx - startx + 1, endy - starty + 1)));
+	}
+	*/
+
+
 
 
 	clock_t time_3 = clock();
@@ -219,7 +255,7 @@
 	clock_t time_31 = clock();
 	std::cout << "数据准备-图像数据准备: threadid-" << std::this_thread::get_id() << " 耗时:" << time_31 - time_3 << endl;
 
-	int* pos = (int*)malloc(sizeof(int) * 3 * 4 * rowDataList.size());
+	int* pos = (int*)malloc(sizeof(int) * 4 * 4 * rowDataList.size());
 
 
 	index = 0;
@@ -228,14 +264,21 @@
 		int startS = index * 4 * 7;
 
 
-		int start = index * 4 * 3;
+		int start = index * 4 * 4;
 		pos[start] = rowSplitDataOneLevel[startS + 0];
 		pos[start + 1] = rowSplitDataOneLevel[startS + 1];
 		pos[start + 2] = rowSplitDataOneLevel[startS + 2];
 		pos[start + 3] = rowSplitDataOneLevel[startS + 3];
 
 
-		start = index * 4 * 3 + 4 * 1;
+		start = index * 4 * 4 + 4 * 1;
+		pos[start] = rowSplitDataOneLevel[startS + 4 * 1 + 0];
+		pos[start + 1] = rowSplitDataOneLevel[startS + 4 * 1 + 1];
+		pos[start + 2] = rowSplitDataOneLevel[startS + 4 * 1 + 2];
+		pos[start + 3] = rowSplitDataOneLevel[startS + 4 * 1 + 3];
+
+
+		start = index * 4 * 4 + 4 * 2;
 		pos[start] = rowSplitDataOneLevel[startS + 4 * 2 + 0];
 		pos[start + 1] = rowSplitDataOneLevel[startS + 4 * 2 + 1];
 		pos[start + 2] = rowSplitDataOneLevel[startS + 4 * 2 + 2];
@@ -243,7 +286,7 @@
 
 
 
-	    start = index * 4 * 3 + 4 * 2;
+	    start = index * 4 * 4 + 4 * 3;
 		pos[start] = rowSplitDataOneLevel[startS + 4 * 5 + 0];
 		pos[start + 1] = rowSplitDataOneLevel[startS + 4 * 5 + 1];
 		pos[start + 2] = rowSplitDataOneLevel[startS + 4 * 5 + 2];
@@ -267,7 +310,7 @@
 	clock_t time_33 = clock();
 	std::cout << "数据准备-0数据准备: threadid-" << std::this_thread::get_id() << " 耗时:" << time_33 - time_32 << endl;
 
-	openCLExcuter[identify]->splitL2Num(imgData, img.cols, img.rows, pos, 3 * rowDataList.size(), zeroData, _NUMBER_L2_WIDTH, _NUMBER_L2_HEIGHT, _NUMBER_L2_TOTAL_NUMBER, totalNumberData);
+	openCLExcuter[identify]->splitL2Num(imgData, img.cols, img.rows, pos, 4 * rowDataList.size(), zeroData, _NUMBER_L2_WIDTH, _NUMBER_L2_HEIGHT, _NUMBER_L2_TOTAL_NUMBER, totalNumberData);
 
 	free(pos);
 	free(zeroData);
@@ -302,14 +345,28 @@
 	list<TradeData> resultList;
 
 
-	int* notNumberResult = (int*)malloc(sizeof(int)* rowDataList.size()*2);
+	int* notNumberResult = (int*)malloc(sizeof(int)* rowDataList.size()*3);
 	openCLExcuter[identify]->recognitionNotNum(img.data,img.cols,img.rows, rowSplitDataOneLevel,7, rowDataList.size(), notNumberResult);
 
 
 
 	for (int i = 0;i < rowDataList.size();i++) {
 		TradeData td = TradeData();
-		switch (notNumberResult[i * 2])
+
+		switch (notNumberResult[i * 3])
+		{
+		case 0:
+			td.cancelTimeUnit = TIME_SECOND;break;
+		case 1:
+			td.cancelTimeUnit = TIME_MINITE;break;
+		case 2:
+			td.cancelTimeUnit = TIME_HOUR;break;
+
+		default:
+			break;
+		}
+
+		switch (notNumberResult[i * 3+1])
 		{
 		case 0:
 			td.limitPrice = LIMIT_PRICE_NORMAL;break;
@@ -321,7 +378,7 @@
 		default:
 			break;
 		}
-		switch (notNumberResult[i * 2 + 1])
+		switch (notNumberResult[i * 3 + 2])
 		{
 		case OPERATE_BUY:
 			td.operateType = OPERATE_BUY;
@@ -373,19 +430,25 @@
 		time.append(to_string(lineData[2])).append(to_string(lineData[3]));
 		time.append(":");
 		time.append(to_string(lineData[4])).append(to_string(lineData[5]));
+
+		string cancelTime = "";
+		cancelTime.append(to_string(lineData[6])).append(to_string(lineData[7]));
+
+
 		string price = "";
-		price.append(to_string(lineData[6])).append(to_string(lineData[7])).append(to_string(lineData[8])).append(to_string(lineData[9]));
+		price.append(to_string(lineData[6+2])).append(to_string(lineData[7+2])).append(to_string(lineData[8+2])).append(to_string(lineData[9+2]));
 		price.append(".");
-		price.append(to_string(lineData[10])).append(to_string(lineData[11]));
+		price.append(to_string(lineData[10+2])).append(to_string(lineData[11+2]));
 
 		string num = "";
-		num.append(to_string(lineData[12])).append(to_string(lineData[13])).append(to_string(lineData[14])).append(to_string(lineData[15])).append(to_string(lineData[16]));
+		num.append(to_string(lineData[12+2])).append(to_string(lineData[13+2])).append(to_string(lineData[14+2])).append(to_string(lineData[15+2])).append(to_string(lineData[16+2]));
 
 
 		(*tradeEle).time = time;
 		(*tradeEle).num = stoi(num);
 		(*tradeEle).price = price;
 		(*tradeEle).index = index;
+		(*tradeEle).cancelTime = stoi(cancelTime);
 
 		//释放内存
 		free(lineData);

--
Gitblit v1.8.0