|
|
|
@ -97,8 +97,6 @@ CAlgorithmCompare::~CAlgorithmCompare(void)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//cv::BackgroundSubtractorMOG CAlgorithmFluorescence::bgSubtractor(30, 5, 0.95, false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString CAlgorithmCompare::bestMatch(const QMap<QString, IWheelModel*>* modelMap, CLocalWheel*pLocal, double* pMinDis /*= NULL*/, int minDisNum /*= -1*/) const
|
|
|
|
QString CAlgorithmCompare::bestMatch(const QMap<QString, IWheelModel*>* modelMap, CLocalWheel*pLocal, double* pMinDis /*= NULL*/, int minDisNum /*= -1*/) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
double minDis = DBL_MAX;
|
|
|
|
double minDis = DBL_MAX;
|
|
|
|
@ -279,7 +277,9 @@ int CAlgorithmCompare::IImageAnalysis(class IImageObject* pImgObj)
|
|
|
|
double dD2H = vMap.value("d2h", -1).toDouble();
|
|
|
|
double dD2H = vMap.value("d2h", -1).toDouble();
|
|
|
|
int nthreshold = vMap.value("Threshold", 15).toInt();
|
|
|
|
int nthreshold = vMap.value("Threshold", 15).toInt();
|
|
|
|
bool bUseBackground = vMap.value("useBackground",false).toBool();//true 使用背景图抠图 false 不使用背景
|
|
|
|
bool bUseBackground = vMap.value("useBackground",false).toBool();//true 使用背景图抠图 false 不使用背景
|
|
|
|
|
|
|
|
int filterCircleSize = vMap.value("filterSize", 50).toInt();//过滤尺寸
|
|
|
|
|
|
|
|
bool bEqual = vMap.value("bEqual", false).toBool();//是否使用图像增强
|
|
|
|
|
|
|
|
|
|
|
|
if (nthreshold <= 0)
|
|
|
|
if (nthreshold <= 0)
|
|
|
|
nthreshold = 15;
|
|
|
|
nthreshold = 15;
|
|
|
|
int IsCutedImg = vMap.value("IsCutImg", 0).toInt();//裁剪后的轮毂图
|
|
|
|
int IsCutedImg = vMap.value("IsCutImg", 0).toInt();//裁剪后的轮毂图
|
|
|
|
@ -301,17 +301,16 @@ int CAlgorithmCompare::IImageAnalysis(class IImageObject* pImgObj)
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
bReload = false;
|
|
|
|
bReload = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//imageSegementation(matSrc);
|
|
|
|
|
|
|
|
//matMatch = ImageProcess::findCircleObject(matSrc, matBack, bUseBackground, nthreshold/*15*/, &lCircle/* NULL*/);
|
|
|
|
//matMatch = ImageProcess::findCircleObject(matSrc, matBack, bUseBackground, nthreshold/*15*/, &lCircle/* NULL*/);
|
|
|
|
Point2f centerPoint;
|
|
|
|
Point2f centerPoint;
|
|
|
|
double radius = 0;
|
|
|
|
double radius = 0;
|
|
|
|
matMatch = ImageProcess::findCircle(matSrc, centerPoint, radius);
|
|
|
|
matMatch = ImageProcess::findCircle(matSrc, centerPoint, radius, bEqual, filterCircleSize);
|
|
|
|
lCircle.ptCenter = centerPoint;
|
|
|
|
lCircle.ptCenter = centerPoint;
|
|
|
|
lCircle.fRadius = radius;
|
|
|
|
lCircle.fRadius = radius;
|
|
|
|
|
|
|
|
|
|
|
|
if (matMatch.cols >= 900 || matMatch.rows >= 900)
|
|
|
|
if (matMatch.cols >= 900 || matMatch.rows >= 900)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
cv::resize(matMatch, matMatch, cv::Size(matMatch.cols / 2, matMatch.rows / 2));
|
|
|
|
cv::resize(matMatch, matMatch, cv::Size(matMatch.cols / 2, matMatch.rows / 2));
|
|
|
|
lCircle.fRadius = lCircle.fRadius / 2;
|
|
|
|
lCircle.fRadius = lCircle.fRadius / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -327,10 +326,8 @@ int CAlgorithmCompare::IImageAnalysis(class IImageObject* pImgObj)
|
|
|
|
pImgObj->IVariantMapToUI(rltMap);
|
|
|
|
pImgObj->IVariantMapToUI(rltMap);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//Mat matMatch = ImageProcess::findCircleObject(matSrc, matBack, 15, NULL/* &lCircle*/);
|
|
|
|
|
|
|
|
//double dDiameter = dD2H * matMatch.rows;
|
|
|
|
|
|
|
|
double dDiameter = dD2H * lCircle.fRadius * 2;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double dDiameter = dD2H * lCircle.fRadius * 2;
|
|
|
|
QVariantMap mResult;//匹配算法结果
|
|
|
|
QVariantMap mResult;//匹配算法结果
|
|
|
|
CLocalWheel wheelLocal;
|
|
|
|
CLocalWheel wheelLocal;
|
|
|
|
wheelLocal.defectList = strModelList;
|
|
|
|
wheelLocal.defectList = strModelList;
|
|
|
|
@ -370,7 +367,6 @@ int CAlgorithmCompare::IImageAnalysis(class IImageObject* pImgObj)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cv::Mat CAlgorithmCompare::getImage(class IImageObject *pImgObj)
|
|
|
|
cv::Mat CAlgorithmCompare::getImage(class IImageObject *pImgObj)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
emTpColorFormat colorFormat = pImgObj->IColorFormat();
|
|
|
|
emTpColorFormat colorFormat = pImgObj->IColorFormat();
|
|
|
|
@ -418,71 +414,3 @@ cv::Mat CAlgorithmCompare::getBackGroundImage(class IImageObject *pObj, bool bRe
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return matback;
|
|
|
|
return matback;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//void CAlgorithmFluorescence::imageSegementation(const cv::Mat &srcImage)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// Mat mask;
|
|
|
|
|
|
|
|
// //Mat sobelImg = srcImage.clone();
|
|
|
|
|
|
|
|
// //genSobelImage(sobelImg);
|
|
|
|
|
|
|
|
// //sobelImg.convertTo(sobelImg, CV_8UC1);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Mat sobelX, sobelY;
|
|
|
|
|
|
|
|
// Sobel(srcImage, sobelX, CV_32FC1, 1, 0, 3, BORDER_REPLICATE);
|
|
|
|
|
|
|
|
// Sobel(srcImage, sobelY, CV_32FC1, 0, 1, 3, BORDER_REPLICATE);
|
|
|
|
|
|
|
|
// Mat img = sobelX.mul(sobelX) + sobelY.mul(sobelY);
|
|
|
|
|
|
|
|
// Mat tempImg;
|
|
|
|
|
|
|
|
// img.convertTo(tempImg, CV_32FC1);
|
|
|
|
|
|
|
|
// Mat tempImg0;
|
|
|
|
|
|
|
|
// sqrt(tempImg, tempImg0);
|
|
|
|
|
|
|
|
// img = tempImg0;
|
|
|
|
|
|
|
|
// img.convertTo(img, CV_8UC1);
|
|
|
|
|
|
|
|
// Mat blurImg;
|
|
|
|
|
|
|
|
// cv::medianBlur(img, blurImg, 11);
|
|
|
|
|
|
|
|
// bgSubtractor(img, mask, 0.001);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// /*cv::Mat element5(5, 5, CV_8U, cv::Scalar(1));
|
|
|
|
|
|
|
|
// cv::Mat closedMat;
|
|
|
|
|
|
|
|
// cv::morphologyEx(mask, closedMat, cv::MORPH_CLOSE, element5);*/
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// //cv::floodFill();
|
|
|
|
|
|
|
|
// luffy_base::luffyCircle pCircle;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// vector<cv::Mat> mats= ImageProcess::findCircleObject(mask, srcImage, 15, &pCircle);
|
|
|
|
|
|
|
|
// if (mats.size() == 0)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (mats[0].size() != mats[1].size())
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// Mat dilatedImgBin;
|
|
|
|
|
|
|
|
// Mat imgBinary = mats[0] > 0;
|
|
|
|
|
|
|
|
// dilate(imgBinary, dilatedImgBin, Mat::ones(5, 5, CV_32FC1));
|
|
|
|
|
|
|
|
// erode(dilatedImgBin, imgBinary, Mat::ones(5, 5, CV_32FC1));
|
|
|
|
|
|
|
|
// imgBinary = ~imgBinary;
|
|
|
|
|
|
|
|
// //Mat canvas(imgBinary.size(), imgBinary.type(), Scalar::all(0));
|
|
|
|
|
|
|
|
// vector<vector<Point>> cons;
|
|
|
|
|
|
|
|
// cv::findContours(imgBinary, cons, RETR_EXTERNAL, CHAIN_APPROX_NONE);
|
|
|
|
|
|
|
|
// for (const vector<Point> & pContour : cons)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// const int& size = pContour.size();
|
|
|
|
|
|
|
|
// if (size < 200)
|
|
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
// Mat(pContour).setTo(255);
|
|
|
|
|
|
|
|
// //continue;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //cv::fillPoly(canvas, vector<vector<Point>>(1, pContour), Scalar(255));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// //Mat tarMat = (~canvas).mul(mats[1]) / 255;
|
|
|
|
|
|
|
|
// //openOper(imgBinary, Mat::ones(1, 13, CV_32FC1));
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|