From 04d89bc9216553adcd0df87985a7665882924093 Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期五, 22 八月 2025 17:56:10 +0800
Subject: [PATCH] 1. 优化Notch计算周长,使用比例的形式计算

---
 EdgeInspector_App/Data/PostProcess.cpp |   70 ++++++++++++++++++++++-------------
 1 files changed, 44 insertions(+), 26 deletions(-)

diff --git a/EdgeInspector_App/Data/PostProcess.cpp b/EdgeInspector_App/Data/PostProcess.cpp
index c9a5c59..a2bd149 100644
--- a/EdgeInspector_App/Data/PostProcess.cpp
+++ b/EdgeInspector_App/Data/PostProcess.cpp
@@ -1,4 +1,4 @@
-#include "StdAfx.h"
+锘�#include "StdAfx.h"
 #include "PostProcess.h"
 #include "Config.h"
 #include "FreeImage.h"
@@ -180,7 +180,7 @@
 	if (glass_id.IsEmpty() == TRUE)
 		glass_id.Format(_T("MANUAL_ID"));
 
-	// 获取当前产品加载时间
+	// 鑾峰彇褰撳墠浜у搧鍔犺浇鏃堕棿
 	CTime tGlassLoading = m_pGlassData->GetLoadingTime();
 
 	CString measure_data;
