From 27244f17d32b963f736e00cbd71db2a8db4036e1 Mon Sep 17 00:00:00 2001 From: jerryzeng Date: Wed, 3 Jun 2026 22:33:54 +0800 Subject: [PATCH] =?UTF-8?q?rodAndBarDetection=20version=201.3.4=20:=20?= =?UTF-8?q?=E6=96=B0=E7=9A=84=E5=AE=9A=E4=BD=8D=E7=9B=98=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E6=B5=8B=E9=87=8F=E5=8A=9F=E8=83=BD=E7=AE=97=E6=B3=95=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rodAndBarDetection_test.cpp | 15 ++--- sourceCode/rodAndBarDetection.cpp | 56 ++++++++++++++----- 2 files changed, 50 insertions(+), 21 deletions(-) diff --git a/rodAndBarDetection_test/rodAndBarDetection_test.cpp b/rodAndBarDetection_test/rodAndBarDetection_test.cpp index 1045052..5168afa 100644 --- a/rodAndBarDetection_test/rodAndBarDetection_test.cpp +++ b/rodAndBarDetection_test/rodAndBarDetection_test.cpp @@ -1142,25 +1142,26 @@ void locatingPlateTest(void) } } -#define NEW_LOCATING_PALTE_TEST_GROUP 1 +#define NEW_LOCATING_PALTE_TEST_GROUP 2 void newLocatingPlateTest(void) { const char* dataPath[NEW_LOCATING_PALTE_TEST_GROUP] = { - "F:/ShangGu/项目/冠钦项目/螺杆测量/配天现场点云/定位盘点云20260621/", //0 + "F:/ShangGu/项目/冠钦项目/螺杆测量/配天现场点云/定位盘点云20260521/", //0 + "F:/ShangGu/项目/冠钦项目/螺杆测量/配天现场点云/定位盘点云20260603/", //1 }; SVzNLRange fileIdx[NEW_LOCATING_PALTE_TEST_GROUP] = { - {12,13}, + {12,13}, {1,51} }; const char* ver = wd_rodAndBarDetectionVersion(); printf("ver:%s\n", ver); - for (int grp = 0; grp < NEW_LOCATING_PALTE_TEST_GROUP; grp++) + for (int grp = 1; grp < NEW_LOCATING_PALTE_TEST_GROUP; grp++) { for (int fidx = fileIdx[grp].nMin; fidx <= fileIdx[grp].nMax; fidx++) { - //fidx =2; + //fidx =16; char _scan_file[256]; sprintf_s(_scan_file, "%sLaserData_%d.txt", dataPath[grp], fidx); @@ -1734,9 +1735,9 @@ int main() { //ESG_testMode testMode = keSG_测试_配天螺杆定位; //ESG_testMode testMode = keSG_测试_配天定位盘定位; - //ESG_testMode testMode = keSG_测试_配天新定位盘定位; + ESG_testMode testMode = keSG_测试_配天新定位盘定位; //ESG_testMode testMode = keSG_测试_棒材抓取; - ESG_testMode testMode = keSG_测试_筑裕钢筋焊缝定位; + //ESG_testMode testMode = keSG_测试_筑裕钢筋焊缝定位; if(keSG_测试_配天螺杆定位 == testMode) screwTest(); diff --git a/sourceCode/rodAndBarDetection.cpp b/sourceCode/rodAndBarDetection.cpp index 23da844..c6b1f25 100644 --- a/sourceCode/rodAndBarDetection.cpp +++ b/sourceCode/rodAndBarDetection.cpp @@ -24,7 +24,8 @@ //version 1.3.1 : λIJ //version 1.3.2 : ɭץȡһ뷵ش󣬲˵ƽAPI //version 1.3.3 : ԣֽȡ㷨Ľм汾 -std::string m_strVersion = "1.3.3"; +//version 1.3.4 : µĶλIJ㷨Ż +std::string m_strVersion = "1.3.4"; const char* wd_rodAndBarDetectionVersion(void) { return m_strVersion.c_str(); @@ -908,13 +909,27 @@ SVzNL3DRangeD _getPointCloudROI(std::vector& scanData) return; } -double _getListMeanZ(std::vector< SVzNL3DPosition>& listData) +double _getListMeanZ(std::vector< SVzNL3DPosition>& listData, SVzNLRangeD& zRange) { if (listData.size() == 0) return 0; double meanZ = 0; + zRange.max = -1; + zRange.min = 0; for (int i = 0; i < (int)listData.size(); i++) + { meanZ += listData[i].pt3D.z; + if (zRange.max < 0) + { + zRange.max = listData[i].pt3D.z; + zRange.min = listData[i].pt3D.z; + } + else + { + zRange.max = zRange.max < listData[i].pt3D.z ? listData[i].pt3D.z : zRange.max; + zRange.min = zRange.min > listData[i].pt3D.z ? listData[i].pt3D.z : zRange.min; + } + } meanZ = meanZ / (double)listData.size(); return meanZ; } @@ -1378,7 +1393,8 @@ SSX_platePoseInfo sx_getLocationPlatePose( double w = a_roi.right - a_roi.left; double h = a_roi.bottom - a_roi.top; - double meanZ = _getListMeanZ(objClusters[i]); + SVzNLRangeD zRange; + double meanZ = _getListMeanZ(objClusters[i], zRange); objMeanZ[i] = meanZ; if ( (meanZ > 1e-4) && (w > 150) && (h > 100)) { @@ -2090,7 +2106,7 @@ SSX_platePoseInfo sx_getLocationPlatePose_new( double minObjSize_h = 150; int clusterCheckWin = 5; - double clusterDist = 5.0; + double clusterDist = 1.5; int distType = 1; //0 - 2d distance; 1- 3d distance std::vector> objClusters; //result wd_pointClustering_speedUp( @@ -2102,10 +2118,13 @@ SSX_platePoseInfo sx_getLocationPlatePose_new( ); //ǰĿ - const double topPlateMinW = 150; - const double topPlateMinH = 150; + const double topPlateMinW = 150.0; + const double topPlateMinH = 150.0; + const double topPlateMaxZRange = 100.0; std::vector objMeanZ; - objMeanZ.resize(objClusters.size()); + std::vector objZRange; + objMeanZ.resize(objClusters.size()); + objZRange.resize(objClusters.size()); for (int i = 0; i < (int)objClusters.size(); i++) { SSG_ROIRectD a_roi = _getListROI(objClusters[i]); @@ -2113,12 +2132,17 @@ SSX_platePoseInfo sx_getLocationPlatePose_new( double h = a_roi.bottom - a_roi.top; if ((w > topPlateMinW) && (h > topPlateMinH)) { - - double meanZ = _getListMeanZ(objClusters[i]); + SVzNLRangeD zRange; + double meanZ = _getListMeanZ(objClusters[i], zRange); objMeanZ[i] = meanZ; + objZRange[i]= zRange; } else - objMeanZ[i] = 0; 0; + { + objMeanZ[i] = 0; + objZRange[i].max = -1.0; + objZRange[i].min = 0.0; + } } //ѡzСĿΪ @@ -2126,12 +2150,16 @@ SSX_platePoseInfo sx_getLocationPlatePose_new( double minMeanZ = DBL_MAX; for (int i = 0; i < (int)objClusters.size(); i++) { - if (objMeanZ[i] > 1e-4) + if ( (objMeanZ[i] > 1e-4) && (objZRange[i].max > 0)) { - if (minMeanZ > objMeanZ[i]) + double range = objZRange[i].max - objZRange[i].min; + if (range < topPlateMaxZRange) { - minMeanZ = objMeanZ[i]; - objIdx = i; + if (minMeanZ > objMeanZ[i]) + { + minMeanZ = objMeanZ[i]; + objIdx = i; + } } } }