| | |
| | | CCameraImageData* pCameraImage = m_vecCameraImage[nCameraIdx]; |
| | | CAlignFinder* pAlignFinder = m_vecAlignFinder[nCameraIdx]; |
| | | |
| | | if (pCameraImage==NULL || pAlignFinder==NULL) return FALSE; |
| | | /*< LYW 20211014 - #index MOD Start >*/ |
| | | if (pCameraImage == NULL || pAlignFinder == NULL || m_pACC2P == NULL) return FALSE; |
| | | /*< LYW 20211014 - #index MOD End >*/ |
| | | /*< Origin Code >*/ |
| | | //if (pCameraImage == NULL || pAlignFinder == NULL) return FALSE; |
| | | |
| | | // set find param; |
| | | SAlignFindParam findParam; |
| | |
| | | findParam.nEdgeThreshold = m_AlignRecipe.nEdgeThreshold; |
| | | findParam.nMergeRange = m_AlignRecipe.nMergeRange; |
| | | findParam.dEdgeRate = m_AlignRecipe.dEdgeRate; |
| | | findParam.dMatchingPixelStandard = _tcstod(m_AlignRecipe.strMatchingPixelStandard,NULL); |
| | | findParam.dMatchingAlarmCondition = _tcstod(m_AlignRecipe.strMatchingAlarmCondition, NULL); |
| | | // findParam.m_nAlignMarkPos = m_AlignRecipe.nAlignMarkPosition; |
| | | |
| | | |
| | |
| | | // CString strFilename = ALIGN_IMAGE_PATH; |
| | | // if (nCameraIdx == 0) |
| | | // { |
| | | // strFilename += _T("\\Test3.BMP"); |
| | | // strFilename += _T("\\Test1.BMP"); |
| | | // } |
| | | // else |
| | | // { |
| | | // strFilename += _T("\\Test4.BMP"); |
| | | // strFilename += _T("\\Test2.BMP"); |
| | | // } |
| | | // TestImage.LoadImage(strFilename); |
| | | // TestImage.GetBandImage(BandTypeGray, m_vecCameraImage[nCameraIdx]->GetImageData(View_Camera)); |
| | |
| | | |
| | | |
| | | //SAlignFindResult findResult = pAlignFinder->FindAlign(pCameraImage->GetImageData(View_Matching), findParam, pCameraImage->GetImageData(View_Template)); |
| | | //Main Align Matching |
| | | SAlignFindResult findResult = pAlignFinder->FindAlign(&camImage, findParam, pCameraImage->GetImageData(View_Template)); |
| | | g_pLog->DisplayMessage(_T("Main TempleteMatching Result : %d Cam ResultCode = %d, PixelX = %d, PixelY = %d, MatchingRate = %.3lf"), nCameraIdx, findResult.nResultCode, int(findResult.dPosX + 0.5), int(findResult.dPosY + 0.5), findResult.dMatchValue); |
| | | |
| | | // result process |
| | | //Main Align Matching result process |
| | | if (findResult.nResultCode==AlignMatch_Success) |
| | | { |
| | | g_pLog->DisplayMessage(_T("Main TempleteMatching Success!")); |
| | | /*< LYW 20211015 - #3671 ADD Start >*/ |
| | | m_pACC2P->IACC2P_SetAccumaulate(0); |
| | | /*< LYW 20211015 - #3671 ADD End >*/ |
| | | g_pLog->DisplayMessage(_T("Main TempleteMatching Success! Accumaulate = %d"), m_pACC2P->IACC2P_GetAccumaulate()); |
| | | m_AlignResult.nFindAlign[nCameraIdx] = 1; |
| | | m_AlignResult.dFindPixelX[nCameraIdx] = int(findResult.dPosX + 0.5); |
| | | m_AlignResult.dFindPixelY[nCameraIdx] = int(findResult.dPosY + 0.5); |
| | |
| | | |
| | | else |
| | | { |
| | | //Assistant Align Matching |
| | | SAlignFindResult findAssistantResult = pAlignFinder->FindAlign(&camImage, findParam, pCameraImage->GetImageData(View_AssistantTemplate)); |
| | | g_pLog->DisplayMessage(_T("Assistant TempleteMatching Result : %d Cam ResultCode = %d, PixelX = %d, PixelY = %d, MatchingRate = %.3lf"), nCameraIdx, findAssistantResult.nResultCode, int(findAssistantResult.dPosX + 0.5), int(findAssistantResult.dPosY + 0.5), findAssistantResult.dMatchValue); |
| | | //Assistant Align Matching result process |
| | | if (findAssistantResult.nResultCode == AlignMatch_Success) |
| | | { |
| | | g_pLog->DisplayMessage(_T("Assistant TempleteMatching Success!")); |
| | | /*< LYW 20211015 - #3671 ADD Start >*/ |
| | | m_pACC2P->IACC2P_SetAccumaulate(0); |
| | | /*< LYW 20211015 - #3671 ADD End >*/ |
| | | g_pLog->DisplayMessage(_T("Assistant TempleteMatching Success! Accumaulate = %d"),m_pACC2P->IACC2P_GetAccumaulate()); |
| | | m_AlignResult.nFindAlign[nCameraIdx] = 1; |
| | | m_AlignResult.dFindPixelX[nCameraIdx] = int(findAssistantResult.dPosX + 0.5); |
| | | m_AlignResult.dFindPixelY[nCameraIdx] = int(findAssistantResult.dPosY + 0.5); |
| | |
| | | |
| | | else |
| | | { |
| | | //Main, Assistant Find Pos Compare |
| | | int dffmain2assistanstX = int(findResult.dPosX) - int(findAssistantResult.dPosX); |
| | | int dffmain2assistanstY = int(findResult.dPosY) - int(findAssistantResult.dPosY); |
| | | g_pLog->DisplayMessage(_T("Main, Assistant TempleteMatching All Low Score! differenceX = %d, differenceY = %d"), dffmain2assistanstX, dffmain2assistanstY); |
| | | |
| | | if (abs(dffmain2assistanstX) <= 10 && abs(dffmain2assistanstY) <= 10 && findResult.dMatchValue != 0.0) |
| | | if (abs(dffmain2assistanstX) <= findParam.dMatchingPixelStandard && abs(dffmain2assistanstY) <= findParam.dMatchingPixelStandard && findResult.dMatchValue != 0.0 && findAssistantResult.dMatchValue != 0.0) |
| | | { |
| | | g_pLog->DisplayMessage(_T("Main Assistant Templete Find Same Point! Align Success!")); |
| | | //Main, Assistant Find Pos Compare Result Success Process |
| | | m_AlignResult.nFindAlign[nCameraIdx] = 1; |
| | | m_AlignResult.dFindPixelX[nCameraIdx] = int(findResult.dPosX + 0.5); |
| | | m_AlignResult.dFindPixelY[nCameraIdx] = int(findResult.dPosY + 0.5); |
| | | /*< LYW 20211015 - #3671 MOD Start >*/ |
| | | m_AlignResult.dFindPixelX[nCameraIdx] = int((findResult.dPosX + findAssistantResult.dPosX) / 2 + 0.5); |
| | | m_AlignResult.dFindPixelY[nCameraIdx] = int((findResult.dPosY + findAssistantResult.dPosY) / 2 + 0.5); |
| | | /*< LYW 20211015 - #3671 MOD End >*/ |
| | | /*< Origin Code >*/ |
| | | //m_AlignResult.dFindPixelX[nCameraIdx] = int(findResult.dPosX + 0.5); |
| | | //m_AlignResult.dFindPixelY[nCameraIdx] = int(findResult.dPosY + 0.5); |
| | | m_AlignResult.dFindScore[nCameraIdx] = findResult.dMatchValue; |
| | | m_pACC2P->IACC2P_SetAccumaulate(m_pACC2P->IACC2P_GetAccumaulate() + 1); |
| | | g_pLog->DisplayMessage(_T("Main, Assistant Templete Find Same Point! Align Success! Accumaulate = %d"), m_pACC2P->IACC2P_GetAccumaulate()); |
| | | } |
| | | |
| | | else |
| | | { |
| | | //Main, Assistant Find Pos Compare Result Fail Process |
| | | g_pLog->DisplayMessage(_T("Main Assistant Templete Don`t Find Same Point! Align Fail!")); |
| | | m_AlignResult.nFindAlign[nCameraIdx] = 0; |
| | | m_AlignResult.dFindScore[nCameraIdx] = findResult.dMatchValue; |
| | | } |
| | | |
| | | if (m_pACC2P->IACC2P_GetAccumaulate() >= findParam.dMatchingAlarmCondition) |
| | | { |
| | | //Main, Assistant Find Pos Alarm Process |
| | | m_AlignResult.nFindAlign[nCameraIdx] = 0; |
| | | m_AlignResult.dFindScore[nCameraIdx] = findResult.dMatchValue; |
| | | m_pACC2P->IACC2P_SetAccumaulate(0); |
| | | g_pLog->DisplayMessage(_T("Low Matching, But Align Same Point, Count is more Than MatchingAlarmCondition , Accumaulate = %d Reset"), m_pACC2P->IACC2P_GetAccumaulate()); |
| | | } |
| | | } |
| | | } |
| | | /*< LYW 20211013 - #3671 ADD End >*/ |