| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | 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 |
| | | |