workpieceHolePositioning version 1.6.5 :
拓普发工件4和工件5姿态计算优化,首先寻找垂直方向孔(原算法首先寻找水平方向孔)。
This commit is contained in:
parent
e09a59bbd9
commit
1f407d9fb9
@ -114,14 +114,6 @@ typedef struct
|
||||
int idx;
|
||||
}SSG_intPair;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int data_0;
|
||||
int data_1;
|
||||
double value1;
|
||||
double value2;
|
||||
}SSG_intPairRelationD;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int flag;
|
||||
|
||||
@ -34,12 +34,22 @@
|
||||
//version 1.6.2 : 拓普发算法代码同步。
|
||||
//version 1.6.3 : 拓普发5种工件算法。共3个API。 工件2和工作5使用API2, 工件3和工件4使用API3。
|
||||
//version 1.6.4 : 拓普发5种工件添加正反判断。
|
||||
std::string m_strVersion = "HolePostion 1.6.4";
|
||||
//version 1.6.5 : 拓普发工件4和工件5姿态计算优化,首先寻找垂直方向孔(原算法首先寻找水平方向孔)。
|
||||
std::string m_strVersion = "HolePostion 1.6.5";
|
||||
const char* wd_workpieceHolePositioningVersion(void)
|
||||
{
|
||||
return m_strVersion.c_str();
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int data_0;
|
||||
int data_1;
|
||||
double pointDistance;
|
||||
double distFromCenterToLine; //参考中心点到两点构成的直线的距离
|
||||
double pointZDiff;
|
||||
}SSG_pointPairRelationD;
|
||||
|
||||
#ifdef _DEBUG_OUTPUT
|
||||
// 二维 int vector (灰度像素 0~255) 转 Mat
|
||||
cv::Mat vec2Int2VisMat(const std::vector<std::vector<int>>& data)
|
||||
@ -1947,20 +1957,54 @@ void _distanceSeparate(
|
||||
return;
|
||||
}
|
||||
|
||||
void _computeDistanceRelationships(std::vector<SWD_HoleInfo>& a_grp, std::vector< SSG_intPairRelationD>& distanceRelations)
|
||||
void _computeDistanceRelationships(std::vector<int>& indice, std::vector<SWD_HoleInfo>& holes, const SVzNL3DPoint refPoint, std::vector< SSG_pointPairRelationD>& distanceRelations)
|
||||
{
|
||||
for (int m = 0; m < (int)a_grp.size(); m++)
|
||||
for (int m = 0; m < (int)indice.size(); m++)
|
||||
{
|
||||
SWD_HoleInfo& hole_1 = a_grp[m];
|
||||
for (int n = m + 1; n < (int)a_grp.size(); n++)
|
||||
int idx1 = indice[m];
|
||||
SWD_HoleInfo& hole_1 = holes[idx1];
|
||||
for (int n = m + 1; n < (int)indice.size(); n++)
|
||||
{
|
||||
SWD_HoleInfo& hole_2 = a_grp[n];
|
||||
int idx2 = indice[n];
|
||||
SWD_HoleInfo& hole_2 = holes[idx2];
|
||||
double distance = sqrt(pow(hole_1.center.x - hole_2.center.x, 2) + pow(hole_1.center.y - hole_2.center.y, 2));
|
||||
SSG_intPairRelationD a_pair;
|
||||
|
||||
double _a, _b, _c;
|
||||
compute2ptLine(hole_1.center, hole_2.center, &_a, &_b, &_c);
|
||||
double dist2 = computePtDistToLine(refPoint.x, refPoint.y, _a, _b, _c);
|
||||
|
||||
SSG_pointPairRelationD a_pair;
|
||||
a_pair.data_0 = idx1;
|
||||
a_pair.data_1 = idx2;
|
||||
a_pair.pointDistance = distance;
|
||||
a_pair.distFromCenterToLine = dist2;
|
||||
a_pair.pointZDiff = abs(hole_1.center.z - hole_2.center.z);
|
||||
distanceRelations.push_back(a_pair);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void _computeDistanceRelationships_2(std::vector<SWD_HoleInfo>& holes, const SVzNL3DPoint refPoint, std::vector< SSG_pointPairRelationD>& distanceRelations)
|
||||
{
|
||||
for (int m = 0; m < (int)holes.size(); m++)
|
||||
{
|
||||
SWD_HoleInfo& hole_1 = holes[m];
|
||||
for (int n = m + 1; n < (int)holes.size(); n++)
|
||||
{
|
||||
SWD_HoleInfo& hole_2 = holes[n];
|
||||
double distance = sqrt(pow(hole_1.center.x - hole_2.center.x, 2) + pow(hole_1.center.y - hole_2.center.y, 2));
|
||||
|
||||
double _a, _b, _c;
|
||||
compute2ptLine(hole_1.center, hole_2.center, &_a, &_b, &_c);
|
||||
double dist2 = computePtDistToLine(refPoint.x, refPoint.y, _a, _b, _c);
|
||||
|
||||
SSG_pointPairRelationD a_pair;
|
||||
a_pair.data_0 = m;
|
||||
a_pair.data_1 = n;
|
||||
a_pair.value1 = distance;
|
||||
a_pair.value2 = abs(hole_1.center.z - hole_2.center.z);
|
||||
a_pair.pointDistance = distance;
|
||||
a_pair.distFromCenterToLine = dist2;
|
||||
a_pair.pointZDiff = abs(hole_1.center.z - hole_2.center.z);
|
||||
distanceRelations.push_back(a_pair);
|
||||
}
|
||||
}
|
||||
@ -2006,7 +2050,7 @@ void wd_workpieceHolePositioning_3(
|
||||
{ //行处理
|
||||
//调平,去除地面
|
||||
wd_lineDataR(scanLines[i], groundCalibPara.planeCalib, -1);
|
||||
wd_lineDataR(scanLinesInput[i], groundCalibPara.planeCalib, -1);
|
||||
//wd_lineDataR(scanLinesInput[i], groundCalibPara.planeCalib, -1);
|
||||
}
|
||||
|
||||
//过滤掉凹段
|
||||
@ -2402,7 +2446,8 @@ void wd_workpieceHolePositioning_3(
|
||||
//生成目标
|
||||
//内部参数
|
||||
double smallHoleMinDistance = 8.0;
|
||||
double maxDistanceFromCenterToLine = 25.0;
|
||||
double maxDistanceFromCenterToLine = 1.0;
|
||||
SVzNLRangeD vHoleDistance = {45.0, 60.0};
|
||||
double reverseJudgeDistToCenterTH = 33.0;
|
||||
double midPointToLongerHoleDIstTh = 20.0; //
|
||||
double distP1P2_short_minTh = 35.0;
|
||||
@ -2426,188 +2471,191 @@ void wd_workpieceHolePositioning_3(
|
||||
//搜索相信小孔
|
||||
std::vector<int> searchResults;
|
||||
searchObjectInRange(p0.center, smallHoles, distRange, deltaZ, searchResults);
|
||||
//根据距离进行分组
|
||||
std::vector<std::vector<SWD_HoleInfo>> groups;
|
||||
_distanceSeparate(searchResults, smallHoles, bigHoleDiameter, groups);
|
||||
if (groups.size() == 0) //工件3和工作4的特点是小孔分为上下各3个。分组
|
||||
continue;
|
||||
|
||||
std::vector<std::vector<double>> distancesToCenter;
|
||||
distancesToCenter.resize(groups.size());
|
||||
for (int grp = 0; grp < (int)groups.size(); grp++)
|
||||
std::vector< SSG_pointPairRelationD> clusterSmallHoleRelations;
|
||||
_computeDistanceRelationships(searchResults, smallHoles, p0.center, clusterSmallHoleRelations);
|
||||
|
||||
//搜索垂直方向
|
||||
double minDistToLine = -1;
|
||||
SSG_pointPairRelationD bestPair;
|
||||
for (int m = 0; m < (int)clusterSmallHoleRelations.size(); m++)
|
||||
{
|
||||
distancesToCenter[grp].resize(groups[grp].size());
|
||||
for (int m = 0; m < (int)groups[grp].size(); m++)
|
||||
if ((clusterSmallHoleRelations[m].pointDistance > vHoleDistance.min) &&
|
||||
(clusterSmallHoleRelations[m].pointDistance < vHoleDistance.max) &&
|
||||
(clusterSmallHoleRelations[m].distFromCenterToLine < maxDistanceFromCenterToLine) &&
|
||||
(clusterSmallHoleRelations[m].pointZDiff < smallHoleParam.H / 4))
|
||||
{
|
||||
double dist = sqrt(pow(p0.center.x - groups[grp][m].center.x, 2) +
|
||||
pow(p0.center.y - groups[grp][m].center.y, 2));
|
||||
distancesToCenter[grp][m] = dist;
|
||||
if (minDistToLine < 0)
|
||||
{
|
||||
minDistToLine = clusterSmallHoleRelations[m].distFromCenterToLine;
|
||||
bestPair = clusterSmallHoleRelations[m];
|
||||
}
|
||||
else if (minDistToLine > clusterSmallHoleRelations[m].distFromCenterToLine)
|
||||
{
|
||||
minDistToLine = clusterSmallHoleRelations[m].distFromCenterToLine;
|
||||
bestPair = clusterSmallHoleRelations[m];
|
||||
}
|
||||
}
|
||||
}
|
||||
//搜索每组中距离大于大孔直径0.8倍的目标
|
||||
|
||||
SWD_HoleInfo p1, p2;
|
||||
bool foundObj = false;
|
||||
bool isYDIr = true;
|
||||
bool isReverse = false;
|
||||
for (int grp = 0; grp < (int)groups.size(); grp++)
|
||||
if (minDistToLine >= 0)
|
||||
{
|
||||
std::vector<SWD_HoleInfo>& a_grp = groups[grp];
|
||||
if (a_grp.size() < 2)
|
||||
continue;
|
||||
p1 = smallHoles[bestPair.data_0];
|
||||
p2 = smallHoles[bestPair.data_1];
|
||||
|
||||
std::vector< SSG_intPairRelationD> distanceRelations;
|
||||
_computeDistanceRelationships(a_grp, distanceRelations);
|
||||
double minDistance = distanceRelations[0].value1;
|
||||
for (int m = 1; m < (int)distanceRelations.size(); m ++)
|
||||
minDistance = minDistance > distanceRelations[m].value1 ? distanceRelations[m].value1 : minDistance;
|
||||
if (minDistance < smallHoleMinDistance) //有非法小孔
|
||||
continue;
|
||||
|
||||
std::vector< SSG_intPairRelationD> validRelations;
|
||||
for (int m = 0; m < (int)distanceRelations.size(); m++)
|
||||
foundObj = true;
|
||||
isYDIr = false;
|
||||
//判断正反
|
||||
bool judeOk = false;
|
||||
for (int n = 0; n < (int)searchResults.size(); n++)
|
||||
{
|
||||
if (distanceRelations[m].value1 > bigHoleDiameter * 0.8)
|
||||
validRelations.push_back(distanceRelations[m]);
|
||||
}
|
||||
int idx = searchResults[n];
|
||||
if ( (idx == bestPair.data_0) || (idx == bestPair.data_1))
|
||||
continue;
|
||||
|
||||
if (validRelations.size() == 1)
|
||||
{
|
||||
int idx1 = validRelations[0].data_0;
|
||||
int idx2= validRelations[0].data_1;
|
||||
p1 = a_grp[idx1];
|
||||
p2 = a_grp[idx2];
|
||||
foundObj = true;
|
||||
|
||||
double dist1 = distancesToCenter[grp][idx1];
|
||||
double dist2 = distancesToCenter[grp][idx2];
|
||||
if ((dist1 > reverseJudgeDistToCenterTH) && (dist2 > reverseJudgeDistToCenterTH)) //longer
|
||||
double distToCenter = sqrt(pow(p0.center.x - smallHoles[idx].center.x, 2) +
|
||||
pow(p0.center.y - smallHoles[idx].center.y, 2));
|
||||
double _distToP1 = sqrt(pow(p1.center.x - smallHoles[idx].center.x, 2) +
|
||||
pow(p1.center.y - smallHoles[idx].center.y, 2));
|
||||
if ((distToCenter > reverseJudgeDistToCenterTH) && (_distToP1 < midPointToLongerHoleDIstTh))
|
||||
{
|
||||
if (p1.center.y < p0.center.y) //长的在上面,反
|
||||
judeOk = true;
|
||||
if (smallHoles[idx].center.y < p0.center.y)
|
||||
isReverse = true;
|
||||
foundObj = true;
|
||||
break;
|
||||
}
|
||||
else if ((dist1 < reverseJudgeDistToCenterTH) && (dist2 < reverseJudgeDistToCenterTH)) //shorter
|
||||
{
|
||||
if (p1.center.y > p0.center.y) //短的在下面,反
|
||||
isReverse = true;
|
||||
foundObj = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (validRelations.size() > 1)
|
||||
if (false == judeOk)
|
||||
{
|
||||
SSG_intPairRelationD bestPair = validRelations[0];
|
||||
for (int m = 1; m < (int)validRelations.size(); m++)
|
||||
for (int n = 0; n < (int)searchResults.size(); n++)
|
||||
{
|
||||
if (bestPair.value2 > validRelations[m].value2)
|
||||
bestPair = validRelations[m];
|
||||
}
|
||||
int idx1 = bestPair.data_0;
|
||||
int idx2 = bestPair.data_1;
|
||||
p1 = a_grp[idx1];
|
||||
p2 = a_grp[idx2];
|
||||
int idx = searchResults[n];
|
||||
if ((idx == bestPair.data_0) || (idx == bestPair.data_1))
|
||||
continue;
|
||||
|
||||
double dist1 = distancesToCenter[grp][idx1];
|
||||
double dist2 = distancesToCenter[grp][idx2];
|
||||
if ((dist1 > reverseJudgeDistToCenterTH) && (dist2 > reverseJudgeDistToCenterTH)) //longer
|
||||
double distToCenter = sqrt(pow(p0.center.x - smallHoles[idx].center.x, 2) +
|
||||
pow(p0.center.y - smallHoles[idx].center.y, 2));
|
||||
double _distToP2 = sqrt(pow(p2.center.x - smallHoles[idx].center.x, 2) +
|
||||
pow(p2.center.y - smallHoles[idx].center.y, 2));
|
||||
if ((distToCenter > reverseJudgeDistToCenterTH) && (_distToP2 < midPointToLongerHoleDIstTh))
|
||||
{
|
||||
judeOk = true;
|
||||
if (smallHoles[idx].center.y < p0.center.y)
|
||||
isReverse = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//根据距离进行分组
|
||||
std::vector<std::vector<SWD_HoleInfo>> groups;
|
||||
_distanceSeparate(searchResults, smallHoles, bigHoleDiameter, groups);
|
||||
if (groups.size() == 0) //工件3和工作4的特点是小孔分为上下各3个。分组
|
||||
continue;
|
||||
|
||||
std::vector<std::vector<double>> distancesToCenter;
|
||||
distancesToCenter.resize(groups.size());
|
||||
for (int grp = 0; grp < (int)groups.size(); grp++)
|
||||
{
|
||||
distancesToCenter[grp].resize(groups[grp].size());
|
||||
for (int m = 0; m < (int)groups[grp].size(); m++)
|
||||
{
|
||||
if ((bestPair.value1 > distP1P2_long_minTh)&&(bestPair.value1 < distP1P2_long_maxTh))
|
||||
double dist = sqrt(pow(p0.center.x - groups[grp][m].center.x, 2) +
|
||||
pow(p0.center.y - groups[grp][m].center.y, 2));
|
||||
distancesToCenter[grp][m] = dist;
|
||||
}
|
||||
}
|
||||
//搜索每组中距离大于大孔直径0.8倍的目标
|
||||
for (int grp = 0; grp < (int)groups.size(); grp++)
|
||||
{
|
||||
std::vector<SWD_HoleInfo>& a_grp = groups[grp];
|
||||
if (a_grp.size() < 2)
|
||||
continue;
|
||||
|
||||
std::vector< SSG_pointPairRelationD> distanceRelations;
|
||||
_computeDistanceRelationships_2(a_grp, p0.center, distanceRelations);
|
||||
double minDistance = distanceRelations[0].pointDistance;
|
||||
for (int m = 1; m < (int)distanceRelations.size(); m++)
|
||||
minDistance = minDistance > distanceRelations[m].pointDistance ? distanceRelations[m].pointDistance : minDistance;
|
||||
if (minDistance < smallHoleMinDistance) //有非法小孔
|
||||
continue;
|
||||
|
||||
std::vector< SSG_pointPairRelationD> validRelations;
|
||||
for (int m = 0; m < (int)distanceRelations.size(); m++)
|
||||
{
|
||||
if (distanceRelations[m].pointDistance > bigHoleDiameter * 0.8)
|
||||
validRelations.push_back(distanceRelations[m]);
|
||||
}
|
||||
|
||||
if (validRelations.size() == 1)
|
||||
{
|
||||
int idx1 = validRelations[0].data_0;
|
||||
int idx2 = validRelations[0].data_1;
|
||||
p1 = a_grp[idx1];
|
||||
p2 = a_grp[idx2];
|
||||
foundObj = true;
|
||||
|
||||
double dist1 = distancesToCenter[grp][idx1];
|
||||
double dist2 = distancesToCenter[grp][idx2];
|
||||
if ((dist1 > reverseJudgeDistToCenterTH) && (dist2 > reverseJudgeDistToCenterTH)) //longer
|
||||
{
|
||||
if (p1.center.y < p0.center.y) //长的在上面,反
|
||||
isReverse = true;
|
||||
foundObj = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((dist1 < reverseJudgeDistToCenterTH) && (dist2 < reverseJudgeDistToCenterTH)) //shorter
|
||||
{
|
||||
if ( (bestPair.value1 > distP1P2_short_minTh)&& (bestPair.value1 < distP1P2_short_maxTh))
|
||||
else if ((dist1 < reverseJudgeDistToCenterTH) && (dist2 < reverseJudgeDistToCenterTH)) //shorter
|
||||
{
|
||||
if (p1.center.y > p0.center.y) //短的在下面,反
|
||||
isReverse = true;
|
||||
foundObj = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (false == foundObj)
|
||||
{
|
||||
//尝试第二种方法,寻找垂直方向的目标
|
||||
if (groups.size() == 2)
|
||||
{
|
||||
SWD_HoleInfo pTmp1, pTmp2;
|
||||
double minDistToLine = -1;
|
||||
for (int m = 0; m < (int)groups[0].size(); m++)
|
||||
else if (validRelations.size() > 1)
|
||||
{
|
||||
SWD_HoleInfo& pp1 = groups[0][m];
|
||||
for (int n = 0; n < (int)groups[1].size(); n++)
|
||||
SSG_pointPairRelationD bestPair = validRelations[0];
|
||||
for (int m = 1; m < (int)validRelations.size(); m++)
|
||||
{
|
||||
SWD_HoleInfo& pp2 = groups[1][n];
|
||||
double _a, _b, _c;
|
||||
compute2ptLine( pp1.center, pp2.center, &_a, &_b, &_c);
|
||||
double dist = computePtDistToLine(p0.center.x, p0.center.x, _a, _b, _c);
|
||||
if (minDistToLine < 0)
|
||||
{
|
||||
minDistToLine = dist;
|
||||
pTmp1 = pp1;
|
||||
pTmp2 = pp2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (minDistToLine > dist)
|
||||
{
|
||||
minDistToLine = dist;
|
||||
pTmp1 = pp1;
|
||||
pTmp2 = pp2;
|
||||
}
|
||||
}
|
||||
if (bestPair.pointZDiff > validRelations[m].pointZDiff)
|
||||
bestPair = validRelations[m];
|
||||
}
|
||||
}
|
||||
if ((minDistToLine >= 0)&&(minDistToLine < maxDistanceFromCenterToLine))
|
||||
{
|
||||
p1 = pTmp1;
|
||||
p2 = pTmp2;
|
||||
foundObj = true;
|
||||
isYDIr = false;
|
||||
//判断正反
|
||||
bool judeOk = false;
|
||||
for (int n = 0; n < (int)groups[0].size(); n++)
|
||||
{
|
||||
double _dist = sqrt(pow(p1.center.x - groups[0][n].center.x, 2) +
|
||||
pow(p1.center.y - groups[0][n].center.y, 2));
|
||||
if ((distancesToCenter[0][n] > reverseJudgeDistToCenterTH) && (_dist < midPointToLongerHoleDIstTh))
|
||||
{
|
||||
if (groups[0][n].center.y < p0.center.y)
|
||||
{
|
||||
judeOk = true;
|
||||
isReverse = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (false == judeOk)
|
||||
{
|
||||
for (int n = 0; n < (int)groups[1].size(); n++)
|
||||
{
|
||||
double _dist = sqrt(pow(p2.center.x - groups[1][n].center.x, 2) +
|
||||
pow(p2.center.y - groups[1][n].center.y, 2));
|
||||
if ((distancesToCenter[1][n] > reverseJudgeDistToCenterTH) && (_dist < midPointToLongerHoleDIstTh))
|
||||
{
|
||||
if (groups[1][n].center.y < p0.center.y)
|
||||
{
|
||||
judeOk = true;
|
||||
isReverse = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int idx1 = bestPair.data_0;
|
||||
int idx2 = bestPair.data_1;
|
||||
p1 = a_grp[idx1];
|
||||
p2 = a_grp[idx2];
|
||||
|
||||
double dist1 = distancesToCenter[grp][idx1];
|
||||
double dist2 = distancesToCenter[grp][idx2];
|
||||
if ((dist1 > reverseJudgeDistToCenterTH) && (dist2 > reverseJudgeDistToCenterTH)) //longer
|
||||
{
|
||||
if ((bestPair.pointDistance > distP1P2_long_minTh) && (bestPair.pointDistance < distP1P2_long_maxTh))
|
||||
{
|
||||
if (p1.center.y < p0.center.y) //长的在上面,反
|
||||
isReverse = true;
|
||||
foundObj = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if ((dist1 < reverseJudgeDistToCenterTH) && (dist2 < reverseJudgeDistToCenterTH)) //shorter
|
||||
{
|
||||
if ((bestPair.pointDistance > distP1P2_short_minTh) && (bestPair.pointDistance < distP1P2_short_maxTh))
|
||||
{
|
||||
if (p1.center.y > p0.center.y) //短的在下面,反
|
||||
isReverse = true;
|
||||
foundObj = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (false == foundObj)
|
||||
continue;
|
||||
|
||||
@ -978,12 +978,17 @@ void _XOYprojection(
|
||||
int px1 = (int)((x1 - x_range.min) / scale + sideWidth);
|
||||
int py1 = (int)((y1 - y_range.min) / scale + sideWidth);
|
||||
//x轴
|
||||
double mx2 = a_hole.center.x - dirAngleLen * a_hole.x_dir.x;
|
||||
double my2 = a_hole.center.y - dirAngleLen * a_hole.x_dir.y;
|
||||
int mpx2 = (int)((mx2 - x_range.min) / scale + sideWidth);
|
||||
int mpy2 = (int)((my2 - y_range.min) / scale + sideWidth);
|
||||
|
||||
double x2 = a_hole.center.x + dirAngleLen * a_hole.x_dir.x;
|
||||
double y2 = a_hole.center.y + dirAngleLen * a_hole.x_dir.y;
|
||||
int px2 = (int)((x2 - x_range.min) / scale + sideWidth);
|
||||
int py2 = (int)((y2 - y_range.min) / scale + sideWidth);
|
||||
rgb = { 255, 0, 0 }; //x轴用红色
|
||||
cv::line(img, cv::Point(px1, py1), cv::Point(px2, py2), cv::Scalar(rgb[2], rgb[1], rgb[0]), 1);
|
||||
cv::line(img, cv::Point(mpx2, mpy2), cv::Point(px2, py2), cv::Scalar(rgb[2], rgb[1], rgb[0]), 1);
|
||||
//y轴
|
||||
x2 = a_hole.center.x + dirAngleLen * a_hole.y_dir.x;
|
||||
y2 = a_hole.center.y + dirAngleLen * a_hole.y_dir.y;
|
||||
@ -1557,24 +1562,25 @@ void TuoPuFa_holePosition_test2(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#define TPF3_TEST_GROUP 7
|
||||
#define TPF3_TEST_GROUP 8
|
||||
//拓普发工件孔定位(工件定位)
|
||||
void TuoPuFa_holePosition_test3(void)
|
||||
void TuoPuFa_holePosition_test4(void)
|
||||
{
|
||||
const char* dataPath[TPF3_TEST_GROUP] = {
|
||||
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/1层/", //0
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/2层/", //1
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/3层/", //2
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/4层/", //3
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/5层/", //4
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/6层/", //5
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/7层/", //6
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/1层/", //0
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/2层/", //1
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/3层/", //2
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/4层/", //3
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/5层/", //4
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/6层/", //5
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/7层/", //6
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/B10歪/", //7
|
||||
};
|
||||
|
||||
SVzNLRange fileIdx[TPF3_TEST_GROUP] = {
|
||||
{1,11}, {1, 10}, {1,10}, {1,10}, {1, 10},
|
||||
{1,10}, {1, 10},
|
||||
{1,10}, {1, 10}, {1, 10},
|
||||
};
|
||||
|
||||
const char* ver = wd_workpieceHolePositioningVersion();
|
||||
@ -1617,7 +1623,7 @@ void TuoPuFa_holePosition_test3(void)
|
||||
#endif
|
||||
|
||||
#if TEST_COMPUTE_HOLE
|
||||
for (int grp = 0; grp < TPF3_TEST_GROUP; grp++)
|
||||
for (int grp = 7; grp < TPF3_TEST_GROUP; grp++)
|
||||
{
|
||||
SSG_planeCalibPara groundCalibPara;
|
||||
//初始化成单位阵
|
||||
@ -1701,7 +1707,7 @@ void TuoPuFa_holePosition_test3(void)
|
||||
|
||||
sprintf_s(calibFile, "%sresult/LaserLine%d_holes_projection.png", dataPath[grp], fidx);
|
||||
double rpy[3] = { -30, 15, 0 }; //{ 0,-45, 0 }; //
|
||||
double angleDrawLen = 15;
|
||||
double angleDrawLen = 30;
|
||||
double displayScale = 0.3;
|
||||
cv::String imgName(calibFile);
|
||||
_genXOYProjectionImage(imgName, scanLines, displayScale, workpiecePositioning, rpy, angleDrawLen);
|
||||
@ -1710,25 +1716,26 @@ void TuoPuFa_holePosition_test3(void)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#define TPF4_TEST_GROUP 7
|
||||
#define TPF4_TEST_GROUP 8
|
||||
//拓普发工件孔定位(工件定位)
|
||||
void TuoPuFa_holePosition_test4(void)
|
||||
void TuoPuFa_holePosition_test5(void)
|
||||
{
|
||||
|
||||
const char* dataPath[TPF4_TEST_GROUP] = {
|
||||
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/1层/", //0
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/2层/", //1
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/3层/", //2
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/4层/", //3
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/5层/", //4
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/6层/", //5
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件4/7层/", //6
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/1层/", //0
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/2层/", //1
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/3层/", //2
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/4层/", //3
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/5层/", //4
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/6层/", //5
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/7层/", //6
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/B20歪/", //7
|
||||
};
|
||||
|
||||
SVzNLRange fileIdx[TPF4_TEST_GROUP] = {
|
||||
{1,11}, {1, 11}, {1,11}, {1,10}, {1, 10},
|
||||
{1,10}, {1, 10},
|
||||
{1,10}, {1, 10}, {1, 10},
|
||||
};
|
||||
|
||||
const char* ver = wd_workpieceHolePositioningVersion();
|
||||
@ -1771,7 +1778,7 @@ void TuoPuFa_holePosition_test4(void)
|
||||
#endif
|
||||
|
||||
#if TEST_COMPUTE_HOLE
|
||||
for (int grp = 0; grp < TPF4_TEST_GROUP; grp++)
|
||||
for (int grp = 7; grp < TPF4_TEST_GROUP; grp++)
|
||||
{
|
||||
SSG_planeCalibPara groundCalibPara;
|
||||
//初始化成单位阵
|
||||
@ -1855,7 +1862,7 @@ void TuoPuFa_holePosition_test4(void)
|
||||
|
||||
sprintf_s(calibFile, "%sresult/LaserLine%d_holes_projection.png", dataPath[grp], fidx);
|
||||
double rpy[3] = { -30, 15, 0 }; //{ 0,-45, 0 }; //
|
||||
double angleDrawLen = 15;
|
||||
double angleDrawLen = 30;
|
||||
double displayScale = 0.3;
|
||||
cv::String imgName(calibFile);
|
||||
_genXOYProjectionImage(imgName, scanLines, displayScale, workpiecePositioning, rpy, angleDrawLen);
|
||||
@ -1867,28 +1874,28 @@ void TuoPuFa_holePosition_test4(void)
|
||||
|
||||
#define TPF5_TEST_GROUP 14
|
||||
//拓普发工件孔定位(工件定位)
|
||||
void TuoPuFa_holePosition_test5(void)
|
||||
void TuoPuFa_holePosition_test3(void)
|
||||
{
|
||||
const char* dataPath[TPF5_TEST_GROUP] = {
|
||||
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/1层/", //0
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/2层/", //1
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/3层/", //2
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/4层/", //3
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/5层/", //4
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/6层/", //5
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/7层/", //6
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/8层/", //7
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/9层/", //8
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/10层/", //9
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/11层/", //10
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/12层/", //11
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/13层/", //12
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件5/14层/", //13
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/1层/", //0
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/2层/", //1
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/3层/", //2
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/4层/", //3
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/5层/", //4
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/6层/", //5
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/7层/", //6
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/8层/", //7
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/9层/", //8
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/10层/", //9
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/11层/", //10
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/12层/", //11
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/13层/", //12
|
||||
"F:/ShangGu/项目/冠钦项目/拓普发工件孔定位/工件3/14层/", //13
|
||||
};
|
||||
|
||||
SVzNLRange fileIdx[TPF5_TEST_GROUP] = {
|
||||
{1,10}, {1, 10}, {1,10}, {1,10}, {1, 10},
|
||||
{1,12}, {1, 10}, {1,10}, {1,10}, {1, 10},
|
||||
{1,11}, {1, 10}, {1,11}, {1,10}, {1,10},
|
||||
{1, 10}, {1,10}, {1,11}, {1,10}
|
||||
};
|
||||
@ -2742,9 +2749,9 @@ int main()
|
||||
{
|
||||
//TuoPuFa_holePosition_test();
|
||||
//TuoPuFa_holePosition_test2();
|
||||
TuoPuFa_holePosition_test3();
|
||||
//TuoPuFa_holePosition_test3();
|
||||
TuoPuFa_holePosition_test4();
|
||||
//TuoPuFa_holePosition_test5();
|
||||
TuoPuFa_holePosition_test5();
|
||||
}
|
||||
else if (keSG_华航孔定位 == testMode)
|
||||
HuaHang_holePosition_test();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user