rodAndBarDetection version 1.3.5 :
新的定位盘中心测量功能占将float运算改成double ,测试PC和3588差异
This commit is contained in:
parent
27244f17d3
commit
5d95855e2a
@ -1151,7 +1151,7 @@ void newLocatingPlateTest(void)
|
||||
};
|
||||
|
||||
SVzNLRange fileIdx[NEW_LOCATING_PALTE_TEST_GROUP] = {
|
||||
{12,13}, {1,51}
|
||||
{12,13}, {52,52}
|
||||
};
|
||||
|
||||
const char* ver = wd_rodAndBarDetectionVersion();
|
||||
@ -1694,7 +1694,17 @@ void rodWeldSeamPosition_test(void)
|
||||
growParam.minVTypeTreeLen = 50; //mm
|
||||
|
||||
bool isHorizonScan = true; //true:激光线平行槽道;false:激光线垂直槽道
|
||||
double weldSeanRange = 100; //焊缝距钢筋交叉点的范围(最大值)
|
||||
SVzNLRangeD weldSeamRange;//焊缝距钢筋交叉点的范围
|
||||
if ((grp == 0) || (grp == 1))
|
||||
{
|
||||
weldSeamRange.min = rodParam.diameter / 2;
|
||||
weldSeamRange.max = 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
weldSeamRange.min = 0;
|
||||
weldSeamRange.max = 80;
|
||||
}
|
||||
int errCode = 0;
|
||||
std::vector<SSX_weldSeamInfo> weldSeamInfo;
|
||||
sx_rebarWeldSeamPositioning(
|
||||
@ -1704,7 +1714,7 @@ void rodWeldSeamPosition_test(void)
|
||||
filterParam,
|
||||
growParam,
|
||||
rodParam,
|
||||
weldSeanRange,
|
||||
weldSeamRange,
|
||||
weldSeamInfo,
|
||||
&errCode);
|
||||
long t2 = (long)GetTickCount64();
|
||||
|
||||
@ -779,11 +779,11 @@ SG_APISHARED_EXPORT void SG_TwoPassLabel(
|
||||
//计算面参数: z = Ax + By + C
|
||||
//res: [0]=A, [1]= B, [2]=-1.0, [3]=C,
|
||||
SG_APISHARED_EXPORT void vzCaculateLaserPlane(
|
||||
std::vector<cv::Point3f> Points3ds,
|
||||
std::vector<cv::Point3d> Points3ds,
|
||||
std::vector<double>& res);
|
||||
|
||||
SG_APISHARED_EXPORT Plane robustFitPlane(
|
||||
const std::vector<cv::Point3f>& points,
|
||||
const std::vector<cv::Point3d>& points,
|
||||
RobustType type = HUBER,
|
||||
double delta = 1.0, // 阈值:>此值视为离群点(mm)
|
||||
int maxIter = 20, // 迭代次数
|
||||
@ -793,8 +793,8 @@ SG_APISHARED_EXPORT Plane robustFitPlane(
|
||||
// 带 提前终止 的 RANSAC 平面拟合(工业正式版)
|
||||
// ==============================================
|
||||
SG_APISHARED_EXPORT Plane ransacFitPlane(
|
||||
const std::vector<cv::Point3f>& points,
|
||||
std::vector<cv::Point3f>& out_inliers,
|
||||
const std::vector<cv::Point3d>& points,
|
||||
std::vector<cv::Point3d>& out_inliers,
|
||||
float dist_thresh = 0.5f, // 内点距离阈值
|
||||
int max_iter = 1000, // 最大迭代
|
||||
int stop_no_improve = 150 // 连续多少次无提升就提前退出
|
||||
|
||||
@ -1489,7 +1489,7 @@ SSG_planeCalibPara sg_getPlaneCalibPara(
|
||||
topZRange.max = (float)postBtmIdx + zRange.min;
|
||||
|
||||
//取数据
|
||||
std::vector<cv::Point3f> Points3ds;
|
||||
std::vector<cv::Point3d> Points3ds;
|
||||
for (int line = 0; line < lineNum; line++)
|
||||
{
|
||||
for (int i = 0; i < laser3DPoints[line].nPositionCnt; i++)
|
||||
@ -1500,10 +1500,10 @@ SSG_planeCalibPara sg_getPlaneCalibPara(
|
||||
|
||||
if ((pt3D->pt3D.z >= topZRange.min) && (pt3D->pt3D.z <= topZRange.max))
|
||||
{
|
||||
cv::Point3f a_vldPt;
|
||||
a_vldPt.x = (float)pt3D->pt3D.x;
|
||||
a_vldPt.y = (float)pt3D->pt3D.y;
|
||||
a_vldPt.z = (float)pt3D->pt3D.z;
|
||||
cv::Point3d a_vldPt;
|
||||
a_vldPt.x = pt3D->pt3D.x;
|
||||
a_vldPt.y = pt3D->pt3D.y;
|
||||
a_vldPt.z = pt3D->pt3D.z;
|
||||
Points3ds.push_back(a_vldPt);
|
||||
}
|
||||
}
|
||||
@ -1867,7 +1867,7 @@ SSG_planeCalibPara sg_getPlaneCalibPara2(
|
||||
topZRange.max = (float)postBtmIdx + zRange.min;
|
||||
|
||||
//取数据
|
||||
std::vector<cv::Point3f> Points3ds;
|
||||
std::vector<cv::Point3d> Points3ds;
|
||||
for (int line = 0; line < lineNum; line++)
|
||||
{
|
||||
int nPositionCnt = (int)scanLines[line].size();
|
||||
@ -1879,10 +1879,10 @@ SSG_planeCalibPara sg_getPlaneCalibPara2(
|
||||
|
||||
if ((pt3D->pt3D.z >= topZRange.min) && (pt3D->pt3D.z <= topZRange.max))
|
||||
{
|
||||
cv::Point3f a_vldPt;
|
||||
a_vldPt.x = (float)pt3D->pt3D.x;
|
||||
a_vldPt.y = (float)pt3D->pt3D.y;
|
||||
a_vldPt.z = (float)pt3D->pt3D.z;
|
||||
cv::Point3d a_vldPt;
|
||||
a_vldPt.x = pt3D->pt3D.x;
|
||||
a_vldPt.y = pt3D->pt3D.y;
|
||||
a_vldPt.z = pt3D->pt3D.z;
|
||||
Points3ds.push_back(a_vldPt);
|
||||
}
|
||||
}
|
||||
@ -2024,7 +2024,7 @@ SSG_planeCalibPara sg_getHolePlaneCalibPara(
|
||||
}
|
||||
|
||||
//取数据
|
||||
std::vector<cv::Point3f> Points3ds;
|
||||
std::vector<cv::Point3d> Points3ds;
|
||||
for (int vline = 0; vline < (int)validLines.size(); vline++)
|
||||
{
|
||||
int line = validLines[vline];
|
||||
@ -2035,10 +2035,10 @@ SSG_planeCalibPara sg_getHolePlaneCalibPara(
|
||||
if (pt3D->pt3D.z < 1e-4)
|
||||
continue;
|
||||
|
||||
cv::Point3f a_vldPt;
|
||||
a_vldPt.x = (float)pt3D->pt3D.x;
|
||||
a_vldPt.y = (float)pt3D->pt3D.y;
|
||||
a_vldPt.z = (float)pt3D->pt3D.z;
|
||||
cv::Point3d a_vldPt;
|
||||
a_vldPt.x = pt3D->pt3D.x;
|
||||
a_vldPt.y = pt3D->pt3D.y;
|
||||
a_vldPt.z = pt3D->pt3D.z;
|
||||
Points3ds.push_back(a_vldPt);
|
||||
}
|
||||
}
|
||||
@ -2168,7 +2168,7 @@ SSG_planeCalibPara sg_HCameraVScan_getGroundCalibPara(
|
||||
lineSegPara.segGapTh_y = 5.0; //y方向间隔大于5mm认为是分段
|
||||
lineSegPara.segGapTh_z = 10.0; //z方向间隔大于10mm认为是分段
|
||||
|
||||
std::vector<cv::Point3f> groundPts;
|
||||
std::vector<cv::Point3d> groundPts;
|
||||
int lineNum = (int)scanLines.size();
|
||||
for (int line = 0; line < lineNum; line++)
|
||||
{
|
||||
@ -2205,7 +2205,7 @@ SSG_planeCalibPara sg_HCameraVScan_getGroundCalibPara(
|
||||
if (lineData[i].pt3D.z > 1e-4)
|
||||
{
|
||||
lineData[i].nPointIdx = 1;
|
||||
cv::Point3f a_pt = cv::Point3f(lineData[i].pt3D.x, lineData[i].pt3D.y, lineData[i].pt3D.z);
|
||||
cv::Point3d a_pt = cv::Point3d(lineData[i].pt3D.x, lineData[i].pt3D.y, lineData[i].pt3D.z);
|
||||
groundPts.push_back(a_pt);
|
||||
}
|
||||
}
|
||||
@ -2410,7 +2410,7 @@ SSG_planeCalibPara sg_getPlaneCalibPara2_ROI(
|
||||
|
||||
int lineNum = (int)scanLines.size();
|
||||
//取数据
|
||||
std::vector<cv::Point3f> Points3ds;
|
||||
std::vector<cv::Point3d> Points3ds;
|
||||
for (int line = 0; line < lineNum; line++)
|
||||
{
|
||||
int nPositionCnt = (int)scanLines[line].size();
|
||||
@ -2427,10 +2427,10 @@ SSG_planeCalibPara sg_getPlaneCalibPara2_ROI(
|
||||
(pt3D->pt3D.y >= roi.yRange.min) && (pt3D->pt3D.y <= roi.yRange.max) &&
|
||||
(pt3D->pt3D.z >= roi.zRange.min) && (pt3D->pt3D.y <= roi.zRange.max))
|
||||
{
|
||||
cv::Point3f a_vldPt;
|
||||
a_vldPt.x = (float)pt3D->pt3D.x;
|
||||
a_vldPt.y = (float)pt3D->pt3D.y;
|
||||
a_vldPt.z = (float)pt3D->pt3D.z;
|
||||
cv::Point3d a_vldPt;
|
||||
a_vldPt.x = pt3D->pt3D.x;
|
||||
a_vldPt.y = pt3D->pt3D.y;
|
||||
a_vldPt.z = pt3D->pt3D.z;
|
||||
Points3ds.push_back(a_vldPt);
|
||||
}
|
||||
}
|
||||
@ -2539,7 +2539,7 @@ SSG_planeCalibPara sg_getPlaneCalibPara_ROIs(
|
||||
planePara.planeHeight = -1.0;
|
||||
|
||||
//取数据
|
||||
std::vector<cv::Point3f> Points3ds;
|
||||
std::vector<cv::Point3d> Points3ds;
|
||||
for (int line = 0; line < lineNum; line++)
|
||||
{
|
||||
for (int i = 0; i < laser3DPoints[line].nPositionCnt; i++)
|
||||
@ -2563,10 +2563,10 @@ SSG_planeCalibPara sg_getPlaneCalibPara_ROIs(
|
||||
if (false == isValid)
|
||||
continue;
|
||||
|
||||
cv::Point3f a_vldPt;
|
||||
a_vldPt.x = (float)pt3D->pt3D.x;
|
||||
a_vldPt.y = (float)pt3D->pt3D.y;
|
||||
a_vldPt.z = (float)pt3D->pt3D.z;
|
||||
cv::Point3d a_vldPt;
|
||||
a_vldPt.x = pt3D->pt3D.x;
|
||||
a_vldPt.y = pt3D->pt3D.y;
|
||||
a_vldPt.z = pt3D->pt3D.z;
|
||||
Points3ds.push_back(a_vldPt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -464,7 +464,7 @@ bool leastSquareParabolaFitEigen(
|
||||
|
||||
//计算面参数: z = Ax + By + C
|
||||
//res: [0]=A, [1]= B, [2]=-1.0, [3]=C,
|
||||
void vzCaculateLaserPlane(std::vector<cv::Point3f> Points3ds, std::vector<double>& res)
|
||||
void vzCaculateLaserPlane(std::vector<cv::Point3d> Points3ds, std::vector<double>& res)
|
||||
{
|
||||
//最小二乘法拟合平面
|
||||
//获取cv::Mat的坐标系以纵向为x轴,横向为y轴,而cvPoint等则相反
|
||||
@ -568,14 +568,14 @@ bool fitLine3DLeastSquares(const std::vector<SVzNL3DPoint>& points, SVzNL3DPoint
|
||||
|
||||
// ============================== 工具函数 ==============================
|
||||
// 点到平面距离(带符号)
|
||||
double pointToPlaneSignedDist(const cv::Point3f& p, const Plane& plane) {
|
||||
double pointToPlaneSignedDist(const cv::Point3d& p, const Plane& plane) {
|
||||
return (plane.A * p.x + plane.B * p.y + plane.C * p.z + plane.D);
|
||||
}
|
||||
|
||||
// 点到平面的距离(绝对值)
|
||||
float pointToPlaneDistance(const cv::Point3f& p, const Plane& plane) {
|
||||
return fabsf(plane.A * p.x + plane.B * p.y + plane.C * p.z + plane.D)
|
||||
/ sqrtf(plane.A * plane.A + plane.B * plane.B + plane.C * plane.C);
|
||||
float pointToPlaneDistance(const cv::Point3d& p, const Plane& plane) {
|
||||
return fabs(plane.A * p.x + plane.B * p.y + plane.C * p.z + plane.D)
|
||||
/ sqrt(plane.A * plane.A + plane.B * plane.B + plane.C * plane.C);
|
||||
}
|
||||
|
||||
// 归一化平面(法向量模长=1)
|
||||
@ -606,7 +606,7 @@ double tukeyWeight(double r, double c) {
|
||||
|
||||
// ============================== 鲁棒加权最小二乘平面拟合 ==============================
|
||||
Plane robustFitPlane(
|
||||
const std::vector< cv::Point3f>& points,
|
||||
const std::vector< cv::Point3d>& points,
|
||||
RobustType type,
|
||||
double delta, // 阈值:>此值视为离群点(mm)
|
||||
int maxIter, // 迭代次数
|
||||
@ -733,21 +733,21 @@ Plane robustFitPlane(
|
||||
}
|
||||
|
||||
// 三点拟合平面
|
||||
Plane planeFrom3Points(const cv::Point3f& p1, const cv::Point3f& p2, const cv::Point3f& p3) {
|
||||
float v1x = p2.x - p1.x;
|
||||
float v1y = p2.y - p1.y;
|
||||
float v1z = p2.z - p1.z;
|
||||
Plane planeFrom3Points(const cv::Point3d& p1, const cv::Point3d& p2, const cv::Point3d& p3) {
|
||||
double v1x = p2.x - p1.x;
|
||||
double v1y = p2.y - p1.y;
|
||||
double v1z = p2.z - p1.z;
|
||||
|
||||
float v2x = p3.x - p1.x;
|
||||
float v2y = p3.y - p1.y;
|
||||
float v2z = p3.z - p1.z;
|
||||
double v2x = p3.x - p1.x;
|
||||
double v2y = p3.y - p1.y;
|
||||
double v2z = p3.z - p1.z;
|
||||
|
||||
float A = v1y * v2z - v1z * v2y;
|
||||
float B = v1z * v2x - v1x * v2z;
|
||||
float C = v1x * v2y - v1y * v2x;
|
||||
float D = -(A * p1.x + B * p1.y + C * p1.z);
|
||||
double A = v1y * v2z - v1z * v2y;
|
||||
double B = v1z * v2x - v1x * v2z;
|
||||
double C = v1x * v2y - v1y * v2x;
|
||||
double D = -(A * p1.x + B * p1.y + C * p1.z);
|
||||
|
||||
float norm = sqrtf(A * A + B * B + C * C);
|
||||
double norm = sqrtf(A * A + B * B + C * C);
|
||||
if (norm > 1e-6) { A /= norm; B /= norm; C /= norm; D /= norm; }
|
||||
return Plane(A, B, C, D);
|
||||
}
|
||||
@ -756,8 +756,8 @@ Plane planeFrom3Points(const cv::Point3f& p1, const cv::Point3f& p2, const cv::P
|
||||
// 带 提前终止 的 RANSAC 平面拟合(工业正式版)
|
||||
// ==============================================
|
||||
Plane ransacFitPlane(
|
||||
const std::vector<cv::Point3f>& points,
|
||||
std::vector<cv::Point3f>& out_inliers,
|
||||
const std::vector<cv::Point3d>& points,
|
||||
std::vector<cv::Point3d>& out_inliers,
|
||||
float dist_thresh, // 内点距离阈值
|
||||
int max_iter, // 最大迭代
|
||||
int stop_no_improve // 连续多少次无提升就提前退出
|
||||
|
||||
@ -25,7 +25,8 @@
|
||||
//version 1.3.2 : 矩森棒材抓取修正一个错误码返回错误,测试了地面调平API
|
||||
//version 1.3.3 : 筑裕钢筋焊缝提取算法改进中间版本
|
||||
//version 1.3.4 : 新的定位盘中心测量功能算法优化
|
||||
std::string m_strVersion = "1.3.4";
|
||||
//version 1.3.5 : 新的定位盘中心测量功能占将float运算改成double ,测试PC和3588差异
|
||||
std::string m_strVersion = "1.3.5";
|
||||
const char* wd_rodAndBarDetectionVersion(void)
|
||||
{
|
||||
return m_strVersion.c_str();
|
||||
@ -1446,11 +1447,11 @@ SSX_platePoseInfo sx_getLocationPlatePose(
|
||||
}
|
||||
|
||||
//拟合平面
|
||||
std::vector<cv::Point3f> Points3ds;
|
||||
std::vector<cv::Point3d> Points3ds;
|
||||
std::vector<SWD_polarPt> polarPoints;
|
||||
for (int i = 0; i < (int)objClusters[objIdx].size(); i++)
|
||||
{
|
||||
cv::Point3f a_pt = cv::Point3f(objClusters[objIdx][i].pt3D.x, objClusters[objIdx][i].pt3D.y, objClusters[objIdx][i].pt3D.z);
|
||||
cv::Point3d a_pt = cv::Point3d(objClusters[objIdx][i].pt3D.x, objClusters[objIdx][i].pt3D.y, objClusters[objIdx][i].pt3D.z);
|
||||
Points3ds.push_back(a_pt);
|
||||
SWD_polarPt a_polarPt;
|
||||
a_polarPt.lineIdx = objClusters[objIdx][i].nPointIdx >> 16;
|
||||
@ -1465,7 +1466,7 @@ SSX_platePoseInfo sx_getLocationPlatePose(
|
||||
//计算面参数: z = Ax + By + C
|
||||
//res: [0]=A, [1]= B, [2]=-1.0, [3]=C,
|
||||
#if 1
|
||||
std::vector<cv::Point3f> out_inliers;
|
||||
std::vector<cv::Point3d> out_inliers;
|
||||
Plane res = ransacFitPlane( Points3ds, out_inliers );
|
||||
if (res.C < 0)
|
||||
{
|
||||
@ -2184,16 +2185,16 @@ SSX_platePoseInfo sx_getLocationPlatePose_new(
|
||||
|
||||
|
||||
//拟合平面
|
||||
std::vector<cv::Point3f> Points3ds;
|
||||
std::vector<cv::Point3d> Points3ds;
|
||||
for (int i = 0; i < (int)topCluster.size(); i++)
|
||||
{
|
||||
cv::Point3f a_pt = cv::Point3f(topCluster[i].pt3D.x, topCluster[i].pt3D.y, topCluster[i].pt3D.z);
|
||||
cv::Point3d a_pt = cv::Point3d(topCluster[i].pt3D.x, topCluster[i].pt3D.y, topCluster[i].pt3D.z);
|
||||
Points3ds.push_back(a_pt);
|
||||
}
|
||||
//计算面参数: z = Ax + By + C
|
||||
//res: [0]=A, [1]= B, [2]=-1.0, [3]=C,
|
||||
#if 1
|
||||
std::vector<cv::Point3f> out_inliers;
|
||||
std::vector<cv::Point3d> out_inliers;
|
||||
Plane res = ransacFitPlane(Points3ds, out_inliers);
|
||||
if (res.C < 0)
|
||||
{
|
||||
@ -3494,7 +3495,7 @@ SSX_weldSeamInfo _computeWeldSeamInfo(
|
||||
return a_weldSeam;
|
||||
}
|
||||
|
||||
|
||||
//焊缝计算
|
||||
void _computeRebarWeldSeam(
|
||||
_RodLineInfo& vRod,
|
||||
SVzNL3DPoint& v_zDir,
|
||||
@ -3505,7 +3506,7 @@ void _computeRebarWeldSeam(
|
||||
std::vector< std::vector<SVzNL3DPosition>>& scanLines,
|
||||
const SSX_rodParam rodParam,
|
||||
const SSG_cornerParam weldPointCornerParam,
|
||||
const double weldSeanRange //焊缝距钢筋交叉点的范围(最大值)
|
||||
const SVzNLRangeD weldSeamRange //焊缝距钢筋交叉点的范围(最大值)
|
||||
)
|
||||
{
|
||||
int lineSize = (int)scanLines.size();
|
||||
@ -3513,8 +3514,8 @@ void _computeRebarWeldSeam(
|
||||
//提取范围内的值
|
||||
int position_1 = -1;
|
||||
int position_2 = -1;
|
||||
SWD3DPointPostion chkPt_1 = _computeGivenDistancePoint(vRod, crossPoint, crossPtIdx, rodParam.diameter/2, &position_1, searchDir_forward);
|
||||
SWD3DPointPostion chkPt_2 = _computeGivenDistancePoint(vRod, crossPoint, crossPtIdx, weldSeanRange, &position_2, searchDir_forward);
|
||||
SWD3DPointPostion chkPt_1 = _computeGivenDistancePoint(vRod, crossPoint, crossPtIdx, weldSeamRange.min, &position_1, searchDir_forward);
|
||||
SWD3DPointPostion chkPt_2 = _computeGivenDistancePoint(vRod, crossPoint, crossPtIdx, weldSeamRange.max, &position_2, searchDir_forward);
|
||||
if ((position_1 < 0) || (position_2 < 0))
|
||||
return;
|
||||
|
||||
@ -3620,6 +3621,7 @@ void _computeRebarWeldSeam(
|
||||
checkingData_1.push_back(a_line_1);
|
||||
checkingData_2.push_back(a_line_2);
|
||||
}
|
||||
|
||||
//宽度分析
|
||||
int dataLineSize = (int)checkingData_1.size();
|
||||
std::vector<double> lineW;
|
||||
@ -3705,6 +3707,248 @@ void _computeRebarWeldSeam(
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
SVzNLRangeD _computeZRange()
|
||||
{
|
||||
}
|
||||
|
||||
void _zHist()
|
||||
{
|
||||
}
|
||||
|
||||
void zSumHist()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//焊缝计算
|
||||
void _computeRebarWeldSeam_2(
|
||||
_RodLineInfo& vRod,
|
||||
SVzNL3DPoint& v_zDir,
|
||||
bool searchDir_forward,
|
||||
SVzNL3DPoint& crossPoint,
|
||||
int crossPtIdx,
|
||||
std::vector<SSX_weldSeamInfo>& rebarWeldSeam,
|
||||
std::vector< std::vector<SVzNL3DPosition>>& scanLines,
|
||||
const SSX_rodParam rodParam,
|
||||
const SSG_cornerParam weldPointCornerParam,
|
||||
const SVzNLRangeD weldSeamRange //焊缝距钢筋交叉点的范围(最大值)
|
||||
)
|
||||
{
|
||||
int lineSize = (int)scanLines.size();
|
||||
int linePtSize = (int)scanLines[0].size();
|
||||
//提取范围内的值
|
||||
int position_1 = -1;
|
||||
int position_2 = -1;
|
||||
SWD3DPointPostion chkPt_1 = _computeGivenDistancePoint(vRod, crossPoint, crossPtIdx, weldSeamRange.min, &position_1, searchDir_forward);
|
||||
SWD3DPointPostion chkPt_2 = _computeGivenDistancePoint(vRod, crossPoint, crossPtIdx, weldSeamRange.max, &position_2, searchDir_forward);
|
||||
if ((position_1 < 0) || (position_2 < 0))
|
||||
return;
|
||||
|
||||
std::vector<std::vector< SWD3DPointPostion>> checkingData_1; //从Peak向左或向上
|
||||
std::vector<std::vector< SWD3DPointPostion>> checkingData_2; //从peak向右或向下
|
||||
int startIdx = position_1 < position_2 ? position_1 : position_2;
|
||||
int endIdx = position_1 < position_2 ? position_2 : position_1;
|
||||
for (int i = startIdx; i <= endIdx; i++)
|
||||
{
|
||||
std::vector< SWD3DPointPostion> a_line_1;
|
||||
std::vector< SWD3DPointPostion> a_line_2;
|
||||
SWD3DPointPostion& refPt = vRod.linePts[i];
|
||||
if (vRod.lineType == 1) //垂直
|
||||
{
|
||||
int lineIdx = refPt.lineIdx;
|
||||
for (int j = refPt.ptIdx; j >= 0; j--)
|
||||
{
|
||||
SVzNL3DPosition& a_pt = scanLines[lineIdx][j];
|
||||
if (a_pt.pt3D.z > 1e-4)
|
||||
{
|
||||
double xyDist = sqrt(pow(a_pt.pt3D.x - refPt.point.x, 2) + pow(a_pt.pt3D.y - refPt.point.y, 2));
|
||||
double zDiff = abs(a_pt.pt3D.z - refPt.point.z);
|
||||
if (xyDist > rodParam.diameter * 1.5)
|
||||
break;
|
||||
if (zDiff < rodParam.diameter)
|
||||
{
|
||||
SWD3DPointPostion a_chkPt;
|
||||
a_chkPt.lineIdx = lineIdx;
|
||||
a_chkPt.ptIdx = j;
|
||||
a_chkPt.point = a_pt.pt3D;
|
||||
a_line_1.push_back(a_chkPt);
|
||||
}
|
||||
}
|
||||
}
|
||||
//向后
|
||||
for (int j = refPt.ptIdx; j < linePtSize; j++)
|
||||
{
|
||||
SVzNL3DPosition& a_pt = scanLines[lineIdx][j];
|
||||
if (a_pt.pt3D.z > 1e-4)
|
||||
{
|
||||
double xyDist = sqrt(pow(a_pt.pt3D.x - refPt.point.x, 2) + pow(a_pt.pt3D.y - refPt.point.y, 2));
|
||||
double zDiff = abs(a_pt.pt3D.z - refPt.point.z);
|
||||
if (xyDist > rodParam.diameter * 1.5)
|
||||
break;
|
||||
if (zDiff < rodParam.diameter)
|
||||
{
|
||||
SWD3DPointPostion a_chkPt;
|
||||
a_chkPt.lineIdx = lineIdx;
|
||||
a_chkPt.ptIdx = j;
|
||||
a_chkPt.point = a_pt.pt3D;
|
||||
a_line_2.push_back(a_chkPt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int ptIdx = refPt.ptIdx;
|
||||
for (int j = refPt.lineIdx; j >= 0; j--)
|
||||
{
|
||||
SVzNL3DPosition& a_pt = scanLines[j][ptIdx];
|
||||
if (a_pt.pt3D.z > 1e-4)
|
||||
{
|
||||
double xyDist = sqrt(pow(a_pt.pt3D.x - refPt.point.x, 2) + pow(a_pt.pt3D.y - refPt.point.y, 2));
|
||||
double zDiff = abs(a_pt.pt3D.z - refPt.point.z);
|
||||
if (xyDist > rodParam.diameter * 1.5)
|
||||
break;
|
||||
if (zDiff < rodParam.diameter)
|
||||
{
|
||||
SWD3DPointPostion a_chkPt;
|
||||
a_chkPt.lineIdx = j;
|
||||
a_chkPt.ptIdx = ptIdx;
|
||||
a_chkPt.point.x = a_pt.pt3D.y;
|
||||
a_chkPt.point.y = a_pt.pt3D.x;
|
||||
a_chkPt.point.z = a_pt.pt3D.z;
|
||||
a_line_1.push_back(a_chkPt);
|
||||
}
|
||||
}
|
||||
}
|
||||
//向后
|
||||
for (int j = refPt.lineIdx; j < lineSize; j++)
|
||||
{
|
||||
SVzNL3DPosition& a_pt = scanLines[j][ptIdx];
|
||||
if (a_pt.pt3D.z > 1e-4)
|
||||
{
|
||||
double xyDist = sqrt(pow(a_pt.pt3D.x - refPt.point.x, 2) + pow(a_pt.pt3D.y - refPt.point.y, 2));
|
||||
double zDiff = abs(a_pt.pt3D.z - refPt.point.z);
|
||||
if (xyDist > rodParam.diameter * 1.5)
|
||||
break;
|
||||
if (zDiff < rodParam.diameter)
|
||||
{
|
||||
SWD3DPointPostion a_chkPt;
|
||||
a_chkPt.lineIdx = j;
|
||||
a_chkPt.ptIdx = ptIdx;
|
||||
a_chkPt.point.x = a_pt.pt3D.y;
|
||||
a_chkPt.point.y = a_pt.pt3D.x;
|
||||
a_chkPt.point.z = a_pt.pt3D.z;
|
||||
a_line_2.push_back(a_chkPt);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
checkingData_1.push_back(a_line_1);
|
||||
checkingData_2.push_back(a_line_2);
|
||||
}
|
||||
|
||||
//zSlicea切割
|
||||
|
||||
|
||||
//内部参数
|
||||
const double maxDistTh = 2.0; //
|
||||
const int minSegSize = 5; //
|
||||
{
|
||||
std::vector<SSG_RUN> segs;
|
||||
wd_lineDataSegment_dist(data, segs, maxDistTh, minSegSize);
|
||||
if (segs.size() == 1) //检查拐点
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//宽度分析(需要替换成V型分析)
|
||||
int dataLineSize = (int)checkingData_1.size();
|
||||
std::vector<double> lineW;
|
||||
int seam_start = -1;
|
||||
int seam_end = -1;
|
||||
for (int i = 0; i < dataLineSize; i++)
|
||||
{
|
||||
double w;
|
||||
if ((checkingData_1[i].size() == 0) || (checkingData_2[i].size() == 0))
|
||||
w = -1;
|
||||
else
|
||||
w = checkingData_2[i].back().point.y - checkingData_1[i].back().point.y;
|
||||
|
||||
if (w > rodParam.diameter * 1.2)
|
||||
{
|
||||
if (seam_start < 0)
|
||||
seam_start = i;
|
||||
seam_end = i;
|
||||
}
|
||||
lineW.push_back(w);
|
||||
}
|
||||
//焊缝分析
|
||||
double segment_maxDistTh = 2.0;
|
||||
std::vector<SSX_weldSlice> seamData_1;
|
||||
std::vector<SSX_weldSlice> seamData_2;
|
||||
for (int i = seam_start; i <= seam_end; i++)
|
||||
{
|
||||
|
||||
SSX_weldSlice a_slice_1 = _computeWeldSliceInfo(
|
||||
checkingData_1[i],
|
||||
rodParam,
|
||||
weldPointCornerParam,
|
||||
segment_maxDistTh,
|
||||
false
|
||||
);
|
||||
if (KeWD_WELD_UNKNOWN != a_slice_1.type)
|
||||
seamData_1.push_back(a_slice_1);
|
||||
|
||||
SSX_weldSlice a_slice_2 = _computeWeldSliceInfo(
|
||||
checkingData_2[i],
|
||||
rodParam,
|
||||
weldPointCornerParam,
|
||||
segment_maxDistTh,
|
||||
true
|
||||
);
|
||||
if (KeWD_WELD_UNKNOWN != a_slice_2.type)
|
||||
seamData_2.push_back(a_slice_2);
|
||||
|
||||
}
|
||||
|
||||
//生成焊缝信息
|
||||
if (seamData_1.size() > 10)
|
||||
{
|
||||
double rotateAngle = vRod.lineType == 1 ? -45.0 : 45.0;
|
||||
SSX_weldSeamInfo a_weldSeam = _computeWeldSeamInfo(seamData_1, vRod.lineType, weldPointCornerParam, v_zDir, rotateAngle);
|
||||
rebarWeldSeam.push_back(a_weldSeam);
|
||||
//置标志,用于debug
|
||||
for (int i = 0; i < (int)seamData_1.size(); i++)
|
||||
{
|
||||
int lineIdx = seamData_1[i].startPt.lineIdx;
|
||||
int ptIdx = seamData_1[i].startPt.ptIdx;
|
||||
scanLines[lineIdx][ptIdx].nPointIdx |= 0x40;
|
||||
lineIdx = seamData_1[i].endPt.lineIdx;
|
||||
ptIdx = seamData_1[i].endPt.ptIdx;
|
||||
scanLines[lineIdx][ptIdx].nPointIdx |= 0x40;
|
||||
}
|
||||
}
|
||||
if (seamData_2.size() > 10)
|
||||
{
|
||||
double rotateAngle = vRod.lineType == 1 ? 45.0 : -45.0;
|
||||
SSX_weldSeamInfo a_weldSeam = _computeWeldSeamInfo(seamData_2, vRod.lineType, weldPointCornerParam, v_zDir, rotateAngle);
|
||||
rebarWeldSeam.push_back(a_weldSeam);
|
||||
//置标志,用于debug
|
||||
for (int i = 0; i < (int)seamData_2.size(); i++)
|
||||
{
|
||||
int lineIdx = seamData_2[i].startPt.lineIdx;
|
||||
int ptIdx = seamData_2[i].startPt.ptIdx;
|
||||
scanLines[lineIdx][ptIdx].nPointIdx |= 0x40;
|
||||
lineIdx = seamData_2[i].endPt.lineIdx;
|
||||
ptIdx = seamData_2[i].endPt.ptIdx;
|
||||
scanLines[lineIdx][ptIdx].nPointIdx |= 0x40;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//筑裕钢结构钢筋焊缝定位
|
||||
void sx_rebarWeldSeamPositioning(
|
||||
std::vector< std::vector<SVzNL3DPosition>>& scanLines,
|
||||
@ -3713,7 +3957,7 @@ void sx_rebarWeldSeamPositioning(
|
||||
const SSG_outlierFilterParam filterParam,
|
||||
const SSG_treeGrowParam growParam,
|
||||
const SSX_rodParam rodParam,
|
||||
const double weldSeanRange, //焊缝距钢筋交叉点的范围(最大值)
|
||||
const SVzNLRangeD weldSeamRange, //焊缝距钢筋交叉点的范围(最小值和最大值)
|
||||
std::vector<SSX_weldSeamInfo>& weldSeamInfo,
|
||||
int* errCode)
|
||||
{
|
||||
@ -4090,7 +4334,7 @@ void sx_rebarWeldSeamPositioning(
|
||||
scanLines,
|
||||
rodParam,
|
||||
weldPointCornerParam,
|
||||
weldSeanRange //焊缝距钢筋交叉点的范围(最大值)
|
||||
weldSeamRange //焊缝距钢筋交叉点的范围(最大值)
|
||||
);
|
||||
weldSeamInfo.insert(weldSeamInfo.end(), a_rebarWeldSeam.begin(), a_rebarWeldSeam.end());
|
||||
}
|
||||
@ -4126,7 +4370,7 @@ void sx_rebarWeldSeamPositioning(
|
||||
scanLines,
|
||||
rodParam,
|
||||
weldPointCornerParam,
|
||||
weldSeanRange //焊缝距钢筋交叉点的范围(最大值)
|
||||
weldSeamRange //焊缝距钢筋交叉点的范围(最大值)
|
||||
);
|
||||
weldSeamInfo.insert(weldSeamInfo.end(), a_rebarWeldSeam_0.begin(), a_rebarWeldSeam_0.end());
|
||||
//另一个方向
|
||||
@ -4141,7 +4385,7 @@ void sx_rebarWeldSeamPositioning(
|
||||
scanLines,
|
||||
rodParam,
|
||||
weldPointCornerParam,
|
||||
weldSeanRange //焊缝距钢筋交叉点的范围(最大值)
|
||||
weldSeamRange //焊缝距钢筋交叉点的范围(最大值)
|
||||
);
|
||||
weldSeamInfo.insert(weldSeamInfo.end(), a_rebarWeldSeam_1.begin(), a_rebarWeldSeam_1.end());
|
||||
}
|
||||
|
||||
@ -115,6 +115,6 @@ SG_APISHARED_EXPORT void sx_rebarWeldSeamPositioning(
|
||||
const SSG_outlierFilterParam filterParam,
|
||||
const SSG_treeGrowParam growParam,
|
||||
const SSX_rodParam rodParam,
|
||||
const double weldSeanRange, //焊缝距钢筋交叉点的范围(最大值)
|
||||
const SVzNLRangeD weldSeamRange, //焊缝距钢筋交叉点的范围(最小值和最大值)
|
||||
std::vector<SSX_weldSeamInfo>& weldSeamInfo,
|
||||
int* errCode);
|
||||
Loading…
x
Reference in New Issue
Block a user