From d7e3f882feb9307c22b0cd2698e45d24804b6572 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 20 七月 2022 18:37:45 +0800
Subject: [PATCH] '完善'

---
 ConsoleApplication/THSActionUtil.cpp |  100 +++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 91 insertions(+), 9 deletions(-)

diff --git a/ConsoleApplication/THSActionUtil.cpp b/ConsoleApplication/THSActionUtil.cpp
index 720c295..63169f0 100644
--- a/ConsoleApplication/THSActionUtil.cpp
+++ b/ConsoleApplication/THSActionUtil.cpp
@@ -59,6 +59,34 @@
 }
 
 
+HWND THSActionUtil::getIndustryWindow() {
+	list<HWND> wlist = Win32Util::searchWindow("同花顺(");
+	list<HWND>::iterator ele;
+	for (ele = wlist.begin();ele != wlist.end();ele++) {
+		HWND hwnd = *ele;
+		string str = Win32Util::getWindowName(hwnd);
+		if (str.find("行业") != string::npos)
+		{
+			return hwnd;
+		}
+	}
+	return 0;
+}
+
+HWND THSActionUtil::getTradeWindow() {
+	list<HWND> wlist = Win32Util::searchWindow("网上股票交易系统");
+	list<HWND>::iterator ele;
+	for (ele = wlist.begin();ele != wlist.end();ele++) {
+		HWND hwnd = *ele;
+		return hwnd;
+	}
+	return 0;
+}
+
+
+
+
+
 //获取副屏1
 HWND getSecondWindow() {
 	list<HWND> wlist = Win32Util::searchWindow("同花顺(");
@@ -374,7 +402,7 @@
 	std::list<int*> dataItemList;
 
 	for (int i = start_row;i < end_row;i++) {
-		bool empty = ImgDivider::isRowEmpty(img, i, start_col, start_col + 50, 1, _IMG_BINARY_THRESHOLD) && ImgDivider::isRowEmpty(img, i, start_col + (end_col - start_col) / 2 - 40, start_col + (end_col - start_col) / 2 + 40, 1, _IMG_BINARY_THRESHOLD);
+		bool empty = ImgDivider::isRowEmpty(img, i, start_col, start_col + 50, 1, _IMG_BINARY_THRESHOLD)&& ImgDivider::isRowEmpty(img, i, start_col+50, start_col + 150, 2, _IMG_BINARY_THRESHOLD) && ImgDivider::isRowEmpty(img, i, start_col + (end_col - start_col) / 2 - 40, start_col + (end_col - start_col) / 2 + 40, 1, _IMG_BINARY_THRESHOLD);
 		if (empty) {
 			if (emptyStartRow < 0) {
 				emptyStartRow = i;
@@ -389,7 +417,7 @@
 				break;
 			}
 
-			if (startf > -1 && endf > -1 && (dataItemList.size()>0 &&  emptyEndRow - emptyStartRow > 3|| emptyEndRow - emptyStartRow>0)) {
+			if (startf > -1 && endf > -1 && (dataItemList.size() > 0 && emptyEndRow - emptyStartRow > 3 || emptyEndRow - emptyStartRow > 0)) {
 				//内容坐标
 				   //LogUtil::debug("内容的高度为:%d \n", endf - startf);
 
@@ -428,6 +456,60 @@
 	return dataItemList;
 }
 
+
+GPCodeArea THSActionUtil::splitPlateMenuArea(cv::Mat img) {
+	int rows = img.rows;
+	int cols = img.cols;
+	int r;
+	int contentStartRow = -1;
+	int contentEndRow = -1;
+	for (r = 5;r < img.rows;r++) {
+		if (ImgDivider::isRowFull(img, r, 0, cols - 5, 3, 12, 30)) {
+
+			if (contentStartRow < 0)
+				contentStartRow = r;
+			else if (r - contentStartRow > 100) {
+				contentEndRow = r;
+			}
+
+
+		}
+
+		if (contentStartRow > -1 && contentEndRow > -1) {
+			break;
+		}
+	}
+
+	if (contentEndRow < 0) {
+		contentEndRow = img.rows - 1;
+	}
+
+	if (contentStartRow < 0|| contentEndRow<0) {
+		throw string("起始行分隔出错");
+	}
+
+	//分隔列
+	int c = 0;
+	int startC = -1;
+	for (c = 0;c < cols;c++) {
+		if (ImgDivider::isColFull(img, c, contentStartRow + 5, contentStartRow + 100, 2)) {
+			if (startC < 0 && c>50) {
+				startC = c;
+				break;
+			}
+		}
+	}
+
+	if (startC < 0) {
+		throw string("内容框分隔出错");
+	}
+	GPCodeArea area = GPCodeArea();
+	area.startx = 0;
+	area.starty = contentStartRow;
+	area.endx = startC;
+	area.endy = contentEndRow;
+	return area;
+}
 
 //分隔板块行数据
 std::list<int*> THSActionUtil::splitPlateRowArea(cv::Mat img) {
@@ -478,12 +560,12 @@
 	//再次分隔内容框,排除干扰
 	int cut_index = -1;
 	for (int r = contentStartRow + 5;r < contentStartRow + 5 + 100;r++) {
-		
-		if (ImgDivider::isRowFull(img, r, startC, endC, 2,25,30)) {
+
+		if (ImgDivider::isRowFull(img, r, startC, endC, 2, 25, 30)) {
 			cut_index = r;
 		}
 		else {
-			if (cut_index>0&& r - cut_index > 30) {
+			if (cut_index > 0 && r - cut_index > 30) {
 				contentStartRow = cut_index;
 				break;
 			}
@@ -517,7 +599,7 @@
 	//分隔行内容
 	std::list<int*> dataItemList = THSActionUtil::splitPlateRowArea(img, start_row, start_col, end_row, end_col);
 
-	
+
 
 
 	//分隔列
@@ -813,7 +895,7 @@
 		}
 	}
 	//contentStartRow < 0 || contentEndRow < 0
-	if (contentStartRow < 0 ) {
+	if (contentStartRow < 0) {
 		throw string("起始行或结束行分隔出错");
 	}
 
@@ -894,7 +976,7 @@
 		int endRow = 0;
 		//判断结束行
 		for (int r = contentStartRow + 10;r < img.rows;r++) {
-			bool full = ImgDivider::isRowFull(img, r, startx, endx,2 , 10, 30);
+			bool full = ImgDivider::isRowFull(img, r, startx, endx, 2, 10, 30);
 			if (full) {
 				endRow = r;
 				break;
@@ -923,7 +1005,7 @@
 	int contentStartRow = -1;
 	int contentEndRow = -1;
 	for (int r = 5;r < img.rows;r++) {
-		if (ImgDivider::isRowFull(img, r, 0, img.cols/3, 2, 10, 30)&& ImgDivider::isRowFull(img, r, img.cols*2 / 3, img.cols, 2, 10, 30)) {
+		if (ImgDivider::isRowFull(img, r, 0, img.cols / 3, 2, 10, 30) && ImgDivider::isRowFull(img, r, img.cols * 2 / 3, img.cols, 2, 10, 30)) {
 			if (contentStartRow < 0)
 			{
 				contentStartRow = r;

--
Gitblit v1.8.0