#include "stdafx.h"
|
#include "SoftVisionApp.h"
|
#include "VisionSetDlg.h"
|
#include "VisionRecipe.h"
|
#include "BlSideData.h"
|
#include "VisionBufferPro.h"
|
#include "KeyVisionSetDlg.h"
|
#include "TranformCoordinate.h"
|
#include "CornerRcutProcess.h"
|
#include "FileRecipe.h"
|
#include "resource.h"
|
#include "BlVisionPro.h"
|
#include "ThresProcess.h"
|
|
CSoftVisionApp::CSoftVisionApp(){
|
/* code */
|
m_pEvent = nullptr;
|
InitializeCriticalSection(&m_criticalSection);
|
}
|
|
CSoftVisionApp::~CSoftVisionApp(){
|
/* code */
|
DeleteCriticalSection(&m_criticalSection);
|
}
|
|
static CSoftVisionApp _gSoftVisionApp;
|
CSoftVisionApp* CSoftVisionApp::getInstance(void) {
|
/* code */
|
return &_gSoftVisionApp;
|
}
|
|
int CSoftVisionApp::OpenVisionWindow(void) {
|
/* code */
|
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
CVisionSetDlg dlg;
|
dlg.DoModal();
|
int nRet = (int)(::GetLastError());
|
return nRet;
|
}
|
|
CDialogEx* CSoftVisionApp::CreateVisionWindow(void) {
|
/* code */
|
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
CVisionSetDlg *pDlg = new CVisionSetDlg();
|
pDlg->Create(IDD_DIALOG_VISION_SET, NULL);
|
|
return (CDialogEx*)(pDlg);
|
}
|
|
int CSoftVisionApp::ReleaseWindow(CDialogEx *pDlg) {
|
/* code */
|
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
|
CVisionSetDlg *pVisionSetDlg = (CVisionSetDlg *)(pDlg);
|
if (NULL == pVisionSetDlg) {
|
pVisionSetDlg->DestroyWindow();
|
delete pVisionSetDlg;
|
pVisionSetDlg = nullptr;
|
}
|
return 0;
|
}
|
|
void CSoftVisionApp::ChangeDimension(CDialogEx *pDlg, int nDir) {
|
/* code */
|
if (!CVisionRecipe::getInstance()->getVisionSetOpen()) return;
|
|
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
|
CVisionSetDlg *pVisionSetDlg = (CVisionSetDlg *)(pDlg);
|
if (NULL == pVisionSetDlg) return;
|
if (!CVisionRecipe::getInstance()->getVisionSetOpen()) return;
|
|
DimensionDir eDir = (DimensionDir)(nDir);
|
pVisionSetDlg->ChangeDimension(eDir);
|
}
|
|
void CSoftVisionApp::SetVisionOpen(BOOL isOpen) {
|
/* code */
|
CVisionRecipe::getInstance()->setVisionSetOpen(isOpen);
|
}
|
|
void CSoftVisionApp::OpenKeySetWindow(void) {
|
/* code */
|
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
CKeyVisionSetDlg dlg;
|
dlg.DoModal();
|
}
|
|
Point2I CSoftVisionApp::getPose(int eDir, int xPoxPxl, int yPosPxl) {
|
/* code */
|
CTranformCoordinate tranform;
|
Point2I pose;
|
pose.x = xPoxPxl;
|
pose.y = yPosPxl;
|
|
return tranform.Execute((DimensionDir)eDir, pose);
|
}
|
|
int CSoftVisionApp::Execute(int eDir, NgInfo *ngArray) {
|
/* code */
|
DimensionDir nDir = (DimensionDir)(eDir);
|
KeyDebugInfo info = CVisionRecipe::getInstance()->getKeyInfo();
|
int nRet = 0;
|
|
//1. ÊÓ¾õ¶¨Î»
|
if (0 != ExecuteLoc(nDir)) {
|
return nRet;
|
}
|
|
//2. GrindSize
|
if (0 == ExecuteGrind(nDir)) {
|
nRet = getGrindResult(nDir ,ngArray);
|
}
|
|
|
//3. Dist
|
if (0 == ExecuteDist(nDir)) { //»ñÈ¡Êý¾ÝȱÏݵÄÊý¾Ý
|
NgInfo ngRCUT[NG_INF_NUM];
|
int nCount = getDistResult(nDir, ngRCUT);
|
if (nCount > 0) {
|
int nTotal = nRet;
|
nRet = addResultToTotal(ngRCUT, nCount, ngArray, nTotal);
|
}
|
}
|
|
//4. CutLine
|
if (0 == ExecuteCut(nDir)) {
|
NgInfo ngRCUT[NG_INF_NUM];
|
int nCount = getCutResult(nDir, ngRCUT);
|
if (nCount > 0) {
|
int nTotal = nRet;
|
nRet = addResultToTotal(ngRCUT, nCount, ngArray, nTotal);
|
}
|
}
|
|
//5. Rcut
|
if (0 == ExecuteRCUT(nDir)){
|
NgInfo ngRCUT[NG_INF_NUM];
|
int nCount = getRcutResult(nDir, ngRCUT);
|
if (nCount > 0) {
|
int nTotal = nRet;
|
nRet = addResultToTotal(ngRCUT, nCount, ngArray, nTotal);
|
}
|
}
|
|
//6. Thres
|
if (0 == ExecuteThres(nDir)) {
|
NgInfo ngRCUT[NG_INF_NUM];
|
int nCount = getThresResult(nDir, ngRCUT);
|
if (nCount > 0) {
|
int nTotal = nRet;
|
nRet = addResultToTotal(ngRCUT, nCount, ngArray, nTotal);
|
}
|
}
|
|
//7. Hole
|
if (0 == ExecuteHole(nDir)) {
|
NgInfo ngRCUT[NG_INF_NUM];
|
int nCount = getHoleResult(nDir, ngRCUT);
|
if (nCount > 0) {
|
int nTotal = nRet;
|
nRet = addResultToTotal(ngRCUT, nCount, ngArray, nTotal);
|
}
|
}
|
|
return nRet;
|
}
|
|
//5. ÉèÖûص÷ʱ¼ä
|
void CSoftVisionApp::setImageEventSignal(IVisionEvent *pEvent) {
|
/* code */
|
m_pEvent = pEvent;
|
}
|
|
Point2I CSoftVisionApp::getPointCoor(DimensionDir dir, Point2I point, Point2I ptTop, Point2I ptBot, int nType) {
|
/* code */
|
CBlSideData *pSideData = CVisionRecipe::getInstance()->getSideData(dir);
|
double xMmvsp = pSideData->m_dPixelSizeX;
|
double yMmvsp = pSideData->m_dPixelSizeY;
|
Point2D posTop, posBot, pose;
|
posTop.x = 0.0f;
|
posTop.y = 0.0f;
|
posBot.x = xMmvsp * (ptBot.x - ptTop.x);
|
posBot.y = yMmvsp * (ptBot.y - ptTop.y);
|
pose.x = xMmvsp * (point.x - ptTop.x);
|
pose.y = yMmvsp * (point.y - ptTop.y);
|
|
double dx = xMmvsp * (ptBot.x - ptTop.x);
|
double dy = yMmvsp * (ptBot.y - ptTop.y);
|
double dist = sqrt(dx * dx + dy * dy);
|
std::vector<Point2D> vPtOrigine, vPtReal;
|
vPtOrigine.push_back(posTop);
|
vPtOrigine.push_back(posBot);
|
|
Point2D pt;
|
pt.x = 0.0f;
|
pt.y = 0.0f;
|
vPtReal.push_back(pt);
|
pt.x = 0.0f;
|
pt.y = dist;
|
vPtReal.push_back(pt);
|
|
ParaAffine2D affine = ClsVision::VectorToSimilarity(vPtOrigine, vPtReal);
|
Point2D ptResult = ClsVision::CoordinateTransform(pose, affine);
|
Point2I result;
|
if (0 == nType) {
|
result.x = (int)(ptResult.x);
|
result.y = (int)(ptResult.y);
|
}
|
else {
|
result.x = (int)(ptResult.x - vPtReal[1].x);
|
result.y = (int)(ptResult.y - vPtReal[1].y);
|
}
|
return result;
|
}
|
|
bool CSoftVisionApp::transformToStandard(int eDir, Point2I point, Point2I &result, Point2I &topResult, Point2I &botResult) {
|
/* code */
|
topResult.x = 0;
|
topResult.y = 0;
|
botResult.x = 0;
|
botResult.y = 0;
|
result.x = 0;
|
result.y = 0;
|
DimensionDir nDir = (DimensionDir)(eDir);
|
CBlSideData *pSideData = CVisionRecipe::getInstance()->getSideData(nDir);
|
if (NULL == pSideData) return false;
|
|
//1. Ê×ÏȼÆËãmark line
|
if (pSideData->m_bTopMark_Find && pSideData->m_bBotMark_Find){ //¼ÆËã
|
Point2I ptTop = pSideData->getPose(0);
|
Point2I ptBot = pSideData->getPose(1);
|
result = getPointCoor(nDir, point, ptTop, ptBot, 0);
|
}
|
|
//2. ¼ÆËã Top Point
|
if (pSideData->m_bTopPoint_Find && pSideData->m_bBotPoint_Find) { //¼ÆËã
|
Point2I ptTop = pSideData->getPose(2);
|
Point2I ptBot = pSideData->getPose(3);
|
topResult = getPointCoor(nDir, point, ptTop, ptBot, 0);
|
}
|
|
//3. ¼ÆËãBot Point
|
if (pSideData->m_bTopPoint_Find && pSideData->m_bBotPoint_Find) { //¼ÆËã
|
Point2I ptTop = pSideData->getPose(2);
|
Point2I ptBot = pSideData->getPose(3);
|
botResult = getPointCoor(nDir, point, ptTop, ptBot, 1);
|
}
|
|
return true;
|
}
|
|
bool CSoftVisionApp::findCutLine(int eDir, int toTopY, int toLineDist, int nEndThres, Point2I& result) {
|
/* code */
|
if (toLineDist > 0) return false;
|
if (nEndThres < 1) return false;
|
DimensionDir eDirReal = (DimensionDir)eDir;
|
CBlSideData* pSideData = CVisionRecipe::getInstance()->getSideData(eDirReal);
|
if (nullptr == pSideData) return false;
|
if (!pSideData->m_bTopMark_Find) return false;
|
if (!pSideData->m_bBotMark_Find) return false;
|
|
Point2I ptOffset;
|
ptOffset.x = -1 * toLineDist;
|
ptOffset.y = toTopY;
|
Point2I leftPoint;
|
if (!CVisionBufferPro::TransformToReal(eDirReal, ptOffset, 0, leftPoint)) return false;
|
|
double fzSearchRange = 500.0f;
|
int nSearchRange = (int)(fzSearchRange / pSideData->m_dPixelSizeX);
|
Point2I cutResult;
|
if (!CVisionBufferPro::findCutLine(eDirReal, leftPoint, nSearchRange, nEndThres, cutResult)) return false;
|
|
result = cutResult;
|
|
return true;
|
}
|
|
double CSoftVisionApp::DistancePL(Point2D pose, Line2D line) {
|
/* code */
|
return ClsVision::DistancePL(pose, line);
|
}
|
|
int CSoftVisionApp::findNorchDefect(int eDir, std::vector<Point2D> vPoints, CRect roiRect, int nThres, int nOffset, int nBinThres,
|
int szType, int xFzSize, int yFzSize, CRect* aryResult) {
|
/* code */
|
DimensionDir eCurDir = (DimensionDir)eDir;
|
CBlSideData *pSideData = CVisionRecipe::getInstance()->getSideData(eCurDir);
|
if (nullptr == pSideData) return 0;
|
|
int xDefectSize = (int)(1.0f * xFzSize / pSideData->m_dPixelSizeX + 0.5f);
|
int yDefectSize = (int)(1.0f * yFzSize / pSideData->m_dPixelSizeY + 0.5f);
|
|
int nRet = CVisionBufferPro::findNorchDefect(eCurDir, vPoints, roiRect, nThres, nOffset, nBinThres, szType, xDefectSize, yDefectSize, aryResult);
|
return nRet;
|
}
|
|
int CSoftVisionApp::ExecuteLoc(DimensionDir eDir) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return -1;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return -1;
|
if (!inf.isLocUse) return -1;
|
|
CLocProcess *dot = pInstance->getLocProcess(eDir);
|
if (NULL == dot) return -1;
|
dot->execute(eDir);
|
return 0;
|
}
|
|
int CSoftVisionApp::ExecuteGrind(DimensionDir eDir) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return -1;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return -1;
|
if (!inf.isGrindUse) return -1;
|
|
CGrindProcess *dot = pInstance->getGrindProcess(eDir);
|
if (NULL == dot) return -1;
|
|
dot->Execute(eDir);
|
return 0;
|
}
|
|
int CSoftVisionApp::ExecuteDist(DimensionDir eDir) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return -1;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return -1;
|
if (!inf.isDistUse) return -1;
|
|
CKDistProcess *dot = pInstance->getKDistProcess(eDir);
|
if (NULL == dot) return -1;
|
|
dot->Execute(eDir);
|
return 0;
|
}
|
|
int CSoftVisionApp::ExecuteCut(DimensionDir eDir) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return -1;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return -1;
|
if (!inf.isCutUse) return -1;
|
|
CCutProcess *dot = pInstance->getCutProcess(eDir);
|
if (NULL == dot) return -1;
|
|
dot->Execute(eDir);
|
return 0;
|
}
|
|
int CSoftVisionApp::ExecuteRCUT(DimensionDir eDir) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return -1;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return -1;
|
if (!inf.isRcutUse) return -1;
|
|
CCornerRcutProcess *dot = pInstance->getCornerRcutProcess(eDir);
|
dot->execute(eDir);
|
return 0;
|
}
|
|
int CSoftVisionApp::ExecuteThres(DimensionDir eDir) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return -1;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return -1;
|
if (!inf.isThresUse) return -1;
|
|
CThresProcess *dot = pInstance->getThresProcess(eDir);
|
dot->execute(eDir);
|
|
return 0;
|
}
|
|
int CSoftVisionApp::ExecuteHole(DimensionDir eDir) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return -1;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return -1;
|
if (!inf.isHoleUse) return -1;
|
|
CHoleProcess *dot = pInstance->getHoleProcess(eDir);
|
dot->Execute(eDir);
|
|
return 0;
|
}
|
|
int CSoftVisionApp::getGrindResult(DimensionDir eDir, NgInfo *ngResult) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return 0;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return 0;
|
if (!inf.isGrindUse) return 0;
|
|
CGrindProcess *dot = pInstance->getGrindProcess(eDir);
|
if (NULL == dot) return 0;
|
|
int nCount = 50;
|
int idx = 0;
|
for (int i = 0; i < nCount; i++) {
|
CGrindDotProcess *distDot = dot->m_dots[i];
|
if (NULL == distDot) continue;
|
if (1 != distDot->m_nUse) continue;
|
|
int ngNum = (int)(distDot->m_nNgInfo.size());
|
if (ngNum < 1) continue;
|
|
for (int j = 0; j < ngNum; j++) {
|
if (idx > NG_INF_NUM - 1) continue; //ȱÏÝÊýÁ¿¹ý´ó
|
NgInfo ng;
|
ng.eDir = distDot->m_nNgInfo[j].eDir;
|
ng.eVision = distDot->m_nNgInfo[j].eVision;
|
ng.isRes = distDot->m_nNgInfo[j].isRes;
|
ng.id = distDot->m_nNgInfo[j].id;
|
ng.minValue = distDot->m_nNgInfo[j].minValue;
|
ng.maxValue = distDot->m_nNgInfo[j].maxValue;
|
ng.result = distDot->m_nNgInfo[j].result;
|
ng.xResult = distDot->m_nNgInfo[j].xResult;
|
ng.yResult = distDot->m_nNgInfo[j].yResult;
|
ng.xPosPxl = distDot->m_nNgInfo[j].xPosPxl;
|
ng.yPosPxl = distDot->m_nNgInfo[j].yPosPxl;
|
ng.x1 = distDot->m_nNgInfo[j].x1;
|
ng.y1 = distDot->m_nNgInfo[j].y1;
|
ng.x2 = distDot->m_nNgInfo[j].x2;
|
ng.y2 = distDot->m_nNgInfo[j].y2;
|
ng.ngType = distDot->m_nNgInfo[j].ngType;
|
ng.strName = distDot->m_nNgInfo[j].strName;
|
ngResult[idx] = ng;
|
idx += 1;
|
}
|
}
|
|
return idx;
|
}
|
|
int CSoftVisionApp::getDistResult(DimensionDir eDir, NgInfo *ngResult) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return 0;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return 0;
|
if (!inf.isDistUse) return 0;
|
|
CKDistProcess *dot = pInstance->getKDistProcess(eDir);
|
if (NULL == dot) return 0;
|
|
int nCount = 50;
|
int idx = 0;
|
for (int i = 0; i < nCount; i++) {
|
CKeyDistDotProcess *distDot = dot->m_dots[i];
|
if (NULL == distDot) continue;
|
if (1 != distDot->m_nUse) continue;
|
|
int ngNum = (int)(distDot->m_nNgInfo.size());
|
if (ngNum < 1) continue;
|
|
for (int j = 0; j < ngNum; j++) {
|
if(idx > NG_INF_NUM-1) continue; //ȱÏÝÊýÁ¿¹ý´ó
|
NgInfo ng;
|
ng.eDir = distDot->m_nNgInfo[j].eDir;
|
ng.eVision = distDot->m_nNgInfo[j].eVision;
|
ng.isRes = distDot->m_nNgInfo[j].isRes;
|
ng.id = distDot->m_nNgInfo[j].id;
|
ng.minValue = distDot->m_nNgInfo[j].minValue;
|
ng.maxValue = distDot->m_nNgInfo[j].maxValue;
|
ng.result = distDot->m_nNgInfo[j].result;
|
ng.xResult = distDot->m_nNgInfo[j].xResult;
|
ng.yResult = distDot->m_nNgInfo[j].yResult;
|
ng.xPosPxl = distDot->m_nNgInfo[j].xPosPxl;
|
ng.yPosPxl = distDot->m_nNgInfo[j].yPosPxl;
|
ng.x1 = distDot->m_nNgInfo[j].x1;
|
ng.y1 = distDot->m_nNgInfo[j].y1;
|
ng.x2 = distDot->m_nNgInfo[j].x2;
|
ng.y2 = distDot->m_nNgInfo[j].y2;
|
ng.ngType = distDot->m_nNgInfo[j].ngType;
|
ng.strName = distDot->m_nNgInfo[j].strName;
|
ngResult[idx] = ng;
|
idx += 1;
|
}
|
}
|
|
return idx;
|
}
|
|
int CSoftVisionApp::getCutResult(DimensionDir eDir, NgInfo *ngResult) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return 0;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return 0;
|
if (!inf.isCutUse) return 0;
|
|
CCutProcess *dot = pInstance->getCutProcess(eDir);
|
if (NULL == dot) return 0;
|
|
int nCount = 50;
|
int idx = 0;
|
for (int i = 0; i < nCount; i++) {
|
CCutDotProcess *distDot = dot->m_dots[i];
|
if (NULL == distDot) continue;
|
if (1 != distDot->m_nUse) continue;
|
|
int ngNum = (int)(distDot->m_nNgInfo.size());
|
if (ngNum < 1) continue;
|
|
for (int j = 0; j < ngNum; j++) {
|
if (idx > NG_INF_NUM - 1) continue; //ȱÏÝÊýÁ¿¹ý´ó
|
NgInfo ng;
|
ng.eDir = distDot->m_nNgInfo[j].eDir;
|
ng.eVision = distDot->m_nNgInfo[j].eVision;
|
ng.isRes = distDot->m_nNgInfo[j].isRes;
|
ng.id = distDot->m_nNgInfo[j].id;
|
ng.minValue = distDot->m_nNgInfo[j].minValue;
|
ng.maxValue = distDot->m_nNgInfo[j].maxValue;
|
ng.result = distDot->m_nNgInfo[j].result;
|
ng.xResult = distDot->m_nNgInfo[j].xResult;
|
ng.yResult = distDot->m_nNgInfo[j].yResult;
|
ng.xPosPxl = distDot->m_nNgInfo[j].xPosPxl;
|
ng.yPosPxl = distDot->m_nNgInfo[j].yPosPxl;
|
ng.x1 = distDot->m_nNgInfo[j].x1;
|
ng.y1 = distDot->m_nNgInfo[j].y1;
|
ng.x2 = distDot->m_nNgInfo[j].x2;
|
ng.y2 = distDot->m_nNgInfo[j].y2;
|
ng.ngType = distDot->m_nNgInfo[j].ngType;
|
ng.strName = distDot->m_nNgInfo[j].strName;
|
ngResult[idx] = ng;
|
idx += 1;
|
}
|
}
|
|
return idx;
|
}
|
|
int CSoftVisionApp::getRcutResult(DimensionDir eDir, NgInfo *ngResult) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return 0;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return 0;
|
if (!inf.isRcutUse) return 0;
|
|
CCornerRcutProcess *dot = pInstance->getCornerRcutProcess(eDir);
|
if (NULL == dot) return 0;
|
|
int nCount = 2;
|
int idx = 0;
|
for (int i = 0; i < nCount; i++) {
|
CRcutDotProcess *pRcut = dot->m_dots[i];
|
if (NULL == pRcut) continue;
|
if (1 != pRcut->m_nUse) continue;
|
|
int ngNum = (int)(pRcut->m_nNgInfo.size());
|
if (ngNum < 1) continue;
|
|
for (int j = 0; j < ngNum; j++) {
|
if (idx > NG_INF_NUM - 1) continue; //ȱÏÝÊýÁ¿¹ý´ó
|
NgInfo ng;
|
ng.eDir = pRcut->m_nNgInfo[j].eDir;
|
ng.eVision = pRcut->m_nNgInfo[j].eVision;
|
ng.isRes = pRcut->m_nNgInfo[j].isRes;
|
ng.id = pRcut->m_nNgInfo[j].id;
|
ng.minValue = pRcut->m_nNgInfo[j].minValue;
|
ng.maxValue = pRcut->m_nNgInfo[j].maxValue;
|
ng.result = pRcut->m_nNgInfo[j].result;
|
ng.xResult = pRcut->m_nNgInfo[j].xResult;
|
ng.yResult = pRcut->m_nNgInfo[j].yResult;
|
ng.xPosPxl = pRcut->m_nNgInfo[j].xPosPxl;
|
ng.yPosPxl = pRcut->m_nNgInfo[j].yPosPxl;
|
ng.x1 = pRcut->m_nNgInfo[j].x1;
|
ng.y1 = pRcut->m_nNgInfo[j].y1;
|
ng.x2 = pRcut->m_nNgInfo[j].x2;
|
ng.y2 = pRcut->m_nNgInfo[j].y2;
|
ng.ngType = pRcut->m_nNgInfo[j].ngType;
|
ng.strName = pRcut->m_nNgInfo[j].strName;
|
ngResult[idx] = ng;
|
idx += 1;
|
}
|
}
|
|
return idx;
|
}
|
|
int CSoftVisionApp::getThresResult(DimensionDir eDir, NgInfo *ngResult) {
|
/* code */
|
CVisionRecipe *pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return 0;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return 0;
|
if (!inf.isThresUse) return 0;
|
|
CThresProcess *dot = pInstance->getThresProcess(eDir);
|
if (NULL == dot) return 0;
|
|
int nCount = 12;
|
int idx = 0;
|
for (int i = 0; i < nCount; i++) {
|
CThresDotProcess *pThres = dot->m_dots[i];
|
if (NULL == pThres) continue;
|
if (1 != pThres->m_nUse) continue;
|
|
int ngNum = (int)(pThres->m_nNgInfo.size());
|
if (ngNum < 1) continue;
|
|
for (int j = 0; j < ngNum; j++) {
|
if (idx > NG_INF_NUM - 1) continue; //ȱÏÝÊýÁ¿¹ý´ó
|
NgInfo ng;
|
ng.eDir = pThres->m_nNgInfo[j].eDir;
|
ng.eVision = pThres->m_nNgInfo[j].eVision;
|
ng.isRes = pThres->m_nNgInfo[j].isRes;
|
ng.id = pThres->m_nNgInfo[j].id;
|
ng.minValue = pThres->m_nNgInfo[j].minValue;
|
ng.maxValue = pThres->m_nNgInfo[j].maxValue;
|
ng.result = pThres->m_nNgInfo[j].result;
|
ng.xResult = pThres->m_nNgInfo[j].xResult;
|
ng.yResult = pThres->m_nNgInfo[j].yResult;
|
ng.xPosPxl = pThres->m_nNgInfo[j].xPosPxl;
|
ng.yPosPxl = pThres->m_nNgInfo[j].yPosPxl;
|
ng.x1 = pThres->m_nNgInfo[j].x1;
|
ng.y1 = pThres->m_nNgInfo[j].y1;
|
ng.x2 = pThres->m_nNgInfo[j].x2;
|
ng.y2 = pThres->m_nNgInfo[j].y2;
|
ng.ngType = pThres->m_nNgInfo[j].ngType;
|
ng.strName = pThres->m_nNgInfo[j].strName;
|
ngResult[idx] = ng;
|
idx += 1;
|
}
|
}
|
|
return idx;
|
}
|
|
int CSoftVisionApp::getHoleResult(DimensionDir eDir, NgInfo* ngResult) {
|
/* code */
|
CVisionRecipe* pInstance = CVisionRecipe::getInstance();
|
if (NULL == pInstance) return 0;
|
|
VisionUseInfo inf = pInstance->getVisionUse(eDir);
|
if (!inf.isVisionUse) return 0;
|
if (!inf.isHoleUse) return 0;
|
|
CHoleProcess* dot = pInstance->getHoleProcess(eDir);
|
if (NULL == dot) return 0;
|
|
int nCount = 4;
|
int idx = 0;
|
for (int i = 0; i < nCount; i++) {
|
CHoleDotProcess* pThres = dot->m_dots[i];
|
if (NULL == pThres) continue;
|
if (1 != pThres->m_nUse) continue;
|
|
int ngNum = (int)(pThres->m_nNgInfo.size());
|
if (ngNum < 1) continue;
|
|
for (int j = 0; j < ngNum; j++) {
|
if (idx > NG_INF_NUM - 1) continue; //ȱÏÝÊýÁ¿¹ý´ó
|
NgInfo ng;
|
ng.eDir = pThres->m_nNgInfo[j].eDir;
|
ng.eVision = pThres->m_nNgInfo[j].eVision;
|
ng.isRes = pThres->m_nNgInfo[j].isRes;
|
ng.id = pThres->m_nNgInfo[j].id;
|
ng.minValue = pThres->m_nNgInfo[j].minValue;
|
ng.maxValue = pThres->m_nNgInfo[j].maxValue;
|
ng.result = pThres->m_nNgInfo[j].result;
|
ng.xResult = pThres->m_nNgInfo[j].xResult;
|
ng.yResult = pThres->m_nNgInfo[j].yResult;
|
ng.xPosPxl = pThres->m_nNgInfo[j].xPosPxl;
|
ng.yPosPxl = pThres->m_nNgInfo[j].yPosPxl;
|
ng.x1 = pThres->m_nNgInfo[j].x1;
|
ng.y1 = pThres->m_nNgInfo[j].y1;
|
ng.x2 = pThres->m_nNgInfo[j].x2;
|
ng.y2 = pThres->m_nNgInfo[j].y2;
|
ng.ngType = pThres->m_nNgInfo[j].ngType;
|
ng.strName = pThres->m_nNgInfo[j].strName;
|
ngResult[idx] = ng;
|
idx += 1;
|
}
|
}
|
|
return idx;
|
}
|
|
int CSoftVisionApp::addResultToTotal(NgInfo *ngInfo, int nCount, NgInfo *ngTotal, int nTotal) {
|
/* code */
|
int ngRes = nTotal;
|
if (nCount < 1) return ngRes;
|
|
int fzNum = NG_INF_NUM - 1;
|
for (int i = 0; i < nCount; i++) {
|
if (ngRes > fzNum) continue;
|
NgInfo ng = ngInfo[i];
|
ngTotal[ngRes] = ng;
|
ngRes += 1;
|
}
|
|
return ngRes;
|
}
|
|
void CSoftVisionApp::sendMessage(int code, int eDir) {
|
/* code */
|
if (nullptr == m_pEvent) return;
|
if (NULL == m_pEvent->m_msgRcvCb) return;
|
|
m_pEvent->m_msgRcvCb(code, eDir);
|
}
|
|
void CSoftVisionApp::Log(int level, std::string strText) {
|
/* code */
|
if (nullptr == m_pEvent) return;
|
if (NULL == m_pEvent->m_msgLogCb) return;
|
|
Lock();
|
m_pEvent->m_msgLogCb(level, strText);
|
Unlock();
|
}
|