@@ -249,11 +249,11 @@
 
 	CString measure_file_path;
 	if (m_pHardware->m_bSaveResultByHour) {
-		// 按小时保存结果
+		// 鎸夊皬鏃朵繚瀛樼粨鏋�
 		measure_file_path.Format(_T("%s\\%s_%02d_MeasureData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, tGlassLoading.GetHour());
 	}
 	else {
-		// 不按小时保存结果
+		// 涓嶆寜灏忔椂淇濆瓨缁撴灉
 		measure_file_path.Format(_T("%s\\%s_MeasureData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay);
 	}
 
@@ -293,9 +293,9 @@
 			CString strDefectType = g_strDefectType[pDefect->m_DefectInfo.m_DefectLoc];
 			if ((strDefectType.Compare(_T("Chip")) == 0 || strDefectType.Compare(_T("In_Chip")) == 0))
 			{
-				// 获取当前时间
+				// 鑾峰彇褰撳墠鏃堕棿
 				std::time_t now = std::time(nullptr);
-				// 使用localtime_s代替localtime
+				// 浣跨敤localtime_s浠f浛localtime
 				std::tm nowTm;
 				localtime_s(&nowTm, &now);
 
@@ -379,9 +379,9 @@
 
 			if ((strDefectType.Compare(_T("Chip")) == 0 || strDefectType.Compare(_T("In_Chip")) == 0))
 			{
-				// 获取当前时间
+				// 鑾峰彇褰撳墠鏃堕棿
 				std::time_t now = std::time(nullptr);
-				// 使用localtime_s代替localtime
+				// 浣跨敤localtime_s浠f浛localtime
 				std::tm nowTm;
 				localtime_s(&nowTm, &now);
 
@@ -412,11 +412,11 @@
 
 	CString Chip_file_path;
 	if (m_pHardware->m_bSaveResultByHour) {
-		// 按小时保存结果
+		// 鎸夊皬鏃朵繚瀛樼粨鏋�
 		Chip_file_path.Format(_T("%s\\%s_%02d_ChipData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, tGlassLoading.GetHour());
 	}
 	else {
-		// 不按小时保存结果
+		// 涓嶆寜灏忔椂淇濆瓨缁撴灉
 		Chip_file_path.Format(_T("%s\\%s_ChipData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay);
 	}
 	
@@ -441,11 +441,11 @@
 
 	CString Defect_file_path;
 	if (m_pHardware->m_bSaveResultByHour) {
-		// 按小时保存结果
+		// 鎸夊皬鏃朵繚瀛樼粨鏋�
 		Defect_file_path.Format(_T("%s\\%s_%02d_DefectData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay, tGlassLoading.GetHour());
 	}
 	else {
-		// 不按小时保存结果
+		// 涓嶆寜灏忔椂淇濆瓨缁撴灉
 		Defect_file_path.Format(_T("%s\\%s_DefectData.csv"), m_strResultFolder, g_pBase->m_strLoadingDay);
 	}
 
@@ -630,7 +630,7 @@
 	BOOL bSuccess = TRUE;
 
 	Lock();
-	// 标题文本
+	// 鏍囬鏂囨湰
 	CString strTitle;
 	int nSideIdx = (0 <= pDefect->m_DefectInfo.m_nSideIdx && pDefect->m_DefectInfo.m_nSideIdx < MAX_SIDE_COUNT) ? pDefect->m_DefectInfo.m_nSideIdx : MAX_SIDE_COUNT;
 	int nCategoryIdx = (0 <= pDefect->m_DefectInfo.m_DefectLoc && pDefect->m_DefectInfo.m_DefectLoc < DefectLoc_None) ? pDefect->m_DefectInfo.m_DefectLoc : DefectLoc_Unknown;
@@ -656,6 +656,16 @@
 		int fontFace = cv::FONT_HERSHEY_TRIPLEX;
 		double fontScale = 0.7;
 		int thickness = 1;
+		
+			if (m_pHardware->m_bUse_SaveDLDefectImage==TRUE)
+			{
+				if (eCategory== DefectLoc_Chip|| eCategory== DefectLoc_Crack|| eCategory == DefectLoc_Burr|| eCategory == DefectLoc_In_Chip|| eCategory == DefectLoc_In_Burr|| eCategory == DefectLoc_UserDefect)
+				{
+					CT2CA pszConvertedAnsiDLFile(strDLFile);
+					cv::String strDLFile(pszConvertedAnsiDLFile);
+					cv::imwrite(strDLFile, imgTmp);
+				}
+			}
 
 		CT2CA pszConvertedAnsiTitle(strTitle);
 		cv::String strCVTitle(pszConvertedAnsiTitle);
@@ -900,7 +910,7 @@
 	// 3. Corner
 
 	
-	// A 惑何 官蹿
+	// A 鎯戜綍 瀹樿箍
 	vecStrTitle.push_back(_T("CORNER_1_X"));
 	strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_A)->m_nBottomCornerWidth);
 	vecStrResultData.push_back(strTemp);
@@ -908,7 +918,7 @@
 	strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_A)->m_nBottomCornerHeight);
 	vecStrResultData.push_back(strTemp);
 
-	// C 惑何 官蹿
+	// C 鎯戜綍 瀹樿箍
 	vecStrTitle.push_back(_T("CORNER_2_X"));
 	strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_C)->m_nBottomCornerWidth);
 	vecStrResultData.push_back(strTemp);
@@ -916,7 +926,7 @@
 	strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_C)->m_nBottomCornerHeight);
 	vecStrResultData.push_back(strTemp);
 
-	// C 惑何 啪
+	// C 鎯戜綍 鍟�
 	vecStrTitle.push_back(_T("CORNER_3_X"));
 	strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_C)->m_nTopCornerWidth);
 	vecStrResultData.push_back(strTemp);
@@ -924,7 +934,7 @@
 	strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_C)->m_nTopCornerHeight);
 	vecStrResultData.push_back(strTemp);
 
-	// A 惑何 啪
+	// A 鎯戜綍 鍟�
 	vecStrTitle.push_back(_T("CORNER_4_X"));
 	strTemp.Format(_T("%d"), m_pGlassData->GetSideData(DIMENSION_A)->m_nTopCornerWidth);
 	vecStrResultData.push_back(strTemp);
@@ -983,7 +993,7 @@
 	CSide_Data* pSideData_UP = NULL;
 	CSide_Data* pSideData_DN = NULL;
 
