From 1a16b19acb23a4f28bafd01f3ed80fb225a96c3e Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期五, 30 九月 2022 18:04:12 +0800 Subject: [PATCH] 'bug修复' --- ConsoleApplication/CurrentPriceCapture.cpp | 84 +++++++++++++++++++++++++++++++++++------- 1 files changed, 70 insertions(+), 14 deletions(-) diff --git a/ConsoleApplication/CurrentPriceCapture.cpp b/ConsoleApplication/CurrentPriceCapture.cpp index 108e673..1f8c3ee 100644 --- a/ConsoleApplication/CurrentPriceCapture.cpp +++ b/ConsoleApplication/CurrentPriceCapture.cpp @@ -32,7 +32,7 @@ if (kill) break; if (tradeTimeCapture) { - if (!GPUtil::isPreTradeTime()) { + if (!GPUtil::isTradeTime()) { Sleep(100); continue; } @@ -72,7 +72,12 @@ thread rt(&(CurrentPriceCapture::_run)); rt.detach(); inited = true; - refreshHWND(); + try { + refreshHWND(); + } + catch (string st) { + + } } void CurrentPriceCapture::reCreateRunning() { @@ -124,7 +129,8 @@ list<int*> rowData = THSActionUtil::splitPlateRowArea(grayImg); //每行的元素个数 - int ele_count_per_line = 2; + int ele_count_per_line = 3; + int length_per_num = 6; int* splitResult = (int*)malloc(sizeof(int) * 4 * 4 * rowData.size()); int* rowIndex = (int*)malloc(sizeof(int) * 4 * rowData.size()); int count = 0; @@ -141,9 +147,9 @@ count++; } - int line_number_count = ele_count_per_line * 6; + int line_number_count = ele_count_per_line * length_per_num; - openCLExcuter->splitPlateContentRowData(grayImg.data, grayImg.cols, grayImg.rows, rowIndex, rowData.size(), ele_count_per_line,1,2,splitResult); + openCLExcuter->splitPlateContentRowData(grayImg.data, grayImg.cols, grayImg.rows, rowIndex, rowData.size(), ele_count_per_line,1,3,splitResult); /* *测试 @@ -183,10 +189,9 @@ UcharDataInfo typesData = UcharDataInfo(); - unsigned char types[] = { NUM_TYPE_CODE, NUM_TYPE_PRICE }; - typesData.length = 2; + unsigned char types[] = { NUM_TYPE_MONEY, NUM_TYPE_CODE, NUM_TYPE_PRICE }; + typesData.length = 3; typesData.data = types; - int length_per_num = 6; openCLExcuter->splitPlateNum(grayImg, IntDataInfo({ splitResult,(int)(ele_count_per_line * rowData.size()) }), UcharDataInfo({ totalNumberData, -1 }), typesData, zeroData, _NUMBER_GP_CODE_WIDTH, _NUMBER_GP_CODE_HEIGHT, ele_count_per_line, length_per_num); @@ -200,24 +205,34 @@ list<CurrentPriceData> dataList; for (int i = 0;i < rowData.size();i++) { CurrentPriceData currentData = CurrentPriceData(); - string code = ""; - for (int j = 0;j < 6;j++) + + string volumn = ""; + for (int j = 0;j < length_per_num;j++) { - code.append(to_string(numberResult[i][j])); + if (j == 4) { + volumn.append("."); + } + volumn.append(to_string(numberResult[i][length_per_num * 0 + j])); + } + + string code = ""; + for (int j = 0;j < length_per_num;j++) + { + code.append(to_string(numberResult[i][length_per_num * 1 + j])); } string price = ""; - for (int j = 0;j < 6;j++) + for (int j = 0;j < length_per_num;j++) { if (j == 4) { price.append("."); } - price.append(to_string(numberResult[i][6 * 1 + j])); + price.append(to_string(numberResult[i][length_per_num * 2 + j])); } currentData.index = i; currentData.code = code; - + currentData.volumn = volumn; currentData.price = price; if ( currentData.price != "0000.00") { dataList.push_back(currentData); @@ -226,12 +241,53 @@ } free(numberResult); int* unitData = (int*)malloc(sizeof(int) * 4 * dataList.size()); + //获取量的单位 + int index = 0; + for (list<CurrentPriceData>::iterator ele = dataList.begin();ele != dataList.end();ele++) { + unitData[index * 4 + 0] = splitResult[(*ele).index * 4 * ele_count_per_line + 4 * 0 + 0]; + unitData[index * 4 + 1] = splitResult[(*ele).index * 4 * ele_count_per_line + 4 * 0 + 1]; + unitData[index * 4 + 2] = splitResult[(*ele).index * 4 * ele_count_per_line + 4 * 0 + 2]; + unitData[index * 4 + 3] = splitResult[(*ele).index * 4 * ele_count_per_line + 4 * 0 + 3]; + index++; + } + int* unitResult = (int*)malloc(sizeof(int) * dataList.size()); + openCLExcuter->recognitionPlateMoneyUnit(grayImg.data, grayImg.cols, grayImg.rows, unitData, 1, dataList.size(), unitResult); + index = 0; + for (list<CurrentPriceData>::iterator ele = dataList.begin();ele != dataList.end();ele++) { + switch (unitResult[index]) + { + case 0: + (*ele).volumnUnit = MONEY_UNIT_Y; + break; + case 1: + (*ele).volumnUnit = MONEY_UNIT_W; + break; + case 2: + (*ele).volumnUnit = MONEY_UNIT_NO; + (*ele).volumn = to_string((int)round( stof((*ele).volumn) * 100)); + default: + break; + } + //cout<< (*ele).code<<" "<< (*ele).price <<" "<< (*ele).volumn; + //if ((*ele).volumnUnit == MONEY_UNIT_Y) { + // cout <<"亿"<<endl; + //}else if ((*ele).volumnUnit == MONEY_UNIT_W) { + // cout << "万" << endl; + //} + //else { + // cout << "" << endl; + //} + + index++; + } + free(rowIndex); free(splitResult); free(zeroData); free(templateNums); free(unitData); + free(unitResult); free(imgData); grayImg.release(); -- Gitblit v1.8.0