From 5d95855e2ad33bbff22996892f37d05dae2d7f2e Mon Sep 17 00:00:00 2001 From: jerryzeng Date: Sat, 6 Jun 2026 21:51:01 +0800 Subject: [PATCH] =?UTF-8?q?rodAndBarDetection=20version=201.3.5=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=E5=8D=A0=E5=B0=86float?= =?UTF-8?q?=E8=BF=90=E7=AE=97=E6=94=B9=E6=88=90double=20,=E6=B5=8B?= =?UTF-8?q?=E8=AF=95PC=E5=92=8C3588=E5=B7=AE=E5=BC=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rodAndBarDetection_test.cpp | 16 +- sourceCode/SG_baseAlgo_Export.h | 8 +- sourceCode/SG_baseFunc.cpp | 54 ++-- sourceCode/dataFitting.cpp | 40 +-- sourceCode/rodAndBarDetection.cpp | 274 +++++++++++++++++- sourceCode/rodAndBarDetection_Export.h | 2 +- 6 files changed, 324 insertions(+), 70 deletions(-) diff --git a/rodAndBarDetection_test/rodAndBarDetection_test.cpp b/rodAndBarDetection_test/rodAndBarDetection_test.cpp index 5168afa..03fde37 100644 --- a/rodAndBarDetection_test/rodAndBarDetection_test.cpp +++ b/rodAndBarDetection_test/rodAndBarDetection_test.cpp @@ -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 weldSeamInfo; sx_rebarWeldSeamPositioning( @@ -1704,7 +1714,7 @@ void rodWeldSeamPosition_test(void) filterParam, growParam, rodParam, - weldSeanRange, + weldSeamRange, weldSeamInfo, &errCode); long t2 = (long)GetTickCount64(); diff --git a/sourceCode/SG_baseAlgo_Export.h b/sourceCode/SG_baseAlgo_Export.h index 74221ca..89b6185 100644 --- a/sourceCode/SG_baseAlgo_Export.h +++ b/sourceCode/SG_baseAlgo_Export.h @@ -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 Points3ds, + std::vector Points3ds, std::vector& res); SG_APISHARED_EXPORT Plane robustFitPlane( - const std::vector& points, + const std::vector& 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& points, - std::vector& out_inliers, + const std::vector& points, + std::vector& out_inliers, float dist_thresh = 0.5f, // ڵֵ int max_iter = 1000, // int stop_no_improve = 150 // ٴǰ˳ diff --git a/sourceCode/SG_baseFunc.cpp b/sourceCode/SG_baseFunc.cpp index b0bb178..c6a7643 100644 --- a/sourceCode/SG_baseFunc.cpp +++ b/sourceCode/SG_baseFunc.cpp @@ -1489,7 +1489,7 @@ SSG_planeCalibPara sg_getPlaneCalibPara( topZRange.max = (float)postBtmIdx + zRange.min; //ȡ - std::vector Points3ds; + std::vector 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 Points3ds; + std::vector 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 Points3ds; + std::vector 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; //y5mmΪǷֶ lineSegPara.segGapTh_z = 10.0; //z10mmΪǷֶ - std::vector groundPts; + std::vector 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 Points3ds; + std::vector 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 Points3ds; + std::vector 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); } } diff --git a/sourceCode/dataFitting.cpp b/sourceCode/dataFitting.cpp index be40cfd..a736b9e 100644 --- a/sourceCode/dataFitting.cpp +++ b/sourceCode/dataFitting.cpp @@ -464,7 +464,7 @@ bool leastSquareParabolaFitEigen( //: z = Ax + By + C //res: [0]=A, [1]= B, [2]=-1.0, [3]=C, -void vzCaculateLaserPlane(std::vector Points3ds, std::vector& res) +void vzCaculateLaserPlane(std::vector Points3ds, std::vector& res) { //С˷ƽ //ȡcv::MatϵΪxᣬΪyᣬcvPoint෴ @@ -568,14 +568,14 @@ bool fitLine3DLeastSquares(const std::vector& 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& points, - std::vector& out_inliers, + const std::vector& points, + std::vector& out_inliers, float dist_thresh, // ڵֵ int max_iter, // int stop_no_improve // ٴǰ˳ diff --git a/sourceCode/rodAndBarDetection.cpp b/sourceCode/rodAndBarDetection.cpp index c6b1f25..b0bd92e 100644 --- a/sourceCode/rodAndBarDetection.cpp +++ b/sourceCode/rodAndBarDetection.cpp @@ -25,7 +25,8 @@ //version 1.3.2 : ɭץȡһ뷵ش󣬲˵ƽAPI //version 1.3.3 : ԣֽȡ㷨Ľм汾 //version 1.3.4 : µĶλIJ㷨Ż -std::string m_strVersion = "1.3.4"; +//version 1.3.5 : µĶλIJռfloatijdouble ,PC3588 +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 Points3ds; + std::vector Points3ds; std::vector 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 out_inliers; + std::vector out_inliers; Plane res = ransacFitPlane( Points3ds, out_inliers ); if (res.C < 0) { @@ -2184,16 +2185,16 @@ SSX_platePoseInfo sx_getLocationPlatePose_new( //ƽ - std::vector Points3ds; + std::vector 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 out_inliers; + std::vector 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>& 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 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& rebarWeldSeam, + std::vector< std::vector>& 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> checkingData_1; //Peak + std::vector> 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 segs; + wd_lineDataSegment_dist(data, segs, maxDistTh, minSegSize); + if (segs.size() == 1) //յ + { + + } + + + //ȷ(Ҫ滻Vͷ) + int dataLineSize = (int)checkingData_1.size(); + std::vector 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 seamData_1; + std::vector 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>& 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& 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()); } diff --git a/sourceCode/rodAndBarDetection_Export.h b/sourceCode/rodAndBarDetection_Export.h index 139d604..56251a0 100644 --- a/sourceCode/rodAndBarDetection_Export.h +++ b/sourceCode/rodAndBarDetection_Export.h @@ -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& weldSeamInfo, int* errCode); \ No newline at end of file