-	// Notch乐绰 搁 茫扁
+	// Notch涔愮话 鎼� 鑼墎
 	for(int nSideIdx=0; nSideIdx<MAX_PANEL_SIDE; nSideIdx++)
 	{
 		pSideData_UP = m_pGlassData->GetSideData(arryWriteOrder_UP[nSideIdx]);
@@ -995,7 +1005,7 @@
 
 	for(int nNotchIdx=0; nNotchIdx<MAX_SIDE_NOTCH_COUNT; nNotchIdx++)
 	{
-		// 4-2. Dimension, 酒阀搁栏肺 螟沥
+		// 4-2. Dimension, 閰掗榾鎼佹爮鑲� 铻熸播
 		for(int nMeasureIdx = 0; nMeasureIdx < MAX_SIDE_NOTCH_MEASURE_COUNT; nMeasureIdx++)
 		{
 			strTemp.Format(_T("NOTCH_%d_DIM_%d"), nNotchIdx+1, nMeasureIdx+1);
@@ -1032,7 +1042,7 @@
 	// Save Path
 	CString strFilePath;
 	if (m_pHardware->m_bSaveResultByHour) {
-		// 按小时保存,绑定玻璃 Loading Time
+		// 鎸夊皬鏃朵繚瀛橈紝缁戝畾鐜荤拑 Loading Time
 		strFilePath.Format(_T("D:\\Data\\%s\\%s\\%d\\%02d\\%02d\\%s_%s_%02d.csv"),
 			m_pHardware->GetMachineName(),
 			m_pHardware->GetLineID(),
@@ -1044,7 +1054,7 @@
 			tLoadingTime.GetHour());
 	}
 	else {
-		// 按天保存,绑定玻璃 Loading Time
+		// 鎸夊ぉ淇濆瓨锛岀粦瀹氱幓鐠� Loading Time
 		strFilePath.Format(_T("D:\\Data\\%s\\%s\\%d\\%02d\\%02d\\%s_%s.csv"),
 			m_pHardware->GetMachineName(),
 			m_pHardware->GetLineID(),
@@ -1211,6 +1221,8 @@
 		bJudgeUse		= (pSideParam->m_UserDefectPrm[pDefect->m_nUserDefectAreaIdx].m_nJudge_Size_Min_OR_AND == 0) ? FALSE : TRUE;
 		break;
 	case DefectLoc_Notch_Crack:
+	case DefectLoc_Notch_Broken:
+	case DefectLoc_Notch_NoGrind:
 		nJudgeW_um = pSideParam->m_NotchPrm[pDefect->m_nNotchIdx].m_nNotch_Inspect_Defect_Judge_X_um;
 		nJudgeH_um = pSideParam->m_NotchPrm[pDefect->m_nNotchIdx].m_nNotch_Inspect_Defect_Judge_Y_um;
 		bAnd = (pSideParam->m_NotchPrm[pDefect->m_nNotchIdx].m_nNotch_Inspect_Defect_Judge_And == 2) ? TRUE : FALSE;
@@ -1460,16 +1472,19 @@
 		}
 
 		CString strSaveImagePath;
+		CString strSaveImageDLPath;
 		//strSaveImagePath.Format(_T("%s\\%03d_%s_%s_%s.jpg"),m_strDefectFolder,pNewDefect->m_nIdx, g_pBase->m_strHPanelID, PANEL_SIDE[pNewDefect->m_DefectInfo.m_nSideIdx], strDefectType);
 		strSaveImagePath.Format(_T("%s\\%s_%s_%s_%d.jpg"),m_strDefectFolder, g_pBase->m_strHPanelID, PANEL_SIDE[pDefect->m_DefectInfo.m_nSideIdx], strDefectType, pDefect->m_nIdx);
-
-		CRect rectDefect;
+		strSaveImageDLPath.Format(_T("%s\\%s_%s_%s_%d.bmp"),m_strImageDLFolder, g_pBase->m_strHPanelID, PANEL_SIDE[pDefect->m_DefectInfo.m_nSideIdx], strDefectType, pDefect->m_nIdx);
+		CRect rectDefect; 
 		rectDefect.left		= DEFECTIMAGE_WIDTH/2	- pDefect->m_DefectInfo.m_rtDefectPos_pxl.Width()/2;
 		rectDefect.right	= DEFECTIMAGE_WIDTH/2	+ pDefect->m_DefectInfo.m_rtDefectPos_pxl.Width()/2;
 		rectDefect.top		= DEFECTIMAGE_HEIGHT/2	- pDefect->m_DefectInfo.m_rtDefectPos_pxl.Height()/2;
 		rectDefect.bottom	= DEFECTIMAGE_HEIGHT/2	+ pDefect->m_DefectInfo.m_rtDefectPos_pxl.Height()/2;
 
 		CheckDirectory(strSaveImagePath);
+		CheckDirectory(strSaveImageDLPath);
+		strDLFile.Format(_T("%s"), strSaveImageDLPath);
 		// SaveDefectImage2(pNewDefect->m_Image,CSize(DEFECTIMAGE_WIDTH,DEFECTIMAGE_HEIGHT), rectDefect, strSaveImagePath);
 		SaveDefectImage_with_Title(pDefect, CSize(DEFECTIMAGE_WIDTH,DEFECTIMAGE_HEIGHT), rectDefect, strSaveImagePath);
 
@@ -1774,7 +1789,7 @@
 	
 	/*
 	pDefect->m_nUMOriginX = (int)((double) (pDefect->m_DefectInfo.m_ptDefectPos_pxl.y - nStartLine) * dScanRes);
-	pDefect->m_nUMOriginY = (int)((double) (pDefect->m_DefectInfo.m_ptDefectPos_pxl.x * dConvRes));		// 荐沥 鞘夸..
+	pDefect->m_nUMOriginY = (int)((double) (pDefect->m_DefectInfo.m_ptDefectPos_pxl.x * dConvRes));		// 鑽愭播 闉樺じ..
 	*/
 
 	CSIDE_PARM* pSideParam = &pRecipe->m_SideParam[pDefect->m_DefectInfo.m_nSideIdx];
@@ -2001,6 +2016,9 @@
 	m_strDefectFolder.Format(_T("%s\\IMG_DEFECT\\%s\\%s"),PATH_INSPECTION_DATA,g_pBase->m_strLoadingDay,g_pBase->m_strHPanelID);
 	DeleteFolder(m_strDefectFolder);
 	CheckDirectory(m_strDefectFolder,TRUE);
+	m_strImageDLFolder.Format(_T("%s\\IMG_DEFECT_DL\\%s\\%s"), PATH_INSPECTION_DATA, g_pBase->m_strLoadingDay, g_pBase->m_strHPanelID);
+	DeleteFolder(m_strImageDLFolder);
+	CheckDirectory(m_strImageDLFolder, TRUE);
 	m_strSplineFolder.Format(_T("%s\\SPLINE\\%s\\%s"),PATH_INSPECTION_DATA,g_pBase->m_strLoadingDay,g_pBase->m_strHPanelID);
 	CheckDirectory(m_strSplineFolder);
 	m_strFullImgeFolder.Format(_T("%s\\IMG_FULL\\%s\\%s"),PATH_INSPECTION_DATA,g_pBase->m_strLoadingDay,g_pBase->m_strHPanelID);
@@ -2017,13 +2035,13 @@
 	TCHAR szTemp[MAX_PATH];
 
 	wcscpy_s(szTemp, MAX_PATH, strFolder);
-	szTemp[strFolder.GetLength() + 1] = NULL; // NULL巩磊啊 滴俺 甸绢啊具 茄促.
+	szTemp[strFolder.GetLength() + 1] = NULL; // NULL宸╃鍟� 婊翠亢 鐢哥虎鍟婂叿 鑼勪績.
 
 	FileOp.hwnd = NULL;
 	FileOp.wFunc = FO_DELETE;
 	FileOp.pFrom = NULL;
 	FileOp.pTo = NULL;
-	FileOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI; // 犬牢皋矫瘤啊 救哆档废 汲沥
+	FileOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI; // 鐘墷鐨嬬煫鐦ゅ晩 鏁戝搯妗e簾 姹叉播
 	FileOp.fAnyOperationsAborted = false;
 	FileOp.hNameMappings = NULL;
 	FileOp.lpszProgressTitle = NULL;

--
Gitblit v1.9.3