From e4b21ea64329c5129b2e66c50ee1f947af7a5f87 Mon Sep 17 00:00:00 2001 From: "bob.pan" Date: Sun, 26 Sep 2021 11:30:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=89=AF=E6=8A=A0=E5=9B=BE=E7=AE=97?= =?UTF-8?q?=E6=B3=95,=E5=A2=9E=E5=8A=A0filtersize=E5=9C=A8=E6=8A=A0?= =?UTF-8?q?=E5=9B=BE=E4=B8=AD=E7=9A=84=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ImageCompare/ImageCompareModel.cpp | 2 +- src/algorithm/AlgorithmFluorescence.cpp | 1 + src/algorithm/ImageProcess.cpp | 71 +++++++++++++++---------- src/algorithm/ImageProcess.h | 1 + src/tpMain/cryptokey/lpCryptokey.cpp | 2 +- tpvs17/tpMain/QAlgParamDlg.ui | 3 ++ tpvs17/tpMain/lpMainWin.cpp | 6 +-- 7 files changed, 52 insertions(+), 34 deletions(-) diff --git a/src/ImageCompare/ImageCompareModel.cpp b/src/ImageCompare/ImageCompareModel.cpp index 4286771..c310a34 100644 --- a/src/ImageCompare/ImageCompareModel.cpp +++ b/src/ImageCompare/ImageCompareModel.cpp @@ -1876,7 +1876,7 @@ void ImageCompareModelInvoker::operator()(const cv::Range& range) const { int i0 = range.start; int i1 = range.end; - assert(abs(i1 - i0) == 1); +// assert(abs(i1 - i0) == 1); //if (abs(i1 - i0) == 1) // return; m_pModel->parallelDetect(i0, m_pData); diff --git a/src/algorithm/AlgorithmFluorescence.cpp b/src/algorithm/AlgorithmFluorescence.cpp index d5bd7de..2cf6128 100644 --- a/src/algorithm/AlgorithmFluorescence.cpp +++ b/src/algorithm/AlgorithmFluorescence.cpp @@ -85,6 +85,7 @@ int CAlgorithmFluorescence::IImageAnalysis(class IImageObject* pImgObj, TP_ALGOR cParam.CirclePolarity = vMap.value("Circle_Polarity",0).toInt(); cParam.CircleACThres = vMap.value("Circle_ACThres",3).toInt(); cParam.CircleEdgeWidth = vMap.value("Circle_EdgeWidth",3).toInt(); + cParam.filterSize = filterSize; if (nthreshold <= 0) nthreshold = 15; diff --git a/src/algorithm/ImageProcess.cpp b/src/algorithm/ImageProcess.cpp index 2df580f..00c8bd0 100644 --- a/src/algorithm/ImageProcess.cpp +++ b/src/algorithm/ImageProcess.cpp @@ -71,6 +71,8 @@ cv::Mat ImageProcess::findCircle(const Mat &srcImg, Point2f& center, double &rad vector EDCircle = edcircles.getCircles(); double maxR = 0; int nIndex = -1; + float centerX = 0; + float centerY = 0; for (int i = 0; i < EDCircle.size(); i++) { int startX = EDCircle[i].center.x - EDCircle[i].r; @@ -86,45 +88,39 @@ cv::Mat ImageProcess::findCircle(const Mat &srcImg, Point2f& center, double &rad { maxR = EDCircle[i].r; nIndex = i; + centerX = EDCircle[i].center.x * REAIZE; + centerY = EDCircle[i].center.y * REAIZE; } } - if (nIndex != -1) + if (nIndex != -1)//找到合适的圆 只需要圆心 { - int startX = EDCircle[nIndex].center.x * REAIZE - EDCircle[nIndex].r * REAIZE; - int startY = EDCircle[nIndex].center.y * REAIZE - EDCircle[nIndex].r* REAIZE; - radius = EDCircle[nIndex].r; - int hight = 2 * radius * REAIZE; - + radius = EDCircle[nIndex].r * REAIZE; center.x = (EDCircle[nIndex].center.x * REAIZE); center.y = (EDCircle[nIndex].center.y * REAIZE); - radius = radius * REAIZE; return DetectCircle(srcImg, Mat(), center, radius, bEqual, cParam); } else { - center.x = srcImg.cols/2; - center.y = srcImg.rows/2; + center.x = centerX; + center.y = centerY; radius = 0; - return DetectCircle(srcImg, Mat(), center,radius,bEqual, cParam); + return DetectCircle(srcImg, Mat(), center, radius, bEqual, cParam); } } Mat ImageProcess::DetectCircle(Mat srcImg, Mat background, Point2f& center, double& radius, bool bEqual, const CircleParam& cParam) { Mat img; - if (!background.empty()) - { + if (!background.empty()) { img = getForeImage(srcImg, background); } else { img = srcImg; } Mat detectImg; - if (bEqual == true) - { + if (bEqual == true) { equalizeHist(img, detectImg); } - else - { + else { detectImg = img; } @@ -137,14 +133,32 @@ Mat ImageProcess::DetectCircle(Mat srcImg, Mat background, Point2f& center, doub cd.setPolarity(Polarity::White2Black); cd.setFindBy(FindBy::Best); - double difRadiusMin = radius - 100; - double difRadiusMax = radius + 100; - if (difRadiusMin < 0) + if (center.x == 0 || center.y == 0) { - difRadiusMin = 0; - difRadiusMax = abs(abs(center.y - (img.cols / 2)) - 50); + center.x = img.cols / 2; + center.y = img.rows / 2; + } + int rY = img.rows - center.y; + int rX = img.cols - center.x; + int min_dify = center.y > rY ? rY : center.y; + int min_difx = center.x > rX ? rX : center.x; + int maxRadius = abs(abs(min_difx > min_dify ? min_dify : min_difx)-50); + double difRadiusMin = radius - 150; + double difRadiusMax = radius + 250; + if (difRadiusMin <= 0) + { + difRadiusMin = cParam.filterSize; + difRadiusMax = maxRadius; } + //控制范围,不让检测越界 + //if (difRadiusMin < cParam.filterSize) + difRadiusMin = cParam.filterSize; + //if (difRadiusMax > maxRadius) + difRadiusMax = maxRadius; + if (difRadiusMin > difRadiusMax) + difRadiusMin = 0; + cd.setRadii(difRadiusMin, difRadiusMax); cd.setACThres(cParam.CircleACThres); vector allScores; @@ -191,6 +205,8 @@ cv::Mat ImageProcess::findCircleByBackground(const Mat &srcImg, const Mat& backg vector EDCircle = edcircles.getCircles(); double maxR = 0; int nIndex = -1; + float centerX = 0; + float centerY = 0; for (int i = 0; i < EDCircle.size(); i++) { int startX = EDCircle[i].center.x - EDCircle[i].r; @@ -206,23 +222,20 @@ cv::Mat ImageProcess::findCircleByBackground(const Mat &srcImg, const Mat& backg { maxR = EDCircle[i].r; nIndex = i; + centerX = EDCircle[i].center.x * REAIZE; + centerY = EDCircle[i].center.y * REAIZE; } } if (nIndex != -1) { - int startX = EDCircle[nIndex].center.x * REAIZE - EDCircle[nIndex].r * REAIZE; - int startY = EDCircle[nIndex].center.y * REAIZE - EDCircle[nIndex].r* REAIZE; - radius = EDCircle[nIndex].r; - int hight = 2 * radius * REAIZE; - + radius = EDCircle[nIndex].r * REAIZE; center.x = (EDCircle[nIndex].center.x * REAIZE); center.y = (EDCircle[nIndex].center.y * REAIZE); - radius = radius * REAIZE; return DetectCircle(srcImg, backgroundImg, center, radius, bEqual, cParam); } else { - center.x = srcImg.cols / 2; - center.y = srcImg.rows / 2; + center.x = centerX; + center.y = centerY; radius = 0; return DetectCircle(srcImg, backgroundImg, center, radius, bEqual, cParam); } diff --git a/src/algorithm/ImageProcess.h b/src/algorithm/ImageProcess.h index 48b5cd3..8f2b21c 100644 --- a/src/algorithm/ImageProcess.h +++ b/src/algorithm/ImageProcess.h @@ -18,6 +18,7 @@ struct CircleParam { int CirclePolarity{ 0 }; int CircleACThres{ 3 }; int CircleEdgeWidth{ 3 }; + int filterSize{ 50 }; }; class ImageProcess { diff --git a/src/tpMain/cryptokey/lpCryptokey.cpp b/src/tpMain/cryptokey/lpCryptokey.cpp index c6ad86a..7ec095a 100644 --- a/src/tpMain/cryptokey/lpCryptokey.cpp +++ b/src/tpMain/cryptokey/lpCryptokey.cpp @@ -74,7 +74,7 @@ lpCheckKey::~lpCheckKey() //检查linese是否匹配 bool lpCheckKey::checkLinese() { - std::string biosID = lpHardwareInfo::instance()->getBiosID(); + std::string biosID = lpHardwareInfo::instance()->getHardDrive(); m_SerialNo = lpCryptokey::genSerialNumber(QString(biosID.c_str())); QSettings settingKey("Leaper_Register"); QString strKey = settingKey.value("key").toString(); diff --git a/tpvs17/tpMain/QAlgParamDlg.ui b/tpvs17/tpMain/QAlgParamDlg.ui index 69d5935..d8d59cb 100644 --- a/tpvs17/tpMain/QAlgParamDlg.ui +++ b/tpvs17/tpMain/QAlgParamDlg.ui @@ -152,6 +152,9 @@ QAbstractSpinBox::NoButtons + + 999 + diff --git a/tpvs17/tpMain/lpMainWin.cpp b/tpvs17/tpMain/lpMainWin.cpp index b720469..d5d38d7 100644 --- a/tpvs17/tpMain/lpMainWin.cpp +++ b/tpvs17/tpMain/lpMainWin.cpp @@ -23,9 +23,9 @@ #include #include "lpCryptokey.h" -#define VERSION_HUB "3.0.1.3" -#define VERSION_ALG "3.0.1.3" -#define UPDATE_TIME "2021-09-23" +#define VERSION_HUB "3.0.1.4" +#define VERSION_ALG "3.0.1.4" +#define UPDATE_TIME "2021-09-26" #pragma execution_character_set("utf-8") lpMainWin::lpMainWin(QWidget *parent)