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 | 30 +++++++++++++++++++++++++-----
1 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/EdgeInspector_App/Process/InspectCamera.cpp b/EdgeInspector_App/Process/InspectCamera.cpp
index a091371..909e2f7 100644
--- a/EdgeInspector_App/Process/InspectCamera.cpp
+++ b/EdgeInspector_App/Process/InspectCamera.cpp
@@ -4336,6 +4336,12 @@
m_nChamferOffset_um = 0;
#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);
IplImage* pProcImage = cvCreateImage(cvSize(rcIns.Width(), rcIns.Height()), 8, 1);
@@ -4390,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);
@@ -4409,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
--
Gitblit v1.9.3