瀏覽代碼

【bug修复】(黄根)优化定位点查找范围,减少定位点无法被识别到的情况 & A3尺寸的答题卡模板中定位点是乱序的,修正原定位点计算逻辑,以正常识别
【工作量】3h
【评审人】

huanggen 2 年之前
父節點
當前提交
15be4ea8f2
共有 2 個文件被更改,包括 12 次插入6 次删除
  1. 5 2
      Identifier/OnLineCardPageIdentifier.cpp
  2. 7 4
      Identifier/PageIdentify.cpp

+ 5 - 2
Identifier/OnLineCardPageIdentifier.cpp

@@ -1076,7 +1076,8 @@ namespace OnLineCard{
 				rc_tmp.height = lcs[j].pos.h;
 				vec_locations_word.push_back(rc_tmp);
 			}
-			wordloctlt = vec_locations_word[3].y - vec_locations_word[0].y;
+			std::sort(vec_locations_word.begin(), vec_locations_word.end(), sort_locate_point_by_y);
+			wordloctlt = vec_locations_word[vec_locations_word.size() - 1].y - vec_locations_word[0].y;
 			double word_w = page.w;
 			double word_h = page.h;
 			tt[2] = word_w;
@@ -1216,7 +1217,9 @@ namespace OnLineCard{
 			int m = 0;
 			dingweidianH = m_pTemplate->pages[1].location[m].pos.h;
 			dingweidianW = m_pTemplate->pages[1].location[m].pos.w;
-			m_default_schema_param.main_locate_point_distance = m_pTemplate->pages[1].location[m + 2].pos.x - m_pTemplate->pages[1].location[m].pos.x;
+			std::vector<Location> vecLocation = m_pTemplate->pages[1].location;
+			std::sort(vecLocation.begin(), vecLocation.end(), [=](Location l1, Location l2){ return l1.pos.x < l2.pos.x; });
+			m_default_schema_param.main_locate_point_distance = vecLocation.at(vecLocation.size() - 1).pos.x - vecLocation.begin()->pos.x;
 			m_default_schema_param.shijuanwidth = m_pTemplate->pages[1].w;
 			for (int i = 0; i < 4; i++)
 			{

+ 7 - 4
Identifier/PageIdentify.cpp

@@ -731,8 +731,8 @@ namespace OnLineCard{
 		{
 			//根据图片像素比例调整定位点检查区域高度
 			double dLocPointHeight = m_pTemplate->pages[1].location.at(0).pos.h;
-			m_pTemplate->dingweidian_range_top = dLocPointHeight * 5 * src_gray_img->height / m_pTemplate->pages[1].h;
-			m_pTemplate->dingweidian_rang_buttom = dLocPointHeight * 5 * src_gray_img->height / m_pTemplate->pages[1].h;
+			m_pTemplate->dingweidian_range_top = dLocPointHeight * 6 * src_gray_img->height / m_pTemplate->pages[1].h;
+			m_pTemplate->dingweidian_rang_buttom = dLocPointHeight * 6 * src_gray_img->height / m_pTemplate->pages[1].h;
 		}
 		int range = m_pTemplate->dingweidian_range_top;
 		//LOGFMTI("MyFindDingWeiDian 1 range=%d", range);
@@ -1084,7 +1084,8 @@ namespace OnLineCard{
 				rc_tmp.height = lcs[j].pos.h;
 				vec_locations_word.push_back(rc_tmp);
 			}
-			wordloctlt = vec_locations_word[3].y - vec_locations_word[0].y;
+			std::sort(vec_locations_word.begin(), vec_locations_word.end(), sort_locate_point_by_y);
+			wordloctlt = vec_locations_word[vec_locations_word.size() - 1].y - vec_locations_word[0].y;
 			double word_w = page.w;
 			double word_h = page.h;
 			tt[2] = word_w;
@@ -1224,7 +1225,9 @@ namespace OnLineCard{
 			int m = 0;
 			dingweidianH = m_pTemplate->pages[1].location[m].pos.h;
 			dingweidianW = m_pTemplate->pages[1].location[m].pos.w;
-			m_default_schema_param.main_locate_point_distance = m_pTemplate->pages[1].location[m + 2].pos.x - m_pTemplate->pages[1].location[m].pos.x;
+			std::vector<Location> vecLocation = m_pTemplate->pages[1].location;
+			std::sort(vecLocation.begin(), vecLocation.end(), [=](Location l1, Location l2){ return l1.pos.x < l2.pos.x; });
+			m_default_schema_param.main_locate_point_distance = vecLocation.at(vecLocation.size() - 1).pos.x - vecLocation.begin()->pos.x;
 			m_default_schema_param.shijuanwidth = m_pTemplate->pages[1].w;
 			for (int i = 0; i < 4; i++)
 			{