rodAndBarDetection version 1.3.4 : 新的定位盘中心测量功能算法优化

This commit is contained in:
jerryzeng 2026-06-03 22:33:54 +08:00
parent 2d837cb108
commit 27244f17d3
2 changed files with 50 additions and 21 deletions

View File

@ -1142,25 +1142,26 @@ void locatingPlateTest(void)
} }
} }
#define NEW_LOCATING_PALTE_TEST_GROUP 1 #define NEW_LOCATING_PALTE_TEST_GROUP 2
void newLocatingPlateTest(void) void newLocatingPlateTest(void)
{ {
const char* dataPath[NEW_LOCATING_PALTE_TEST_GROUP] = { 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] = { SVzNLRange fileIdx[NEW_LOCATING_PALTE_TEST_GROUP] = {
{12,13}, {12,13}, {1,51}
}; };
const char* ver = wd_rodAndBarDetectionVersion(); const char* ver = wd_rodAndBarDetectionVersion();
printf("ver:%s\n", ver); 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++) for (int fidx = fileIdx[grp].nMin; fidx <= fileIdx[grp].nMax; fidx++)
{ {
//fidx =2; //fidx =16;
char _scan_file[256]; char _scan_file[256];
sprintf_s(_scan_file, "%sLaserData_%d.txt", dataPath[grp], fidx); 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_测试_棒材抓取; //ESG_testMode testMode = keSG_测试_棒材抓取;
ESG_testMode testMode = keSG_测试_筑裕钢筋焊缝定位; //ESG_testMode testMode = keSG_测试_筑裕钢筋焊缝定位;
if(keSG_测试_配天螺杆定位 == testMode) if(keSG_测试_配天螺杆定位 == testMode)
screwTest(); screwTest();

View File

@ -24,7 +24,8 @@
//version 1.3.1 : 定位盘中心测量功能添加了噪声过滤 //version 1.3.1 : 定位盘中心测量功能添加了噪声过滤
//version 1.3.2 : 矩森棒材抓取修正一个错误码返回错误测试了地面调平API //version 1.3.2 : 矩森棒材抓取修正一个错误码返回错误测试了地面调平API
//version 1.3.3 : 筑裕钢筋焊缝提取算法改进中间版本 //version 1.3.3 : 筑裕钢筋焊缝提取算法改进中间版本
std::string m_strVersion = "1.3.3"; //version 1.3.4 : 新的定位盘中心测量功能算法优化
std::string m_strVersion = "1.3.4";
const char* wd_rodAndBarDetectionVersion(void) const char* wd_rodAndBarDetectionVersion(void)
{ {
return m_strVersion.c_str(); return m_strVersion.c_str();
@ -908,13 +909,27 @@ SVzNL3DRangeD _getPointCloudROI(std::vector<SWD3DPointPostion>& scanData)
return; return;
} }
double _getListMeanZ(std::vector< SVzNL3DPosition>& listData) double _getListMeanZ(std::vector< SVzNL3DPosition>& listData, SVzNLRangeD& zRange)
{ {
if (listData.size() == 0) if (listData.size() == 0)
return 0; return 0;
double meanZ = 0; double meanZ = 0;
zRange.max = -1;
zRange.min = 0;
for (int i = 0; i < (int)listData.size(); i++) for (int i = 0; i < (int)listData.size(); i++)
{
meanZ += listData[i].pt3D.z; 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(); meanZ = meanZ / (double)listData.size();
return meanZ; return meanZ;
} }
@ -1378,7 +1393,8 @@ SSX_platePoseInfo sx_getLocationPlatePose(
double w = a_roi.right - a_roi.left; double w = a_roi.right - a_roi.left;
double h = a_roi.bottom - a_roi.top; double h = a_roi.bottom - a_roi.top;
double meanZ = _getListMeanZ(objClusters[i]); SVzNLRangeD zRange;
double meanZ = _getListMeanZ(objClusters[i], zRange);
objMeanZ[i] = meanZ; objMeanZ[i] = meanZ;
if ( (meanZ > 1e-4) && (w > 150) && (h > 100)) if ( (meanZ > 1e-4) && (w > 150) && (h > 100))
{ {
@ -2090,7 +2106,7 @@ SSX_platePoseInfo sx_getLocationPlatePose_new(
double minObjSize_h = 150; double minObjSize_h = 150;
int clusterCheckWin = 5; int clusterCheckWin = 5;
double clusterDist = 5.0; double clusterDist = 1.5;
int distType = 1; //0 - 2d distance; 1- 3d distance int distType = 1; //0 - 2d distance; 1- 3d distance
std::vector<std::vector< SVzNL3DPosition>> objClusters; //result std::vector<std::vector< SVzNL3DPosition>> objClusters; //result
wd_pointClustering_speedUp( wd_pointClustering_speedUp(
@ -2102,10 +2118,13 @@ SSX_platePoseInfo sx_getLocationPlatePose_new(
); );
//保留最前面的目标 //保留最前面的目标
const double topPlateMinW = 150; const double topPlateMinW = 150.0;
const double topPlateMinH = 150; const double topPlateMinH = 150.0;
const double topPlateMaxZRange = 100.0;
std::vector<double> objMeanZ; std::vector<double> objMeanZ;
std::vector<SVzNLRangeD> objZRange;
objMeanZ.resize(objClusters.size()); objMeanZ.resize(objClusters.size());
objZRange.resize(objClusters.size());
for (int i = 0; i < (int)objClusters.size(); i++) for (int i = 0; i < (int)objClusters.size(); i++)
{ {
SSG_ROIRectD a_roi = _getListROI(objClusters[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; double h = a_roi.bottom - a_roi.top;
if ((w > topPlateMinW) && (h > topPlateMinH)) if ((w > topPlateMinW) && (h > topPlateMinH))
{ {
SVzNLRangeD zRange;
double meanZ = _getListMeanZ(objClusters[i]); double meanZ = _getListMeanZ(objClusters[i], zRange);
objMeanZ[i] = meanZ; objMeanZ[i] = meanZ;
objZRange[i]= zRange;
} }
else else
objMeanZ[i] = 0; 0; {
objMeanZ[i] = 0;
objZRange[i].max = -1.0;
objZRange[i].min = 0.0;
}
} }
//选出z最小的目标作为顶部轮廓 //选出z最小的目标作为顶部轮廓
@ -2126,12 +2150,16 @@ SSX_platePoseInfo sx_getLocationPlatePose_new(
double minMeanZ = DBL_MAX; double minMeanZ = DBL_MAX;
for (int i = 0; i < (int)objClusters.size(); i++) 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]; if (minMeanZ > objMeanZ[i])
objIdx = i; {
minMeanZ = objMeanZ[i];
objIdx = i;
}
} }
} }
} }