From aef42eef51d1b86ac7217a88ce17c5156c30fe6d Mon Sep 17 00:00:00 2001
From: LWQ <1806950222@qq.com>
Date: 星期一, 14 七月 2025 11:42:53 +0800
Subject: [PATCH] Merge branch 'master' into LWQ
---
EdgeInspector_App/Process/InspectCamera.cpp | 40 +++++++++++++++++++++++++++++++---------
1 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/EdgeInspector_App/Process/InspectCamera.cpp b/EdgeInspector_App/Process/InspectCamera.cpp
index 67c6767..909e2f7 100644
--- a/EdgeInspector_App/Process/InspectCamera.cpp
+++ b/EdgeInspector_App/Process/InspectCamera.cpp
@@ -4214,11 +4214,14 @@
double dChamfer_Diff_um = dChamfer_std_um - dChamfer_um;
pSideData->m_nNotch_Chamfer_Edge_Judge[nNotchIdx][nMeasureIdx] = 1;
+
+#if MINI_LED
//选取测量研磨尺寸最大值
- if (m_nChamferOffset_um < dChamfer_um)
- {
+ if (m_nChamferOffset_um < dChamfer_um) {
m_nChamferOffset_um = dChamfer_um;
}
+#endif
+
pSideData->m_dNotch_Chamfer_Edge_Result_Diff_um[nNotchIdx][nMeasureIdx] = dChamfer_std_um - dChamfer_um;
pSideData->m_dNotch_Chamfer_Edge_Judge_Std_um[nNotchIdx][nMeasureIdx] = dChamfer_std_um;
pSideData->m_dNotch_Chamfer_Edge_Judge_Min_um[nNotchIdx][nMeasureIdx] = dChamfer_min_um;
@@ -4331,9 +4334,13 @@
nOffset = m_nChamferOffset_um / m_pGlassData->GetSideData(emDim)->m_dPixelSizeX;
nOffset += pNotchParam->m_nNotch_Inspect_Defect_Offset;
m_nChamferOffset_um = 0;
-#else
- nOffset = pNotchParam->m_nNotch_Inspect_Defect_Offset;
#endif // MINI_LED
+
+ // 防止过大导致耗时或内存问题
+ if (nOffset > 50) {
+ g_pLog->DisplayMessage(_T("[WARN] Notch defect offset capped to 50 pixels, original: %d"), nOffset);
+ nOffset = 50;
+ }
CRect rcIns = rtROI;
rcIns.OffsetRect(-rcIns.left,-rcIns.top);
@@ -4389,8 +4396,9 @@
strTemp.Format(_T("Notch\\Notch_%d_Defect_MaskPreImage"), nNotchIdx);
SaveDebugImage(emDim, stFrame, pMaskImage, strTemp);
- if(0 < nOffset)
+ if (0 < nOffset) {
cvDilate(pMaskImage, pMaskImage, 0, nOffset);
+ }
strTemp.Format(_T("Notch\\Notch_%d_Defect_MaskDilateImage"), nNotchIdx);
SaveDebugImage(emDim, stFrame, pMaskImage, strTemp);
@@ -4408,13 +4416,26 @@
strTemp.Format(_T("Notch\\Notch_%d_Defect_ProcBinImage"), nNotchIdx);
SaveDebugImage(emDim, stFrame, pProcBinImage, strTemp);
-#if MINI_LED == 0
- cvDilate(pMaskImage, pDilatedMaskImage, 0, pNotchParam->m_nNotch_Inspect_Defect_dilate);
- strTemp.Format(_T("Notch\\Notch_%d_Defect_pMaskImage2"), nNotchIdx);
+#if MINI_LED == 0
+ // 限制膨胀次数,防止过大导致耗时或内存问题
+ int nDilateCount = pNotchParam->m_nNotch_Inspect_Defect_dilate;
+ nDilateCount = std::max(0, std::min(nDilateCount, 50));
+ if (pNotchParam->m_nNotch_Inspect_Defect_dilate != nDilateCount) {
+ g_pLog->DisplayMessage(_T("[WARN] Dilate count capped: Original=%d, Applied=%d"), pNotchParam->m_nNotch_Inspect_Defect_dilate, nDilateCount);
+ }
+
+ if (nDilateCount > 0) {
+ cvDilate(pMaskImage, pDilatedMaskImage, 0, nDilateCount);
+ }
+ else {
+ cvCopy(pMaskImage, pDilatedMaskImage);
+ }
+
+ strTemp.Format(_T("Notch\\Notch_%d_Defect_Mask_Dilated"), nNotchIdx);
SaveDebugImage(emDim, stFrame, pDilatedMaskImage, strTemp);
cvAnd(pDilatedMaskImage, pProcBinImage, pDilatedMaskImage);
- strTemp.Format(_T("Notch\\Notch_%d_Defect_pMaskImage3"), nNotchIdx);
+ strTemp.Format(_T("Notch\\Notch_%d_Defect_Mask_And_Bin"), nNotchIdx);
SaveDebugImage(emDim, stFrame, pDilatedMaskImage, strTemp);
#endif
@@ -4441,6 +4462,7 @@
m_pDefectControl->ExtractDefect_Notch(emDim, m_iCamera, stFrame.nScanIdx, nNotchIdx, &vecDefectCandidateList);
+ cvReleaseImage(&pDilatedMaskImage);
cvReleaseImage(&pMaskImage);
cvReleaseImage(&pProcImage);
cvReleaseImage(&pProcBinImage);
--
Gitblit v1.9.3