hybridPosePositioning version 1.5.3 : 转子钢芯,转子改进虚假目标过滤逻辑
This commit is contained in:
parent
821d07fa93
commit
237988f944
@ -2467,7 +2467,7 @@ void HaiRuiMa_groundCalib_test(void)
|
||||
}
|
||||
|
||||
//拓普发工件孔定位(工件定位)
|
||||
#define HRM_RotorCore_TEST_GROUP 11
|
||||
#define HRM_RotorCore_TEST_GROUP 15
|
||||
void HaiRuiMa_rotorCorePositioning_test(void)
|
||||
{
|
||||
const char* dataPath[HRM_RotorCore_TEST_GROUP] = {
|
||||
@ -2477,24 +2477,28 @@ void HaiRuiMa_rotorCorePositioning_test(void)
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子钢芯/现场数据/", //2
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/定子数据/09-14/", //3
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/定子数据/09-14中/", //4
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/定子数据/异常数据/", //5
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/定子数据/异常数据_1/", //5
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/定子数据/10-09小/", //6
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/定子数据/更换5mm镜头相机/", //7
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/转子数据/10.21数据/1-24中型/", //8
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/转子数据/10.21数据/25-63小型/", //9
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/转子数据/10.21数据/64-87大型/", //10
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/定子数据/20261023数据/", //11
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/定子数据/20261024数据/", //12
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/定子数据/异常数据/", //13
|
||||
"F:/ShangGu/项目/冠钦项目/宁波海瑞马/转子定子抓取/转子数据/2楼转子异常数据/", //14
|
||||
};
|
||||
|
||||
SVzNLRange fileIdx[HRM_RotorCore_TEST_GROUP] = {
|
||||
{1,10}, {3,70},{9,9}, {1,54}, {1,54},
|
||||
{1,6}, {1,8}, {1, 16},{1,24}, {25,63},
|
||||
{64,87}
|
||||
{7,9}, {1,8}, {1, 16},{1,24}, {25,63},
|
||||
{64,87},{1,80}, {1,178}, {1, 39}, {1,38}
|
||||
};
|
||||
|
||||
const char* ver = wd_hybridPositioningVersion();
|
||||
printf("ver:%s\n", ver);
|
||||
|
||||
for (int grp = 3; grp <= 7; grp++)
|
||||
for (int grp = 14; grp <= 14; grp++)
|
||||
{
|
||||
SSG_planeCalibPara groundCalibPara;
|
||||
//初始化成单位阵
|
||||
@ -2518,7 +2522,10 @@ void HaiRuiMa_rotorCorePositioning_test(void)
|
||||
{
|
||||
//fidx = 50;
|
||||
char _scan_file[256];
|
||||
sprintf_s(_scan_file, "%s%d_cloud.txt", dataPath[grp], fidx);
|
||||
if( (grp>= 12) && (grp <= 14))
|
||||
sprintf_s(_scan_file, "%s%d.txt", dataPath[grp], fidx);
|
||||
else
|
||||
sprintf_s(_scan_file, "%s%d_cloud.txt", dataPath[grp], fidx);
|
||||
std::vector<std::vector< SVzNLPositionD>> scanLines;
|
||||
vzReadLaserScanPointFromFile_XYZUV_vector(_scan_file, scanLines);
|
||||
_removeZeroLines_XYZUV(scanLines);
|
||||
@ -2570,7 +2577,14 @@ void HaiRuiMa_rotorCorePositioning_test(void)
|
||||
std::vector<WD_objArea2D> objROIs;
|
||||
vzReadObj2DROI(_scan_file, objROIs);
|
||||
#else //使用掩膜
|
||||
sprintf_s(_scan_file, "%s%d_mask.bmp", dataPath[grp], fidx);
|
||||
if (grp == 11) //20261023数据
|
||||
sprintf_s(_scan_file, "%s%d_reinspection_2d_mask.bmp", dataPath[grp], fidx);
|
||||
else if( (grp == 12) ||(grp == 14)) ////20261024数据
|
||||
sprintf_s(_scan_file, "%s%d_input_reinspection_2d_mask.bmp", dataPath[grp], fidx);
|
||||
else if(grp ==13)
|
||||
sprintf_s(_scan_file, "%s%d_reinspection_2d_mask.bmp", dataPath[grp], fidx);
|
||||
else
|
||||
sprintf_s(_scan_file, "%s%d_mask.bmp", dataPath[grp], fidx);
|
||||
//
|
||||
// 读取 BMP 文件(彩色,默认)
|
||||
cv::Mat img = cv::imread(_scan_file, cv::IMREAD_COLOR);
|
||||
@ -2630,6 +2644,8 @@ void HaiRuiMa_rotorCorePositioning_test(void)
|
||||
EWD_WorkpieceClass workpieceClass = keWD_Class_Stator;
|
||||
if ((grp >= 8) && (grp <= 10))
|
||||
workpieceClass = keWD_Class_Rotor;
|
||||
else if(grp == 14)
|
||||
workpieceClass = keWD_Class_Rotor;
|
||||
|
||||
SVzNLSizeD spacerParam; //隔板参数:长和宽
|
||||
spacerParam.dWidth = 720.0;
|
||||
|
||||
@ -36,7 +36,8 @@
|
||||
//version 1.5.1 : 转子钢芯,2D结果由ROI输入换成掩码输入
|
||||
//version 1.5.2 : 转子钢芯,(1)2D结果添加坐标保护。点云输出的坐标会超过(1920, 1216)。
|
||||
// (2)改进定子检测检测方法 (3)改进隔板检测,工件掩膜中的点不参与隔板检测
|
||||
std::string m_strVersion = "HybridPositioning 1.5.2";
|
||||
//version 1.5.3 : 转子钢芯,转子改进虚假目标过滤逻辑(原因是转子中间孔比较小,原来没有隔板时的过滤逻辑有问题
|
||||
std::string m_strVersion = "HybridPositioning 1.5.3";
|
||||
const char* wd_hybridPositioningVersion(void)
|
||||
{
|
||||
return m_strVersion.c_str();
|
||||
@ -2642,9 +2643,9 @@ void wd_HRM_RotorCorePositioning(
|
||||
if (idx == 44)
|
||||
int kkk = 1;
|
||||
SSG_ROIRect& obj_roi = objROIs[idx];
|
||||
int ex_w = (obj_roi.right - obj_roi.left) / 6;
|
||||
int ex_h = (obj_roi.bottom - obj_roi.top) / 6;
|
||||
double roi_R = ex_w < ex_h ? (double)ex_w : (double)ex_h;
|
||||
int ex_w = (obj_roi.right - obj_roi.left) / 3;
|
||||
int ex_h = (obj_roi.bottom - obj_roi.top) / 3;
|
||||
double roi_R = ex_w < ex_h ? (double)ex_w : (double)ex_h; //转子中央孔范围
|
||||
int L = obj_roi.left - ex_w;
|
||||
if (L < 0)
|
||||
L = 0;
|
||||
@ -2715,6 +2716,10 @@ void wd_HRM_RotorCorePositioning(
|
||||
roiScanLines[line].resize(roiLinePtNum);
|
||||
dataRoiMask[line].resize(roiLinePtNum);
|
||||
}
|
||||
|
||||
int totalPixelsInR = 0;
|
||||
int zeroPointsInR = 0;
|
||||
std::vector<SVzNL3DPoint> pointsInR;
|
||||
for (int x = L; x <= R; x++)
|
||||
{
|
||||
for (int y = T; y <= B; y++)
|
||||
@ -2726,6 +2731,8 @@ void wd_HRM_RotorCorePositioning(
|
||||
int ptIdx = a_mapping.mappings[m].ptIdx;
|
||||
if ((lineIdx == 275) && (ptIdx == 929))
|
||||
int kkk = 1;
|
||||
|
||||
double dist = sqrt((x - nCx) * (x - nCx) + (y - nCy) * (y - nCy));
|
||||
if (scanLines[lineIdx][ptIdx].pt3D.z > 1e-4)
|
||||
{
|
||||
scanLines[lineIdx][ptIdx].nPointIdx &= 0xffff0000;
|
||||
@ -2740,7 +2747,6 @@ void wd_HRM_RotorCorePositioning(
|
||||
dataRoiMask[roiLineIdx][roiPtIdx] = 1;
|
||||
|
||||
//搜索中心点
|
||||
double dist = sqrt((x - nCx) * (x - nCx) + (y - nCy) * (y - nCy));
|
||||
if (minDist < 0)
|
||||
{
|
||||
minDist = dist;
|
||||
@ -2752,6 +2758,14 @@ void wd_HRM_RotorCorePositioning(
|
||||
centerPosition = { roiLineIdx, roiPtIdx };
|
||||
}
|
||||
}
|
||||
if (dist < roi_R)
|
||||
{
|
||||
totalPixelsInR++;
|
||||
if (scanLines[lineIdx][ptIdx].pt3D.z > 1e-4)
|
||||
pointsInR.push_back(scanLines[lineIdx][ptIdx].pt3D);
|
||||
else
|
||||
zeroPointsInR++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2803,18 +2817,36 @@ void wd_HRM_RotorCorePositioning(
|
||||
a_workpiece.center = { 0.0, 0.0, 0.0 };
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
//搜索点云与工件中心最接近的点
|
||||
std::vector<SVzNL3DPoint> roiPoints;
|
||||
_searchRCirclePoints(roiScanLines_copy, dataRoiMask, a_workpiece.center, a_workpiece.value * 0.1, roiPoints);
|
||||
double meanZ = _getListMeanZ_2(roiPoints);
|
||||
if (meanZ > 1e-4)
|
||||
if (keWD_Class_Stator == workpieceClass) //version1.5.3: 只有定子可以使用这种逻辑,转子中间孔比较小,需要另一种逻辑
|
||||
{
|
||||
double heightDiff = meanZ - a_workpiece.center.z;
|
||||
if (heightDiff < workpieceParam.height / 2)
|
||||
//搜索点云与工件中心最接近的点
|
||||
std::vector<SVzNL3DPoint> roiPoints;
|
||||
_searchRCirclePoints(roiScanLines_copy, dataRoiMask, a_workpiece.center, a_workpiece.value * 0.1, roiPoints);
|
||||
double meanZ = _getListMeanZ_2(roiPoints);
|
||||
if (meanZ > 1e-4)
|
||||
{
|
||||
double heightDiff = meanZ - a_workpiece.center.z;
|
||||
if (heightDiff < workpieceParam.height / 2)
|
||||
a_workpiece.center = { 0.0, 0.0, 0.0 };
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else //version1.5.3: 转子过滤逻辑:搜索窗口内空白点和大于(workpieceParam.height / 2)的点,看点的数目
|
||||
{
|
||||
double zMin = a_workpiece.center.z + workpieceParam.height / 2;
|
||||
int vldPtsNum = 0;
|
||||
for (int m = 0; m < (int)pointsInR.size(); m++)
|
||||
{
|
||||
if (pointsInR[m].z > zMin)
|
||||
vldPtsNum++;
|
||||
}
|
||||
vldPtsNum += zeroPointsInR;
|
||||
if (vldPtsNum < 1) //version1.5.3:此处是过滤噪声
|
||||
a_workpiece.center = { 0.0, 0.0, 0.0 };
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef _OUTPUT_DEBUG_DATA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user