From 67a5e3d825fde17b7b00906ce42b0bd8cafebc4e Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 18 八月 2022 18:22:14 +0800
Subject: [PATCH] '完善'

---
 ConsoleApplication/THSGPDataCapture.cpp |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/ConsoleApplication/THSGPDataCapture.cpp b/ConsoleApplication/THSGPDataCapture.cpp
index 6180cde..3b5b9ef 100644
--- a/ConsoleApplication/THSGPDataCapture.cpp
+++ b/ConsoleApplication/THSGPDataCapture.cpp
@@ -36,15 +36,12 @@
 
 
 
-list<list<GPDataStruct>> THSGPDataCapture::captureGPData(cv::Mat grayImg, SplitType types[], int length_per_num) {
+list<list<GPDataStruct>> THSGPDataCapture::captureGPData(cv::Mat grayImg, SplitType types[], int length_per_num, int startColumn, int endColumn) {
 
 
 	list<int*> rowData = THSActionUtil::splitPlateRowArea(grayImg);
-	//每行的元素个数
-	int ele_count_per_line = sizeof(types) / sizeof(types[0]);
-	int* splitResult = (int*)malloc(sizeof(int) * 4 * ele_count_per_line * rowData.size());
-	int* rowIndex = (int*)malloc(sizeof(int) * 4 * rowData.size());
 	int count = 0;
+	int* rowIndex = (int*)malloc(sizeof(int) * 4 * rowData.size());
 	for (std::list<int*>::iterator ele = rowData.begin();ele != rowData.end();ele++) {
 
 		string path = "C:\\Users\\Administrator\\Desktop\\ocr\\limit_up\\";
@@ -57,11 +54,12 @@
 		free(*ele);
 		count++;
 	}
-
-
+	//每行的元素个数
+	int ele_count_per_line = sizeof(types) / sizeof(types[0]);
+	int* splitResult = (int*)malloc(sizeof(int) * 4 * ele_count_per_line * rowData.size());
 	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, startColumn, endColumn, splitResult);
 
 	//分割数字
 	unsigned char* zeroData = (unsigned char*)malloc(sizeof(unsigned char) * _NUMBER_GP_CODE_WIDTH * _NUMBER_GP_CODE_HEIGHT);
@@ -126,9 +124,10 @@
 				}
 
 				char* priceCode;
-				priceCode = new char[20];
-				sprintf_s(priceCode, money.length(), "%.2lf", stod(money));
+				priceCode = new char[100];
+				sprintf_s(priceCode, 100, "%.2lf", stod(money));
 				std::string _str(priceCode);
+				delete[] priceCode;
 				money = _str;
 
 				industryData.type = NUM_TYPE_MONEY;
@@ -146,9 +145,10 @@
 				}
 
 				char* priceCode;
-				priceCode = new char[20];
-				sprintf_s(priceCode, price.length(), "%.2lf", stod(price));
+				priceCode = new char[100];
+				sprintf_s(priceCode, 100, "%.2lf", stod(price));
 				std::string _str(priceCode);
+				delete[] priceCode;
 				price = _str;
 
 				industryData.type = NUM_TYPE_PRICE;

--
Gitblit v1.8.0