From a17738e1545ff7dbef6398b8ec1eab93ab59c9a1 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 30 六月 2022 19:14:47 +0800
Subject: [PATCH] '功能完善'

---
 ConsoleApplication/ImgUtil.cpp |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/ConsoleApplication/ImgUtil.cpp b/ConsoleApplication/ImgUtil.cpp
index 6299532..8259bb7 100644
--- a/ConsoleApplication/ImgUtil.cpp
+++ b/ConsoleApplication/ImgUtil.cpp
@@ -251,11 +251,11 @@
 	}
 	return nums;
 }
-//分隔整数
-list<cv::Mat> ImgUtil::splitNum(cv::Mat src)  throw(string) {
+
+list<cv::Mat> ImgUtil::splitNum(cv::Mat src,int threshold_value)  throw(string) {
 	cv::Mat binary;
 	//去除上下的空白图
-	threshold(src, binary, _IMG_BINARY_THRESHOLD, 255, cv::THRESH_BINARY);
+	threshold(src, binary, threshold_value , 255, cv::THRESH_BINARY);
 	int rows = src.rows;
 	int cols = src.cols;
 
@@ -340,6 +340,11 @@
 		}*/
 	}
 	return resultList;
+}
+
+//分隔整数
+list<cv::Mat> ImgUtil::splitNum(cv::Mat src)  throw(string) {
+	return splitNum(src,_IMG_BINARY_THRESHOLD);
 }
 
 cv::Mat  ImgUtil::formatNumLevel2(cv::Mat num)  throw(string) {
@@ -459,6 +464,7 @@
 }
 
 list<int*> ImgUtil::divideImg(cv::Mat img, bool save) {
+	//cv::imwrite("C:\\Users\\Administrator\\Desktop\\ocr\\demo\\0_gray.jpg", img);
 	clock_t start_time = clock();
 	LogUtil::info("开始分隔图像");
 	list<list<int*>> resultList;
@@ -495,7 +501,7 @@
 	}
 
 	if (contentStartRow < 0) {
-		LogUtil::error("图像分隔出错:title分隔出错");
+		throw string("图像分隔出错:title分隔出错");
 	}
 
 	LogUtil::debug("\n\n\n\n");
@@ -757,7 +763,8 @@
 			}
 		}
 
-
+		//释放数据
+		free(*ele);
 
 
 	}

--
Gitblit v1.8.0