diff --git a/App/WeldSeam/WeldSeamApp/Presenter/Inc/DetectPresenter.h b/App/WeldSeam/WeldSeamApp/Presenter/Inc/DetectPresenter.h index e04e9e7d..cf50780e 100644 --- a/App/WeldSeam/WeldSeamApp/Presenter/Inc/DetectPresenter.h +++ b/App/WeldSeam/WeldSeamApp/Presenter/Inc/DetectPresenter.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include @@ -16,6 +17,14 @@ public: DetectPresenter(); static QString GetAlgoVersion(); + void ResetIncrementalData(); + bool ProcessDetectionLine(EVzResultDataType dataType, + const SVzLaserLineData& lineData, + const VrAlgorithmParams& algorithmParams, + const SSG_planeCalibPara& groundCalibParam, + LaserDataLoader& dataLoader); + bool HasIncrementalData() const; + int DetectWeldSeam( int cameraIndex, std::vector>& laserLines, @@ -24,4 +33,9 @@ public: const VrDebugParam& debugParam, LaserDataLoader& dataLoader, DetectionResult& detectionResult); + +private: + mutable std::mutex m_incrementalMutex; + std::vector> m_incrementalScanLines; + std::vector> m_incrementalLineValleys; }; diff --git a/App/WeldSeam/WeldSeamApp/Presenter/Inc/WeldSeamPresenter.h b/App/WeldSeam/WeldSeamApp/Presenter/Inc/WeldSeamPresenter.h index dcf5f0fc..51359b76 100644 --- a/App/WeldSeam/WeldSeamApp/Presenter/Inc/WeldSeamPresenter.h +++ b/App/WeldSeam/WeldSeamApp/Presenter/Inc/WeldSeamPresenter.h @@ -58,6 +58,10 @@ protected: int InitAlgoParams() override; int ProcessAlgoDetection( std::vector>& detectionDataCache) override; + bool OnDetectionData(EVzResultDataType dataType, + SVzLaserLineData* laserData) override; + bool HasPendingDetectionData() const override; + void ClearDetectionDataCache() override; EVzResultDataType GetDetectionDataType() override { return keResultDataType_Position; } VzNL_OnNotifyStatusCBEx GetCameraStatusCallback() override; void OnCameraStatusChanged(int cameraIndex, bool isConnected) override; diff --git a/App/WeldSeam/WeldSeamApp/Presenter/Src/DetectPresenter.cpp b/App/WeldSeam/WeldSeamApp/Presenter/Src/DetectPresenter.cpp index 0fcc739e..7eec23ec 100644 --- a/App/WeldSeam/WeldSeamApp/Presenter/Src/DetectPresenter.cpp +++ b/App/WeldSeam/WeldSeamApp/Presenter/Src/DetectPresenter.cpp @@ -2,6 +2,7 @@ #include "AlgorithmParamConverter.h" #include "PointCloudImageUtils.h" +#include "SG_baseAlgo_Export.h" #include "SX_lapWeldDetection_Export.h" #include "VrDateUtils.h" #include "VrError.h" @@ -13,19 +14,6 @@ #include #include -SG_APISHARED_EXPORT void wd_getLineVFlaws( - std::vector& line, - int lineIndex, - SWD_valleyParam valleyParam, - std::vector& valleys); - -SG_APISHARED_EXPORT void sg_lineGapsGrowing( - int lineIndex, - bool isLastLine, - std::vector& features, - std::vector& trees, - SSG_treeGrowParam growParam); - namespace { int ValidPointCount(const std::vector& line) @@ -105,6 +93,49 @@ DetectPresenter::DetectPresenter() LOG_INFO("lapWeldDetection version: %s\n", wd_weldSeamAlgoVersion()); } +void DetectPresenter::ResetIncrementalData() +{ + std::lock_guard lock(m_incrementalMutex); + m_incrementalScanLines.clear(); + m_incrementalLineValleys.clear(); +} + +bool DetectPresenter::HasIncrementalData() const +{ + std::lock_guard lock(m_incrementalMutex); + return !m_incrementalScanLines.empty(); +} + +bool DetectPresenter::ProcessDetectionLine( + EVzResultDataType dataType, + const SVzLaserLineData& lineData, + const VrAlgorithmParams& algorithmParams, + const SSG_planeCalibPara& groundCalibParam, + LaserDataLoader& dataLoader) +{ + std::vector> oneLine; + oneLine.emplace_back(dataType, lineData); + std::vector> converted; + if (dataLoader.ConvertToSVzNL3DPosition(oneLine, converted) != SUCCESS || + converted.empty() || converted.front().empty() || + ValidPointCount(converted.front()) == 0) { + return false; + } + + std::vector scanLine = std::move(converted.front()); + sx_lineDataR(scanLine, groundCalibParam.planeCalib, -1.0); + const WeldSeamAlgorithmParams params = + AlgorithmParamConverter::ToAlgorithmParams(algorithmParams); + std::vector valleys; + std::lock_guard lock(m_incrementalMutex); + const int lineIndex = static_cast(m_incrementalScanLines.size()); + wd_getLineVFlaws(scanLine, lineIndex, params.valleyParam, + params.detectFlawType, valleys); + m_incrementalScanLines.push_back(std::move(scanLine)); + m_incrementalLineValleys.push_back(std::move(valleys)); + return true; +} + QString DetectPresenter::GetAlgoVersion() { return QString::fromUtf8(wd_weldSeamAlgoVersion()); @@ -119,17 +150,24 @@ int DetectPresenter::DetectWeldSeam( LaserDataLoader& dataLoader, DetectionResult& detectionResult) { - if (laserLines.empty()) { - detectionResult.message = QStringLiteral("扫æ��æ•°æ�®ä¸ºç©º"); - return ERR_CODE(DEV_DATA_INVALID); - } - std::vector> scanLines; - const int convertResult = dataLoader.ConvertToSVzNL3DPosition(laserLines, scanLines); - RemoveEmptyEdgeLines(scanLines); - if (convertResult != SUCCESS || scanLines.empty()) { - detectionResult.message = QStringLiteral("扫æ��æ•°æ�®è½¬æ�¢å¤±è´¥"); - return ERR_CODE(DEV_DATA_INVALID); + std::vector> preprocessedValleys; + const bool useIncrementalData = HasIncrementalData(); + if (useIncrementalData) { + std::lock_guard lock(m_incrementalMutex); + scanLines = m_incrementalScanLines; + preprocessedValleys = m_incrementalLineValleys; + if (scanLines.empty() || scanLines.size() != preprocessedValleys.size()) { + detectionResult.message = QStringLiteral("扫æ��æ•°æ�®ä¸ºç©º"); + return ERR_CODE(DEV_DATA_INVALID); + } + } else { + const int convertResult = dataLoader.ConvertToSVzNL3DPosition(laserLines, scanLines); + RemoveEmptyEdgeLines(scanLines); + if (convertResult != SUCCESS || scanLines.empty()) { + detectionResult.message = QStringLiteral("扫æ��æ•°æ�®è½¬æ�¢å¤±è´¥"); + return ERR_CODE(DEV_DATA_INVALID); + } } const WeldSeamAlgorithmParams params = AlgorithmParamConverter::ToAlgorithmParams(algorithmParams); @@ -157,16 +195,22 @@ int DetectPresenter::DetectWeldSeam( } CVrTimeUtils timer; - for (auto& line : scanLines) { - sx_lineDataR(line, groundCalibParam.planeCalib, -1.0); + if (!useIncrementalData) { + for (auto& line : scanLines) { + sx_lineDataR(line, groundCalibParam.planeCalib, -1.0); + } } std::vector trees; trees.reserve(scanLines.size()); for (size_t lineIndex = 0; lineIndex < scanLines.size(); ++lineIndex) { std::vector lineValleys; - wd_getLineVFlaws(scanLines[lineIndex], static_cast(lineIndex), - params.valleyParam, lineValleys); + if (useIncrementalData) { + lineValleys = preprocessedValleys[lineIndex]; + } else { + wd_getLineVFlaws(scanLines[lineIndex], static_cast(lineIndex), + params.valleyParam, params.detectFlawType, lineValleys); + } const bool isLastLine = lineIndex + 1 == scanLines.size(); sg_lineGapsGrowing(static_cast(lineIndex), isLastLine, lineValleys, trees, params.treeGrowParam); diff --git a/App/WeldSeam/WeldSeamApp/Presenter/Src/WeldSeamPresenter.cpp b/App/WeldSeam/WeldSeamApp/Presenter/Src/WeldSeamPresenter.cpp index da927d8a..39f7a5ba 100644 --- a/App/WeldSeam/WeldSeamApp/Presenter/Src/WeldSeamPresenter.cpp +++ b/App/WeldSeam/WeldSeamApp/Presenter/Src/WeldSeamPresenter.cpp @@ -85,6 +85,8 @@ int WeldSeamPresenter::InitAlgoParams() p.treeGrowParam.maxLineSkipNum, p.treeGrowParam.yDeviationMax, p.treeGrowParam.maxSkipDistance, p.treeGrowParam.zDeviationMax, p.treeGrowParam.minLTypeTreeLen, p.treeGrowParam.minVTypeTreeLen); + LOG_INFO("WeldSeam flaw type=%d\n", + static_cast(p.weldSeamParam.detectFlawType)); return SUCCESS; } @@ -179,7 +181,7 @@ QString WeldSeamPresenter::StopDynamicScanAndDetect() // StopDetect æˆ�功å�Žæ‰�检查缓存。空扫æ��ä»�属于已å�—ç�†çš„ STOP 请求: // 先让调用方返回 STOP_ACK,å†�在 Presenter 线程异步å�‘布 RESULT_NG。 - if (GetDetectionDataCacheSize() <= 0) { + if (!HasPendingDetectionData()) { UpdateModbusStatus(2); OnStatusUpdate("动æ€�扫æ��已结æ�Ÿï¼Œæœªé‡‡é›†åˆ°æœ‰æ•ˆæ•°æ�®"); QMetaObject::invokeMethod(this, [this]() { @@ -240,6 +242,13 @@ int WeldSeamPresenter::ProcessAlgoDetection( int code = ERR_CODE(DEV_NOT_FIND); if (m_pDetectPresenter && m_pConfigManager) { const ConfigResult config = m_pConfigManager->GetConfigResult(); + // Live WeldSeam scans are preprocessed line-by-line. The base cache is + // only populated in debug mode for persistence, so release that copy + // before asking DetectPresenter to consume its incremental data. + if (m_pDetectPresenter->HasIncrementalData() && !detectionDataCache.empty()) { + m_dataLoader.FreeLaserScanData(detectionDataCache); + detectionDataCache.clear(); + } code = m_pDetectPresenter->DetectWeldSeam( m_currentCameraIndex, detectionDataCache, config.algorithmParams, GetCameraCalibParam(m_currentCameraIndex), config.debugParam, m_dataLoader, result); @@ -264,6 +273,39 @@ int WeldSeamPresenter::ProcessAlgoDetection( return code; } +bool WeldSeamPresenter::OnDetectionData(EVzResultDataType dataType, + SVzLaserLineData* laserData) +{ + if (!laserData || !m_pDetectPresenter || !m_pConfigManager || + dataType != keResultDataType_Position) { + return false; + } + + const ConfigResult config = m_pConfigManager->GetConfigResult(); + const bool processed = m_pDetectPresenter->ProcessDetectionLine( + dataType, *laserData, config.algorithmParams, + GetCameraCalibParam(m_currentCameraIndex), m_dataLoader); + if (!processed) { + LOG_WARNING("WeldSeam failed to preprocess one point-cloud line\n"); + return true; + } + + // Keep the original line only when debug persistence is enabled. In the + // normal path BasePresenter immediately drops its temporary callback data. + return !config.debugParam.enableDebug; +} + +bool WeldSeamPresenter::HasPendingDetectionData() const +{ + return m_pDetectPresenter && m_pDetectPresenter->HasIncrementalData(); +} + +void WeldSeamPresenter::ClearDetectionDataCache() +{ + BasePresenter::ClearDetectionDataCache(); + if (m_pDetectPresenter) m_pDetectPresenter->ResetIncrementalData(); +} + int WeldSeamPresenter::LoadAndDetect(const QString& fileName) { ScanState expected = ScanState::Ready; diff --git a/App/WeldSeam/WeldSeamApp/Version.h b/App/WeldSeam/WeldSeamApp/Version.h index 3b9b49a2..5855d1e3 100644 --- a/App/WeldSeam/WeldSeamApp/Version.h +++ b/App/WeldSeam/WeldSeamApp/Version.h @@ -2,7 +2,7 @@ #define WELDSEAM_VERSION_H #define WELDSEAM_APP_NAME "焊ç¼�定ä½�" -#define WELDSEAM_VERSION_STRING "1.0.0" +#define WELDSEAM_VERSION_STRING "1.0.1" #define WELDSEAM_BUILD_STRING "1" #define WELDSEAM_FULL_VERSION_STRING "V" WELDSEAM_VERSION_STRING "_" WELDSEAM_BUILD_STRING diff --git a/App/WeldSeam/WeldSeamApp/Version.md b/App/WeldSeam/WeldSeamApp/Version.md index f8a16d33..858aaa3c 100644 --- a/App/WeldSeam/WeldSeamApp/Version.md +++ b/App/WeldSeam/WeldSeamApp/Version.md @@ -1,6 +1,8 @@ -# WeldSeam 版本记录 +# 1.0.1 +## build_1 +1. 更新算法版本,增加了焊ç¼�类型 -## 1.0.0 +# 1.0.0 - 使用 VzNLSDK é�žæ‘†åŠ¨åŠ¨æ€�扫æ��模å¼�。 - 实现 `START_SCAN` / `STOP_SCAN` TCP 交互æµ�程。 diff --git a/App/WeldSeam/WeldSeamApp/WeldSeamApp.pro b/App/WeldSeam/WeldSeamApp/WeldSeamApp.pro index 74789cc0..85e2303b 100644 --- a/App/WeldSeam/WeldSeamApp/WeldSeamApp.pro +++ b/App/WeldSeam/WeldSeamApp/WeldSeamApp.pro @@ -4,7 +4,8 @@ QT += core gui network serialport greaterThan(QT_MAJOR_VERSION, 4): QT += widgets -CONFIG += c++17 +# OpenCV 3.2 still uses std::random_shuffle, which was removed in C++17. +CONFIG += c++14 # 项目å��ç§° TARGET = WeldSeamApp @@ -148,6 +149,8 @@ else:unix:!macx: { # 焊ç¼�检测算法(lapWeldDetection) INCLUDEPATH += ../../../AppAlgo/lapWeldDetection/Inc +# OpenCV 3.2 headers required by SG_baseAlgo_Export.h +INCLUDEPATH += $$PWD/../../../SDK/OpenCV320/include win32:CONFIG(release, debug|release): { LIBS += -L$$PWD/../../../AppAlgo/lapWeldDetection/Windows/x64/Release -llapWeldDetection -lbaseAlgorithm diff --git a/App/WeldSeam/WeldSeamApp/dialogalgoarg.cpp b/App/WeldSeam/WeldSeamApp/dialogalgoarg.cpp index b93ba6ea..df8f472f 100644 --- a/App/WeldSeam/WeldSeamApp/dialogalgoarg.cpp +++ b/App/WeldSeam/WeldSeamApp/dialogalgoarg.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,10 @@ DialogAlgoArg::DialogAlgoArg(QWidget* parent) { ui->setupUi(this); setWindowTitle(QStringLiteral("焊ç¼�定ä½� - 算法å�‚数设置")); + ui->comboDetectFlawType->addItem(QStringLiteral("未知/全部"), 0); + ui->comboDetectFlawType->addItem(QStringLiteral("凹陷"), 1); + ui->comboDetectFlawType->addItem(QStringLiteral("凸起"), 2); + ui->comboDetectFlawType->addItem(QStringLiteral("凹陷+凸起"), 3); InitNumericEditors(); InitCommunicationWidgets(); } @@ -149,6 +154,9 @@ void DialogAlgoArg::Load() SetDoubleText(ui->editMinLTypeTreeLen, p.treeGrowParam.minLTypeTreeLen); SetDoubleText(ui->editMinVTypeTreeLen, p.treeGrowParam.minVTypeTreeLen); SetIntText(ui->editWeldRefPoints, p.weldSeamParam.weldRefPoints); + const int flawType = static_cast(p.weldSeamParam.detectFlawType); + const int flawTypeIndex = ui->comboDetectFlawType->findData(flawType); + ui->comboDetectFlawType->setCurrentIndex(flawTypeIndex >= 0 ? flawTypeIndex : 0); SetIntText(ui->editTcpPort, config.tcpPort); LoadCommunicationConfig(); } @@ -225,6 +233,14 @@ bool DialogAlgoArg::Save() p.treeGrowParam.minVTypeTreeLen)) return false; if (!TryGetInt(ui->editWeldRefPoints, QStringLiteral("焊ç¼�中间å�‚考点数"), p.weldSeamParam.weldRefPoints)) return false; + const int flawType = ui->comboDetectFlawType->currentData().toInt(); + if (flawType < static_cast(keWD_FlawType_Uknown) || + flawType > static_cast(keSG_FlawType_Dep_Prot)) { + StyledMessageBox::warning(this, QStringLiteral("å�‚数错误"), + QStringLiteral("焊ç¼�类型无效。")); + return false; + } + p.weldSeamParam.detectFlawType = static_cast(flawType); int tcpPort = 0; if (!TryGetInt(ui->editTcpPort, QStringLiteral("TCP æœ�务端å�£"), tcpPort)) return false; diff --git a/App/WeldSeam/WeldSeamApp/dialogalgoarg.ui b/App/WeldSeam/WeldSeamApp/dialogalgoarg.ui index 6043bc15..4fd1a031 100644 --- a/App/WeldSeam/WeldSeamApp/dialogalgoarg.ui +++ b/App/WeldSeam/WeldSeamApp/dialogalgoarg.ui @@ -140,6 +140,23 @@ QGroupBox::title { subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px; + + + + 焊ç¼�类型: + + + + + + + + 200 + 35 + + + + diff --git a/App/WeldSeam/WeldSeamConfig/Inc/AlgorithmParamConverter.h b/App/WeldSeam/WeldSeamConfig/Inc/AlgorithmParamConverter.h index 1396110c..99e4e035 100644 --- a/App/WeldSeam/WeldSeamConfig/Inc/AlgorithmParamConverter.h +++ b/App/WeldSeam/WeldSeamConfig/Inc/AlgorithmParamConverter.h @@ -9,6 +9,7 @@ struct WeldSeamAlgorithmParams SWD_valleyParam valleyParam{}; SSG_treeGrowParam treeGrowParam{}; int weldRefPoints = 3; + EWD_FlawType detectFlawType = keWD_FlawType_Uknown; }; class AlgorithmParamConverter diff --git a/App/WeldSeam/WeldSeamConfig/Inc/IVrConfig.h b/App/WeldSeam/WeldSeamConfig/Inc/IVrConfig.h index b88b9a4a..9b69ab5b 100644 --- a/App/WeldSeam/WeldSeamConfig/Inc/IVrConfig.h +++ b/App/WeldSeam/WeldSeamConfig/Inc/IVrConfig.h @@ -7,6 +7,7 @@ #include "VrCommonConfig.h" #include "VrHandEyeCalibConfig.h" +#include "SG_baseDataType.h" // å�‚数默认值与 AppAlgo/lapWeldDetection/lapWeldDetection_test.cpp // 中 BQ_thinWeldSeamTest çš„ BQ_getWeldSeamPose 调用ä¿�æŒ�一致。 @@ -30,6 +31,7 @@ struct VrTreeGrowParam struct VrWeldSeamParam { int weldRefPoints = 3; + EWD_FlawType detectFlawType = keWD_FlawType_Uknown; }; struct VrAlgorithmParams diff --git a/App/WeldSeam/WeldSeamConfig/Src/AlgorithmParamConverter.cpp b/App/WeldSeam/WeldSeamConfig/Src/AlgorithmParamConverter.cpp index 46b6e3bb..713718c1 100644 --- a/App/WeldSeam/WeldSeamConfig/Src/AlgorithmParamConverter.cpp +++ b/App/WeldSeam/WeldSeamConfig/Src/AlgorithmParamConverter.cpp @@ -14,5 +14,6 @@ WeldSeamAlgorithmParams AlgorithmParamConverter::ToAlgorithmParams(const VrAlgor result.treeGrowParam.minLTypeTreeLen = params.treeGrowParam.minLTypeTreeLen; result.treeGrowParam.minVTypeTreeLen = params.treeGrowParam.minVTypeTreeLen; result.weldRefPoints = params.weldSeamParam.weldRefPoints; + result.detectFlawType = params.weldSeamParam.detectFlawType; return result; } diff --git a/App/WeldSeam/WeldSeamConfig/Src/VrConfig.cpp b/App/WeldSeam/WeldSeamConfig/Src/VrConfig.cpp index 45d7c798..2ffa9285 100644 --- a/App/WeldSeam/WeldSeamConfig/Src/VrConfig.cpp +++ b/App/WeldSeam/WeldSeamConfig/Src/VrConfig.cpp @@ -33,6 +33,12 @@ void LoadAlgorithmParams(XMLElement* algoElement, VrAlgorithmParams& params) if (XMLElement* e = algoElement->FirstChildElement("WeldSeamParam")) { e->QueryIntAttribute("weldRefPoints", ¶ms.weldSeamParam.weldRefPoints); + int detectFlawType = static_cast(params.weldSeamParam.detectFlawType); + if (e->QueryIntAttribute("detectFlawType", &detectFlawType) == XML_SUCCESS && + detectFlawType >= static_cast(keWD_FlawType_Uknown) && + detectFlawType <= static_cast(keSG_FlawType_Dep_Prot)) { + params.weldSeamParam.detectFlawType = static_cast(detectFlawType); + } } // è§£æž�多相机平é�¢æ ¡å‡†å�‚æ•° @@ -58,6 +64,8 @@ void SaveAlgorithmParams(XMLDocument& doc, XMLElement* algoElement, const VrAlgo XMLElement* weldElement = doc.NewElement("WeldSeamParam"); weldElement->SetAttribute("weldRefPoints", params.weldSeamParam.weldRefPoints); + weldElement->SetAttribute("detectFlawType", + static_cast(params.weldSeamParam.detectFlawType)); algoElement->InsertEndChild(weldElement); // 多相机平é�¢æ ¡å‡†å�‚æ•° diff --git a/App/WeldSeam/WeldSeamConfig/config/config.xml b/App/WeldSeam/WeldSeamConfig/config/config.xml index add597e6..37ae2b39 100644 --- a/App/WeldSeam/WeldSeamConfig/config/config.xml +++ b/App/WeldSeam/WeldSeamConfig/config/config.xml @@ -9,7 +9,7 @@ - + diff --git a/AppAlgo/lapWeldDetection/Arm/aarch64/libbaseAlgorithm.so b/AppAlgo/lapWeldDetection/Arm/aarch64/libbaseAlgorithm.so index 4dde63c4..dfc8c33c 100644 Binary files a/AppAlgo/lapWeldDetection/Arm/aarch64/libbaseAlgorithm.so and b/AppAlgo/lapWeldDetection/Arm/aarch64/libbaseAlgorithm.so differ diff --git a/AppAlgo/lapWeldDetection/Arm/aarch64/liblapWeldDetection.so b/AppAlgo/lapWeldDetection/Arm/aarch64/liblapWeldDetection.so index 4fe60fab..796aa3e1 100644 Binary files a/AppAlgo/lapWeldDetection/Arm/aarch64/liblapWeldDetection.so and b/AppAlgo/lapWeldDetection/Arm/aarch64/liblapWeldDetection.so differ diff --git a/AppAlgo/lapWeldDetection/Inc/SG_baseAlgo_Export.h b/AppAlgo/lapWeldDetection/Inc/SG_baseAlgo_Export.h new file mode 100644 index 00000000..cfd82f6b --- /dev/null +++ b/AppAlgo/lapWeldDetection/Inc/SG_baseAlgo_Export.h @@ -0,0 +1,1137 @@ +#pragma once + +#include "SG_algo_Export.h" +#include +#include + +//ÏòÁ¿²æ³Ë +SG_APISHARED_EXPORT SVzNL3DPoint vec3_cross(const SVzNL3DPoint& a, const SVzNL3DPoint& b); +// ÏòÁ¿Êý³Ë +SG_APISHARED_EXPORT SVzNL3DPoint vec3_multiply(const SVzNL3DPoint& a, const double s); +// µã³Ë dot +SG_APISHARED_EXPORT double vec3_dotMultiply(const SVzNL3DPoint& a, const SVzNL3DPoint& b); +// Ä£³¤ +SG_APISHARED_EXPORT double vec3_length(const SVzNL3DPoint& a); +// ¹éÒ»»¯£¨µ¥Î»ÏòÁ¿£© +SG_APISHARED_EXPORT SVzNL3DPoint vec3_normalize(const SVzNL3DPoint& a); +// ¼ÆËãÁ½¸öÏòÁ¿¼Ð½Ç£¨·µ»Ø ½Ç¶È£© +SG_APISHARED_EXPORT float vec3_computeVecAngle(const SVzNL3DPoint& a, const SVzNL3DPoint& b); +//µãÐýת +SG_APISHARED_EXPORT SVzNL3DPoint wd_ptRotate(SVzNL3DPoint pt3D, const double matrix3d[9]); +//¶þάµãÐýת +SG_APISHARED_EXPORT SVzNL2DPointD wd_pt2dRotate(SVzNL2DPointD pt2D_in, double rotateAngle); +//¼ÆËã×ÜÌå¾ùÖµºÍ×ÜÌå±ê×¼²î +SG_APISHARED_EXPORT void CalcStats(const std::vector& data, SSG_meanVar& result); + +/** + * @brief Æ½ÃæÄÚÏòÁ¿ v ÈÆÆ½Ãæ·¨ÏòÁ¿ n Ðýת theta »¡¶È + * £¨v ±ØÐëÔÚÆ½ÃæÄÚ£¬×Ô¶¯Ê¹Óüò»¯°æÂÞµÂÀï¸ñ˹£© + */ +SG_APISHARED_EXPORT SVzNL3DPoint wd_rotateVectorInPlane(const SVzNL3DPoint& v, const SVzNL3DPoint& n, double theta); + +//ÄæÊ±ÕëÐýתʱ ¦È > 0 £»Ë³Ê±ÕëÐýתʱ ¦È < 0 +SG_APISHARED_EXPORT SVzNL3DPoint wd_rotate2D(const SVzNL3DPoint& pt, const double angle); + +//Â˳ýÀëȺµã:zÌø±äÃÅÏÞ·½·¨£¨´óÓÚÃÅÏÞÊÓΪ²»Á¬Ðø£¬¸ù¾ÝÁ¬Ðø¶ÎµãÊýÁ¿ÅжÏÔëÉù£© +SG_APISHARED_EXPORT void sg_lineDataRemoveOutlier( + SVzNL3DPosition* lineData, + int dataSize, + SSG_outlierFilterParam filterParam, + std::vector& filerData, + std::vector& noisePts); +//Â˳ýÀëȺµã£ºzÌø±äÃÅÏÞ·½·¨,¸Ä±äԭʼÊý¾Ý +SG_APISHARED_EXPORT void sg_lineDataRemoveOutlier_changeOriginData( + SVzNL3DPosition* lineData, + int dataSize, + SSG_outlierFilterParam filterParam); +//Â˳ýÀëȺµã£ºzÌø±äÃÅÏÞ·½·¨, vecotr¶ÔÏó +SG_APISHARED_EXPORT void wd_vectorDataRemoveOutlier_overwrite( + std::vector& a_line, + SSG_outlierFilterParam filterParam); +//Â˳ýÀëȺµã£ºµã¾àÀëÃÅÏÞ·½·¨£¨´óÓÚÃÅÏÞÊÓΪ²»Á¬Ðø£¬¸ù¾ÝÁ¬Ðø¶ÎµãÊýÁ¿ÅжÏÔëÉù£© +SG_APISHARED_EXPORT void sg_lineDataRemoveOutlier_ptDistMethod( + SVzNL3DPosition* lineData, + int dataSize, + SSG_outlierFilterParam filterParam, + std::vector& filerData, + std::vector& noisePts); + +//ƽ»¬ +SG_APISHARED_EXPORT void sg_lineDataSmoothing( + std::vector& input, + int smoothWin, + std::vector& output); +//·Ö¶Îƽ»¬£¬ÕâÑù²»»áÓ°Ïì·Ö¶Î¶Ëµã +SG_APISHARED_EXPORT void sg_lineSegSmoothing( + std::vector& input, + double seg_y_deltaTh, //·Ö¶ÎµÄY¼ä¸ô¡£´óÓڴ˼ä¸ô£¬ÎªÐµķֶΠ+ double seg_z_deltaTh,//·Ö¶ÎµÄZ¼ä¸ô¡£´óÓڴ˼ä¸ô£¬ÎªÐµķֶΠ+ int smoothWin, + std::vector& output); + +//VZ_APISHARED_EXPORT void sg_getLineMeanVar(); +SG_APISHARED_EXPORT void sg_getLineLVFeature( + SVzNL3DPosition* lineData, + int dataSize, + int lineIdx, + const SSG_slopeParam slopeParam, + const SSG_VFeatureParam valleyPara, + SSG_lineFeature* line_features); + +//»ñȡɨÃèÏß¹ÕµãÌØÕ÷ +SG_APISHARED_EXPORT void sg_getLineCornerFeature( + SVzNL3DPosition* lineData, + int dataSize, + int lineIdx, + const SSG_cornerParam cornerPara, //scaleͨ³£È¡bagHµÄ1/4 + SSG_lineFeature* line_features); + +// ¶Ô¼¤¹âÏßÉÏÓÉMask(nPointIdxתÒ嶨Ò壩ָ¶¨µÄµãÌáÈ¡¼¤¹âÏßÉϵĹյãÌØÕ÷ +SG_APISHARED_EXPORT void sg_maskData_getLineCornerFeature( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + int maskID, + const SSG_cornerParam cornerPara, //scaleͨ³£È¡bagHµÄ1/4 + std::vector& features); + +//ÌáÈ¡GapÌØÕ÷¡£GapÌØÕ÷£ºÓÉÁ½¸ö¸ºµÄCorner¹¹³ÉµÄÇøÓò +SG_APISHARED_EXPORT void sg_getLineGapFeature( + std::vector& lineData, //ɨÃèÏß + int lineIdx, //µ±Ç°É¨ÃèÏßÐòºÅ + const SSG_cornerParam cornerPara, + const SVzNLRangeD gapParam, + std::vector& line_gaps); + +SG_APISHARED_EXPORT void sg_getLineCornerFeature_BQ( + SVzNL3DPosition* lineData, + int dataSize, + int lineIdx, + double refSteppingZ, + const SSG_cornerParam cornerPara, + std::vector& line_features); + +/// +/// ÌáÈ¡¼¤¹âÏßÉϵĹյãÌØÕ÷£¬µØÃæ¶Ëµã¸½½üµÄ¹ÕµãÊÓΪºÏ¸ñ¹Õµã +/// ¸ù¾ÝSeg½øÐÐcornerÌáÈ¡ +/// nPointIdx±»ÖØÐ¶¨Òå³ÉFeatureÀàÐÍ +/// Ëã·¨Á÷³Ì£º +/// £¨1£©Öðµã¼ÆËãǰÏò½ÇºÍºóÏò½Ç +/// £¨2£©Öðµã¼ÆËã¹Õ½Ç£¬Ë³Ê±ÕëΪ¸º£¬ÄæÊ±ÕëΪÕý +/// £¨3£©ËÑË÷Õý¹Õ½ÇµÄ¼«´óÖµ¡£ +/// £¨4£©ÅжϹսÇÊÇ·ñÎªÌø±ä +/// +SG_APISHARED_EXPORT void sg_getLineContourCornerFeature_groundMask_BQ( + std::vector& lineData, + std::vector groundMask, + int lineIdx, + double contourWin, //ground±ßÔµ·¶Î§ + const SSG_cornerParam cornerPara, //scaleͨ³£È¡bagHµÄ1/4 + std::vector& line_features); + +SG_APISHARED_EXPORT void wd_getLineDataIntervals( + std::vector& lineData, + const SSG_lineSegParam lineSegPara, + std::vector& segs); + +//ÌáÈ¡Gap¶Î +SG_APISHARED_EXPORT void wd_getLineDataNullIntervals( + std::vector& lineData, + const SSG_lineSegParam lineSegPara, + std::vector& segs); + +// ×îСµã¼¯ÊýÁ¿£¨Ð¡ÓÚ´ËÊýÎÞ·¨ÄâºÏÖ±Ïߣ© +const int MIN_POINT_COUNT = 3; +//ʹÓö˵ãÖ±Ïߣ¬¼ì²éµãµ½Ö±ÏߵľàÀ룬´óÓÚÃÅÏ޵ķָî +SG_APISHARED_EXPORT void split( + SSG_RUN a_run, + std::vector< SVzNL3DPosition>& lineData, + const double maxError, + std::vector< SSG_RUN>& lineSegs); + +/// +/// ÌáÈ¡¼¤¹âÏßÉϵÄÌØÕ÷£ºÌø±ä¡¢µÍÓÚzãÐÖµ¡¢V¼°LÐÍ£¬ÓÃÓÚÁ£¾¶¼ì²â£¨PSM) +/// seg¶Ëµã£ºz¾àÀë´óÓÚÃÅÏÞ +/// nPointIdx±»ÖØÐ¶¨Òå³ÉFeatureÀàÐÍ +/// Ëã·¨Á÷³Ì£º +/// £¨1£©Öðµã¼ÆËãǰÏò½ÇºÍºóÏò½Ç +/// £¨2£©Öðµã¼ÆËã¹Õ½Ç£¬Ë³Ê±ÕëΪ¸º£¬ÄæÊ±ÕëΪÕý +/// £¨3£©ËÑË÷Õý¹Õ½ÇµÄ¼«´óÖµ¡£ +/// £¨4£©ÅжϹսÇÊÇ·ñÎªÌø±ä +/// +SG_APISHARED_EXPORT void wd_getLineCornerFeature_PSM( + SVzNL3DPosition* lineData, + int dataSize, + int lineIdx, + const double groundZ, + const SSG_cornerParam cornerPara, + SSG_lineFeature* line_features); + +//¸ù¾Ý¾àÀëÁ¬ÐøÐÔ·Ö¶Î +SG_APISHARED_EXPORT void wd_lineDataSegment_dist( + std::vector< SWD3DPointPostion>& lineData, + std::vector& segs, + const double maxDistTh, + const int minSegSize +); + +//¸ù¾Ý¾àÀëÁ¬ÐøÐÔ·Ö¶Î +SG_APISHARED_EXPORT void wd_lineDataSegment_dist_2( + std::vector< SVzNL3DPosition>& lineData, + std::vector& segs, + const double maxDistTh, + const double minSegSize +); + +SG_APISHARED_EXPORT void wd_lineDataSegment_zDist( + std::vector< SVzNL3DPosition>& lineData, + std::vector< SVzNL3DPosition>& vldPts, + std::vector& segs, + std::vector& backIndexing, + const SSG_cornerParam cornerPara +); + +//¼ÆËã·½Ïò½Ç(²»·Ö¶Î£© +SG_APISHARED_EXPORT void wd_computeDirAngle_wholeLine( + std::vector< SVzNL3DPosition>& line_data, + const SSG_cornerParam cornerPara, + std::vector< SSG_pntDirAngle>& ptDirAngles +); + +//¼ÆËã·½Ïò½Ç(²»·Ö¶Î£©:ÔÚ¼ÆËãscaleµÄǰÌáÏ£¬¿¼ÂÇÁËÁ½µã¾àÀë¹ý´óʱµÄ´¦Àí¡£ +SG_APISHARED_EXPORT void wd_computeDirAngle_wholeLine2( + std::vector< SVzNL3DPosition>& line_data, + const double steppingScale, + const double invalidScale, //³¬³ö´Ë³ß¶È£¬·½Ïò½Ç¼ÆËãÎÞЧ + std::vector< SSG_pntDirAngle>& ptDirAngles +); + +/// ÌáÈ¡¼¤¹âÏßÉϵÄÔ²»·µÄÉϰë¶Î»¡¡£¿í¶ÈÓÉÔ²»·µÄ¿í¶ÈÈ·¶¨ +/// seg¶Ëµã£ºz¾àÀë´óÓÚÃÅÏÞ +/// nPointIdx±»ÖØÐ¶¨Òå³ÉFeatureÀàÐÍ +/// Ëã·¨Á÷³Ì£º +/// £¨1£©Öðµã¼ÆËãǰÏò½ÇºÍºóÏò½Ç +/// £¨2£©Öðµã¼ÆËã¹Õ½Ç£¬Ë³Ê±ÕëΪ¸º£¬ÄæÊ±ÕëΪÕý +/// £¨3£©ËÑË÷Õý¹Õ½ÇµÄ¼«´óÖµ¡£ +/// £¨4£©ÅжϹսÇÊÇ·ñÎªÌø±ä +/// +SG_APISHARED_EXPORT void wd_getRingArcFeature( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + const SSG_cornerParam cornerPara, + SVzNLRangeD ringArcWidth, //¶¨×ӵĻ·¿í¶È + std::vector& line_ringArcs //»· +); +//¼ì²â°ô²ÄÌØÕ÷¡£¸ù¾Ý°ô²ÄArcµÄ¶¥µãÕýºÃÊÇZ¼«Ð¡ÖµÌØÕ÷£¬¼ì²âZ¼«Ð¡Öµ´¦µÄ¹Õ½ÇÇé¿ö +SG_APISHARED_EXPORT void wd_getRodArcFeature_peakCornerMethod( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + const double peakChkWin, + const SSG_cornerParam cornerPara, + std::vector& line_rodArcs //»· +); + +/// +/// ͨ¹ý¼ÆËãYZÆ½ÃæÄÚµÄÇúÂÊ·½·¨ÌáȡԲ»¡¡£ +/// seg¶Ëµã£ºz¾àÀë´óÓÚÃÅÏÞ +/// +SG_APISHARED_EXPORT void wd_getRodArcFeature_YZCurvatureMethod( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + const double maxDistTh, + const double minSegSize, + const double curvatureWin, + const double rodDiameter, + const double arcTotalCornerMinValue, + std::vector& line_rodArcs //»· +); + +/// +/// ÌáÈ¡¼¤¹âÏßÉϵÄÔ²»·µÄÉϰë¶Î»¡¡£ +/// seg¶Ëµã£ºz¾àÀë´óÓÚÃÅÏÞ +/// nPointIdx±»ÖØÐ¶¨Òå³ÉFeatureÀàÐÍ +/// Ëã·¨Á÷³Ì£º +/// £¨1£©Öð¶Î¼ÆËãǰÏò½ÇºÍºóÏò½Ç +/// £¨2£©ËÑË÷ͬ·½ÏòµÄ¹Õ½ÇÁ¬Ðø¶Î +/// £¨2£©ËÑË÷Z¼«Öµ£¬ +/// £¨2£©Öðµã¼ÆËã¹Õ½Ç£¬Ë³Ê±ÕëΪ¸º£¬ÄæÊ±ÕëΪÕý +/// £¨3£©ËÑË÷Õý¹Õ½ÇµÄ¼«´óÖµ¡£ +/// £¨4£©ÅжϹսÇÊÇ·ñÎªÌø±ä +/// +/// +SG_APISHARED_EXPORT void wd_getRodArcFeature_segmentPeakCornerMethod( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + const double maxDistTh, + const double minSegSize, + const double peakChkWin, + const SSG_cornerParam cornerPara, + bool doSmoothing, + std::vector& line_rodArcs //»· +); + +//ÌáÈ¡corner¼«Öµ£¨½ÏÔçʵÏÖº¯Êý¿ÉÒÔʹÓô˺¯Êý½øÐдúÂëÓÅ»¯£© +SG_APISHARED_EXPORT void wd_searchCornerPeaks( + std::vector< SSG_pntDirAngle>& corners, + std::vector< SVzNL3DPosition>& vldPts, + const double minCornerTh, + double cornerMergeScale, + std::vector< SSG_pntDirAngle>& cornerPeakP, + std::vector< SSG_pntDirAngle>& cornerPeakM +); + +//ÌáÈ¡backwardAngle¼«Öµ£¨½ÏÔçʵÏÖº¯Êý¿ÉÒÔʹÓô˺¯Êý½øÐдúÂëÓÅ»¯£© +SG_APISHARED_EXPORT void wd_searchBackwardAnglePeaks( + std::vector< SSG_pntDirAngle>& corners, + std::vector< SVzNL3DPosition>& vldPts, + const double minCornerTh, + double cornerMergeScale, + std::vector< SSG_pntDirAngle>& backwardAnglePeakP, + std::vector< SSG_pntDirAngle>& backwardAnglePeakM +); + +//ÌáÈ¡forwardAngle¼«Öµ£¨½ÏÔçʵÏÖº¯Êý¿ÉÒÔʹÓô˺¯Êý½øÐдúÂëÓÅ»¯£© +SG_APISHARED_EXPORT void wd_searchForwardAnglePeaks( + std::vector< SSG_pntDirAngle>& corners, + std::vector< SVzNL3DPosition>& vldPts, + const double minCornerTh, + double cornerMergeScale, + std::vector< SSG_pntDirAngle>& forwardAnglePeakP, + std::vector< SSG_pntDirAngle>& forwardAnglePeakM +); + +/// +/// ÌáÈ¡¼¤¹âÏßÉϵĹյãÌØÕ÷¡£ÊÇÔÚPSM£¬ LVTypeFeature, BQµÈ¹ÕµãËã·¨µÄ»ù´¡Éϵİ汾¡£ +/// nPointIdx±»ÖØÐ¶¨Òå³ÉFeatureÀàÐÍ +/// Ëã·¨Á÷³Ì£º +/// £¨1£©Öðµã¼ÆËãǰÏò½ÇºÍºóÏò½Ç +/// £¨2£©Öðµã¼ÆËã¹Õ½Ç£¬Ë³Ê±ÕëΪ¸º£¬ÄæÊ±ÕëΪÕý +/// £¨3£©ËÑË÷Õý¹Õ½ÇµÄ¼«´óÖµ¡£ +/// £¨4£©ÅжϹսÇÊÇ·ñÎªÌø±ä +/// +SG_APISHARED_EXPORT void wd_getLineCorerFeature( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + const SSG_cornerParam cornerPara, + std::vector& line_cornerFeatures //¹Õµã +); + +/// +/// ÌáÈ¡¼¤¹âÏßÉϵÄÓëXYÆ½Ãæ´¹Ö±µÄÌØÕ÷£¨´¹Ö±¶Î£© +/// +SG_APISHARED_EXPORT void wd_getXYVertialFeature_dirAngleMethod( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + const SSG_cornerParam cornerPara, + std::vector& xyVerticalFlags //»· +); +/// +/// °´¶ÎÌáÈ¡¼¤¹âÏßÉϵÄÓëXYÆ½Ãæ´¹Ö±µÄÌØÕ÷£¨´¹Ö±¶Î£© +/// +SG_APISHARED_EXPORT void wd_getXYVertialFeature_perSeg_dirAngleMethod( + std::vector< SVzNL3DPosition>& lineData, + std::vector& segs, + int lineIdx, + const SSG_cornerParam cornerPara, + std::vector& xyVerticalFlags +); + +/// +/// ÌáÈ¡¼¤¹âÏßÉϵÄÓëXYÆ½ÃæË®Æ½µÄÌØÕ÷£¨Ë®Æ½¶Î£© +/// +SG_APISHARED_EXPORT void wd_getXYHorizontalFeature_dirAngleMethod( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + const double maxDistTh, + const double minSegSize, + const SSG_cornerParam cornerPara, + std::vector& xyHorizontalFlags +); + +SG_APISHARED_EXPORT void wd_getRimConvexFeature( + std::vector< SVzNL3DPosition>& lineData, + std::vector& segs, + int lineIdx, + const SWDRimEdgeParam rimPara_1, + const SWDRimEdgeParam rimPara_2, + const SVzNLRangeD rimWidth, + std::vector& rimFeatures +); + +/// ÌáÈ¡¼¤¹âÏßÉϵĹյãÌØÕ÷¡£ÊÇÔÚPSM£¬ LVTypeFeature, BQµÈ¹ÕµãËã·¨µÄ»ù´¡Éϵİ汾¡£ +/// ʹÓÃÆ½¾ùµã¾à½øÐмÓËÙ +/// nPointIdx±»ÖØÐ¶¨Òå³ÉFeatureÀàÐÍ +/// Ëã·¨Á÷³Ì£º +/// £¨1£©Öðµã¼ÆËãǰÏò½ÇºÍºóÏò½Ç +/// £¨2£©Öðµã¼ÆËã¹Õ½Ç£¬Ë³Ê±ÕëΪ¸º£¬ÄæÊ±ÕëΪÕý +/// £¨3£©ËÑË÷Õý¹Õ½ÇµÄ¼«´óÖµ¡£ +/// £¨4£©ÅжϹսÇÊÇ·ñÎªÌø±ä +/// +SG_APISHARED_EXPORT void wd_getLineCorerFeature_accelerate( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + const SSG_cornerParam cornerPara, + const double pointInterval, + std::vector& segs, + std::vector& line_cornerFeatures //¹ÕµãÌØÕ÷ +); + +//Ìáȡ͹Æð¶Î +SG_APISHARED_EXPORT void wd_getLineRaisedFeature( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + SSG_raisedFeatureParam raisedFeaturePara, //͹Æð²ÎÊý + std::vector& line_raisedFeatures //͹Æð +); + +//Ìáȡָ¶¨Ìø±ä¸ß¶ÈµÄÌØÕ÷µã +SG_APISHARED_EXPORT void wd_getSpecifiedHeightJumping( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + SVzNLRangeD jumpHeight, //Ìø±ä¸ß¶È²ÎÊý + std::vector& line_jumpFeatures //Ìø±ä +); + +//Ö±ÏßÌØÕ÷ÌáÈ¡£º¶Ôsplit-and-merge·¨×÷Á˼ò»¯£¬ÒÔÆðµãÖÕµãÖ±Ïß´úÌæÄâºÏÖ±Ïß +SG_APISHARED_EXPORT void wd_surfaceLineSegment( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + SVzNLRangeD lineLenRange, + const SSG_lineSegParam lineSegPara, + std::vector& lineSegs, + std::vector& invlaidLineSegs); + +#if 0 +//¶ÔÒ»¸öÃæµÄ±ßÔµÌØÕ÷½øÐÐÌáÈ¡¡£ +//´ËËã·¨Ê×ÏÈ»ñȡɨÃèÏßÉϸ÷¸ö¶Î£¬È»ºó¶Ô¶ÎµÄ¶Ëµã½øÐд¦Àí£¬µÃµ½±ßÔµÌØÕ÷ +void wd_getSurfaceEdgeFeatures( + std::vector< SVzNL3DPosition>& lineData, + int lineIdx, + const SSG_lineSegParam lineSegPara, + std::vector& edgeFeatures); +#endif + +/// +/// ÌáÈ¡¼¤¹âÏßÉϵÄZÐÎJumpingÌØÕ÷ +/// +SG_APISHARED_EXPORT void sg_getLineZJumpFeature_cornerMethod( + SVzNL3DPosition* lineData, + int dataSize, + int lineIdx, + const SSG_cornerParam cornerPara, + const bool getTopEdge, + std::vector< SSG_basicFeature1D>& jumpFeatures); + +/// +/// ÌáÈ¡¼¤¹âÏßÉϵÄLÐÎJumpingÌØÕ÷ +/// +SG_APISHARED_EXPORT void sg_getLineLJumpFeature_cornerMethod( + SVzNL3DPosition* lineData, + int dataSize, + int lineIdx, + const SSG_cornerParam cornerPara, + const bool getTopEdge, + std::vector< SSG_basicFeature1D>& jumpFeatures); + +SG_APISHARED_EXPORT void wd_getLineGloveArcs( + std::vector& lineData, + int lineIdx, + const SSG_gloveArcParam arcPara, + std::vector& gloveArcs); + +/// ÌáÈ¡¼¤¹âÏßÉϵÄÔ²ÖùÐÎÌØÕ÷ +SG_APISHARED_EXPORT void sg_getLineUpperSemiCircleFeature( + SVzNL3DPosition* lineData, + int dataSize, + int lineIdx, + const double sieveDiameter, + const SSG_slopeParam slopePara, + std::vector< SSG_featureSemiCircle>& line_features, + cv::Mat& holeMask); + +/// +/// ÌáÈ¡¼¤¹âÏßÉϵļ«Öµµã£¨¼«´óÖµµãºÍ¼«Ð¡Öµµã£© +/// +/// +SG_APISHARED_EXPORT void sg_getLineLocalPeaks( + SVzNL3DPosition* lineData, + int dataSize, + int lineIdx, + const double scaleWin, + std::vector< SSG_basicFeature1D>& localMax, + std::vector< SSG_basicFeature1D>& localMin); + +SG_APISHARED_EXPORT void sg_getLineLocalPeaks_2( + std::vector& lineData, + int lineIdx, + const double scaleWin, + std::vector< SSG_basicFeature1D>& localZMax, + std::vector< SSG_basicFeature1D>& localZMin); + +/// +/// °´¶ÎÌáÈ¡¼¤¹âÏßÉϵļ«Öµµã£¨¼«´óÖµµãºÍ¼«Ð¡Öµµã£© +/// +/// +SG_APISHARED_EXPORT void sg_getLineLocalPeaks_perSegment( + std::vector& lineData, + std::vector& segs, + int lineIdx, + const double scaleWin, + std::vector< SSG_basicFeature1D>& localZMax, + std::vector< SSG_basicFeature1D>& localZMin); + +SG_APISHARED_EXPORT void sg_getFlatLineLocalPeaks_vector( + std::vector& lineData, + int lineIdx, + const double scaleWin, + const double minPkHeighth, + const double holeR, + std::vector< SSG_basicFeature1D>& localMax); + +SG_APISHARED_EXPORT void sg_getLineDownJumps( + SVzNL3DPosition* lineData, + int dataSize, + int lineIdx, + const double jumpTh, + std::vector< SSG_basicFeature1D>& downJumps); + +//¶Ôfeature½øÐÐÉú³¤ +SG_APISHARED_EXPORT void sg_getFeatureGrowingTrees( + std::vector& lineFeatures, + std::vector& trees, + SSG_treeGrowParam growParam); + +//¶Ôfeature½øÐÐÉú³¤:²»±È½Ïtype£¬Ö»ÅжÏλÖÃÊÇ·ñÏàÁÚ +SG_APISHARED_EXPORT void wd_getFeatureGrowingTrees_noTypeMatch( + std::vector& lineFeatures, + std::vector& feature_trees, + std::vector& ending_trees, + SSG_treeGrowParam growParam); + +//¶Ôsegment feature½øÐÐÉú³¤ +SG_APISHARED_EXPORT void wd_getSegFeatureGrowingTrees( + std::vector>& all_lineFeatures, + std::vector& feature_trees, + SSG_treeGrowParam growParam); + +//segmentÌØÕ÷Éú³¤, ÏàÐÅseg¼äÒª±£Ö¤ÓÐÖØµþÇø +SG_APISHARED_EXPORT void wd_getSegFeatureGrowingTrees_2( + std::vector>& all_lineFeatures, + std::vector& feature_trees, + const SSG_treeGrowParam growParam); + +//¶ÔrodArcfeature½øÐÐÉú³¤ +SG_APISHARED_EXPORT void wd_getRodArcFeatureGrowingTrees( + std::vector>& all_lineFeatures, + std::vector& feature_trees, + const SSG_treeGrowParam growParam); + +SG_APISHARED_EXPORT void sg_lineFeaturesGrowing( + int lineIdx, + bool isLastLine, + std::vector& features, + std::vector& trees, + SSG_treeGrowParam growParam); + +//cornerÌØÕ÷Éú³¤ +SG_APISHARED_EXPORT void sg_cornerFeaturesGrowing( + std::vector>& cornerFeatures, + std::vector& trees, + SSG_treeGrowParam growParam); + +//gapÌØÕ÷Éú³¤£ºleafÓÅÏÈģʽ¡£Ã¿¸öÒ¶½ÚµãȥѰÕÒÆ¥ÅäÉú³¤Ê÷ +SG_APISHARED_EXPORT void sg_lineGapsGrowing( + int lineIdx, + bool isLastLine, + std::vector& features, + std::vector& trees, + SSG_treeGrowParam growParam); + +//gapÉú³¤£ºtreeÓÅÏÈģʽ¡£Ã¿¿ÃÉú³¤Ê÷ȥѰÕÒÆ¥ÅäеÄleaf +SG_APISHARED_EXPORT void sg_lineGapsGrowing_treeFirst( + int lineIdx, + bool isLastLine, + std::vector& features, + std::vector& trees, + SSG_treeGrowParam growParam); + +//SG_APISHARED_EXPORT void sg_getTreeROI(SSG_featureTree* a_tree); + +//¶Ôending½øÐÐÉú³¤ +SG_APISHARED_EXPORT void sg_getEndingGrowingTrees( + std::vector& lineEndings, + SVzNL3DLaserLine* laser3DPoints, + bool isVScan, + int featureType, + std::vector& trees, + SSG_treeGrowParam growParam); + +//¶Ôending½øÐÐÉú³¤£¬´¹Ö±É¨Ãèʱֻ½øÐÐˮƽÉú³¤£»Ë®Æ½É¨Ãèʱֻ½øÐд¹Ö±Éú³¤ +SG_APISHARED_EXPORT void sg_getEndingGrowingTrees_angleCheck( + std::vector& lineEndings, + SVzNL3DLaserLine* laser3DPoints, + bool isVScan, + int featureType, + std::vector& trees, + SSG_treeGrowParam growParam, + double angleCheckScale); + +//¶ÔɨÃèÏßÉ쵀 +SG_APISHARED_EXPORT void sg_LVFeatureGrowing( + std::vector& lineFeatures, + std::vector& trees, + SSG_bagParam bagParam, + SSG_treeGrowParam growParam, + std::vector& edgePts_0, + std::vector& edgePts_1); + +SG_APISHARED_EXPORT void sg_peakFeatureGrowing( + std::vector>& lineFeatures, + std::vector& trees, + SSG_treeGrowParam growParam); + +//semiCircleÌØÕ÷Éú³¤ +SG_APISHARED_EXPORT void sg_getFeatureGrowingTrees_semiCircle( + std::vector< SSG_featureSemiCircle>& lineFeatures, + const int lineIdx, + const int lineSize, + std::vector& trees, + std::vector& stopTrees, + std::vector& invalidTrees, //±»ÒƳýµÄÊ÷£¬ÕâЩÊ÷¿ÉÄܽ«Ä¿±ê·Ö³É¶à¸öÊ÷£¬´Ó¶ø±»ÒƳý¡£ + SSG_treeGrowParam growParam); + +SSG_meanVar _computeMeanVar(double* data, int size); + +///ËÑË÷¾Ö²¿×î¸ßµã£¨z×îСµã£©¡£ +///ËÑË÷·½·¨£ºÃ¿´Î²½½øËÑË÷´°¿Ú³¤¶ÈµÄÒ»°ë¡£¶Ô¾Ö²¿×î¸ßµã½øÐбê¼Ç£¬·ÀÖ¹±»Öظ´¼Ç¼¡£ +SG_APISHARED_EXPORT void sg_getLocalPeaks( + SVzNL3DLaserLine* scanLines, + int lineNum, + std::vector& peaks, + SSG_localPkParam searchWin); + +/// +/// ÇøÓòÉú³¤·¨£ºÒÔ¾Ö²¿×î¸ßµã×÷ΪÉú³¤ÖÖ×Ó½øÐÐÉú³¤ +/// Éú³¤·½·¨ÓëÒ»°ãµÄÇøÓòÉú³¤²»Í¬£ºÒÔÖÖ×ÓµãΪԲÐÄ×÷Ô²ÖÜɨÃ裬¼Ç¼ɨÃèµ½µÄ±ß½ç +/// +//SG_APISHARED_EXPORT void sg_peakPolarScan(cv::Mat& edgeMask, SVzNL2DPoint a_peak, SSG_polarScanParam polarScanParam, std::vector< SSG_2DValueI>& rgnContour); +//´ÓPeakµã½øÐÐˮƽ´¹Ö±É¨ÃèµÃµ½ÇøÓò±ß½ç +SG_APISHARED_EXPORT void sg_peakXYScan( + SVzNL3DLaserLine* laser3DPoints, + int lineNum, + cv::Mat& featureEdgeMask, + SSG_2DValueI a_peak, + SSG_treeGrowParam growParam, + SSG_bagParam bagParam, + bool rgnPtAsEdge, + std::vector< SSG_lineConotours>& topContour, + std::vector< SSG_lineConotours>& bottomContour, + std::vector< SSG_lineConotours>& leftContour, + std::vector< SSG_lineConotours>& rightContour, + int* maxEdgeId_top, + int* maxEdgeId_btm, + int* maxEdgeId_left, + int* maxEdgeId_right); + +//È¡³öÓë¸ø¶¨edgeIdÏàͬµÄ±ß½çµã +SG_APISHARED_EXPORT void sg_getContourPts( + std::vector< SSG_lineConotours>& contour_all, + int vldEdgeId, + std::vector< SSG_2DValueI>& contourFilter, + int* lowLevelFlag); + +//´Ó±ß½çµã¶ÔÖÐÈ¡³öÓë¸ø¶¨edgeIdÏàͬµÄ±ß½çµã +SG_APISHARED_EXPORT void sg_getPairingContourPts( + std::vector& contourPairs, + std::vector& idPairs, + std::vector< SSG_conotourPair>& contourFilter, + SVzNLRangeD range, + bool isTBDir, + int* lowLevelFlag_0, + int* lowLevelFlag_1); + +//È¡³ö×î¶Ì¾àÀëµÄ±ß½çµã +SG_APISHARED_EXPORT void sg_contourPostProc( + std::vector< SSG_contourPtInfo>& contour, + int maxEdgeIdx, + double sameConturDistTh, + std::vector< SSG_2DValueI>& contourFilter, + int sideID, + int* blockFlag); + +//¾àÀë±ä»» +//input, output¾ùΪfloatÐÍ +SG_APISHARED_EXPORT void sg_distanceTrans(const cv::Mat input, cv::Mat& output, int distType); + +/// +/// ÒÔ5x5·½Ê½Ñ°ÕÒlocalPeaks +/// +/// +/// +SG_APISHARED_EXPORT void sg_getLocalPeaks_distTransform( + cv::Mat& input, + std::vector& peaks, + SSG_localPkParam searchWin); + +/// +/// ʹÓÃÄ£°å·¨Ìáȡֱ½ÇÌØÕ÷ +/// ˮƽÏòÏÂÖ±½ÇÌØÕ÷£º¹Õµã×ó²àdeltaZÔÚÒ»¸öºÜСµÄ·¶Î§ÄÚ£»¹ÕµãÓÒ²àdeltaYÔÚÒ»¸öºÜСµÄ·¶Î§ÄÚ +/// +SG_APISHARED_EXPORT void sg_getLineRigthAngleFeature( + SVzNL3DPosition* lineData, + int dataSize, + int lineIdx, + const SSG_lineRightAngleParam templatePara_HF, + const SSG_lineRightAngleParam templatePara_FH, + const SSG_lineRightAngleParam templatePara_HR, + const SSG_lineRightAngleParam templatePara_RH, + SSG_lineFeature* line_features); + +//¼ÆËãɨÃèROI +SG_APISHARED_EXPORT SVzNL3DRangeD sg_getScanDataROI( + SVzNL3DLaserLine* laser3DPoints, + int lineNum); +//¼ÆËãɨÃèROI: vecotr¸ñʽ +SG_APISHARED_EXPORT SVzNL3DRangeD sg_getScanDataROI_vector( + std::vector< std::vector>& scanLines +); + +//¼ÆËãµãÔÆROI: vecotr¸ñʽ +SG_APISHARED_EXPORT SVzNL3DRangeD wd_getPointCloudROI( + std::vector& scanData); + +//¼ÆËãµãÔÆµÄROIºÍscale: vecotr¸ñʽ +SG_APISHARED_EXPORT SWD_pointCloudPara wd_getPointCloudPara( + std::vector< std::vector>& scanLines); + +//XYÆ½ÃæÖ±ÏßÄâºÏ +SG_APISHARED_EXPORT void lineFitting( + std::vector< SVzNL3DPoint>& inliers, + double* _k, + double* _b); + +//ÄâºÏ³ÉͨÓÃÖ±Ïß·½³Ì£¬°üÀ¨´¹Ö± +SG_APISHARED_EXPORT void lineFitting_abc( + std::vector< SVzNL3DPoint>& inliers, + double* _a, + double* _b, + double* _c); + +//ÄâºÏ³ÉͨÓÃÖ±Ïß·½³Ìax+by+c=0£¬°üÀ¨´¹Ö± +SG_APISHARED_EXPORT void indexingPtLineFitting_abc( + std::vector< SWD3DPointPostion>& inliers, + double* _a, + double* _b, + double* _c); + +/** + * @brief ¿Õ¼äÖ±Ïß×îС¶þ³ËÄâºÏ + * @param points ÊäÈëµÄÈýάµã¼¯£¨ÖÁÉÙ2¸öµã£¬·ñÔòÎÞÒâÒ壩 + * @param center Êä³ö£ºÄâºÏÖ±ÏßµÄÖÊÐÄ£¨»ù×¼µãP0£© + * @param direction Êä³ö£ºÄâºÏÖ±Ïߵķ½ÏòÏòÁ¿v£¨µ¥Î»»¯£© + * @return ÄâºÏÊÇ·ñ³É¹¦£¨µã¼¯ÓÐЧ·µ»Øtrue£© + */ +SG_APISHARED_EXPORT bool fitLine3DLeastSquares( + const std::vector& points, + SVzNL3DPoint& center, + SVzNL3DPoint& direction); + +//Ô²×îС¶þ³ËÄâºÏ +SG_APISHARED_EXPORT double fitCircleByLeastSquare( + const std::vector& pointArray, + SVzNL3DPoint& center, + double& radius); +//Ô²×îС¶þ³ËÄâºÏ +SG_APISHARED_EXPORT double fitCircleByLeastSquare_2( + const std::vector& pointArray, + SVzNL3DPoint& center, + double& radius); +//Ô²×îС¶þ³ËÄâºÏ +SG_APISHARED_EXPORT double fitCircleByLeastSquare_3( + const std::vector& pointArray, + SVzNL2DPointD& center, + double& radius); +// ¼ÓȨµü´ú×îС¶þ³ËÔ²ÄâºÏ£¨HuberÈ¨ÖØ»òTukeyÈ¨ÖØ£© +SG_APISHARED_EXPORT double fitCircleRobust( + const std::vector& points, + SVzNL3DPoint& robustCenter, + double& robustRadius, + double outlierThreshold = 2.5, // ±ê×¼²î±¶Êý + int maxIter = 20, + double minPointsRatio = 0.5); + +//Å×ÎïÏß×îС¶þ³ËÄâºÏ y=ax^2 + bx + c +SG_APISHARED_EXPORT bool leastSquareParabolaFitEigen( + const std::vector& points, + double& a, double& b, double& c, + double& mse, double& max_err); + +//¼ÆËãZ¾ùÖµ +SG_APISHARED_EXPORT double computeMeanZ(std::vector< SVzNL3DPoint>& pts); +SG_APISHARED_EXPORT double computeROIMeanZ(std::vector>& scanLines, SVzNLRect roi); +SG_APISHARED_EXPORT void computeROIZCutLabel(std::vector>& scanLines, SVzNLRect roi, double cutZ, int labelID); +//¼ÆËã½Ç¶È²îÖµ£¬ÔÚ0-180¶È·¶Î§ +SG_APISHARED_EXPORT double computeAngleDiff(double theta1, double theta2); + +/** + * @brief ¼ÆËã´ÓÏòÁ¿aµ½ÏòÁ¿bµÄ**Óз½ÏòÐýת½Ç**£¨·¶Î§£º-¦Ð ~ ¦Ð£© + * @param a Ô´ÏòÁ¿ + * @param b Ä¿±êÏòÁ¿ + * @param rotAngle Êä³ö£ºÐýת½Ç£¨»¡¶È£©£¬ÄæÊ±ÕëΪÕý£¬Ë³Ê±ÕëΪ¸º + * @return true£º¼ÆËã³É¹¦£¬false£ºÁãÏòÁ¿£¨Ê§°Ü£© + */ +SG_APISHARED_EXPORT bool calcRotateAngle(const SVzNL2DPointD& a, const SVzNL2DPointD& b, double& rotAngle); + +//¼ÆËãÖ±Ïß½»µã +SG_APISHARED_EXPORT SVzNL3DPoint computeLineCrossPt_abs( + double a1, double b1, double c1, + double a2, double b2, double c2); + +//¼ÆËã¹ý2µãµÄÖ±Ïß·½³Ì +SG_APISHARED_EXPORT void compute2ptLine( + SVzNL3DPoint pt1, + SVzNL3DPoint pt2, + double* _a, double* _b, double* _c); + +//¼ÆËã¹ý2µãµÄÖ±Ïß·½³Ì,²»Ê¹ÓýṹÌå +SG_APISHARED_EXPORT void compute2ptLine_2( + double x1, double y1, + double x2, double y2, + double* _a, double* _b, double* _c); + +//Ðýת45¶ÈºóµÄÖ±Ïß·½³Ì +SG_APISHARED_EXPORT void rotateLine45Deg( + double _a, double _b, double _c, + double x0, double y0, + double* r_a, double* r_b, double* r_c); + +//¼ÆËãÖ±Ïß½Ç¶È +SG_APISHARED_EXPORT double getLineAngle(const double _a, const double _b, const double _c); + +//¼ÆËãÁ½µãµÄ2D¾àÀë +SG_APISHARED_EXPORT double compute2DLen(SVzNL3DPoint pt1, SVzNL3DPoint pt2); + +//¼ÆËãXYÆ½ÃæÃæµÄÈý½ÇÐζ¥½Ç(p0µÄÕŽÇ) +SG_APISHARED_EXPORT double computeXOYVertexAngle(SVzNL3DPoint p0, SVzNL3DPoint p1, SVzNL3DPoint p2); + +//¼ÆËãµãµ½Ö±Ïß¾àÀë +SG_APISHARED_EXPORT double computePtDistToLine(double x0, double y0, double a, double b, double c); + +//¼ÆËã´¹×ãµã£¬Ö±Ïß·½³Ì£ºy = kx + b +SG_APISHARED_EXPORT SVzNL2DPointD sx_getFootPoint( + double x0, + double y0, + double k, + double b); + +//¼ÆËã´¹×ãµã£¬Ö±Ïß·½³Ì£ºax+by+c = 0 +SG_APISHARED_EXPORT SVzNL2DPointD sx_getFootPoint_abc( + double x0, + double y0, + double A, + double B, + double C); + +//BresenhamËã·¨ +SG_APISHARED_EXPORT void drawLine( + int x0, + int y0, + int x1, + int y1, + std::vector& pts); + +/// +/// Á½²½·¨±ê×¢ +/// +/// Ä¿±êµãΪ¡°1¡±£¬ ¿Õ°×µãΪ¡°0¡± +/// ±ê×¢½á¹û¡£Ã¿¸öµãΪrgnID, ID´Ó2¿ªÊ¼ +/// +SG_APISHARED_EXPORT void SG_TwoPassLabel( + const cv::Mat& bwImg, + cv::Mat& labImg, + std::vector& labelRgns, + int connectivity = 4); + +//¼ÆËãÃæ²ÎÊý: z = Ax + By + C +//res: [0]=A, [1]= B, [2]=-1.0, [3]=C, +SG_APISHARED_EXPORT void vzCaculateLaserPlane( + std::vector& Points3ds, + std::vector& res); + +SG_APISHARED_EXPORT Plane robustFitPlane( + const std::vector& points, + RobustType type = HUBER, + double delta = 1.0, // ãÐÖµ£º>´ËÖµÊÓΪÀëȺµã£¨mm£© + int maxIter = 20, // µü´ú´ÎÊý + double convergeThresh = 1e-5 // ÊÕÁ²ãÐÖµ£¨Æ½Ãæ±ä»¯×㹻С¾ÍÍ££© +); +// ============================================== +// ´ø ÌáǰÖÕÖ¹ µÄ RANSAC Æ½ÃæÄâºÏ£¨¹¤ÒµÕýʽ°æ£© +// ============================================== +SG_APISHARED_EXPORT Plane ransacFitPlane( + const std::vector& points, + std::vector& in_inliers, + float dist_thresh = 0.3f, // ÄÚµã¾àÀëãÐÖµ + int max_iter = 1000, // ×î´óµü´ú + int stop_no_improve = 250 // Á¬Ðø¶àÉÙ´ÎÎÞÌáÉý¾ÍÌáǰÍ˳ö +); + +// ÊäÈ룺3DµãÔÆ std::vector +// Êä³ö£ºaxis ÖáÏòµ¥Î»ÏòÁ¿, centroid µãÔÆÖÐÐÄ +SG_APISHARED_EXPORT void computeCylinderAxisFromIncompletePCA( + const std::vector& points, + SVzNL3DPoint& vec_axis, + SVzNL3DPoint& vec_centroid); + +// ¹¦ÄÜ£ºÓà PCA ¼ÆËãÆ½ÃæµãÔÆµÄ·¨ÏòÁ¿ +// ÊäÈë£ºÆ½ÃæÉ쵀 3D µãÔÆ +// Êä³ö£ºnormal ·¨ÏòÁ¿£¨µ¥Î»»¯£©£¬centroid Æ½ÃæÖÐÐÄ +SG_APISHARED_EXPORT void computePlaneNormalByPCA( + const std::vector& src_points, + SVzNL3DPoint& vec_normal, + SVzNL3DPoint& vec_centroid); + +// ¶þάPCA£¬ÇóÆ½ÃæÄÚÌõÎÆ·½Ïò +SG_APISHARED_EXPORT void pca2D( + const std::vector& src_pts, + SVzNL2DPointD& axis, + SVzNL2DPointD& centroid); + +//¼ÆËãÒ»¸öÆ½Ãæµ÷ƽ²ÎÊý¡£ +//Êý¾ÝÊäÈëÖпÉÒÔÓÐÒ»¸öµØÆ½ÃæºÍ²Î¿¼µ÷Æ½Æ½Ãæ£¬ÒÔ×î¸ßµÄÆ½Ãæ½øÐе÷ƽ +//Ðýת¾ØÕóΪµ÷ƽ²ÎÊý£¬¼´½«Æ½Ãæ·¨Ïòµ÷ÕûΪ´¹Ö±ÏòÁ¿µÄ²ÎÊý +SG_APISHARED_EXPORT SSG_planeCalibPara sg_getPlaneCalibPara( + SVzNL3DLaserLine* laser3DPoints, + int lineNum); + +SG_APISHARED_EXPORT SSG_planeCalibPara sg_HCameraVScan_getGroundCalibPara( + std::vector< std::vector>& scanLines); + +//½«Ò»¸öÆ½Ãæµ÷ÕûÎªË®Æ½Æ½Ãæ(zΪ¹Ì¶¨Öµ£©£¬ +SG_APISHARED_EXPORT SSG_planeCalibPara adjustPlaneToXYPlane( + double plane_A, double plane_B, double plane_C //Æ½Ãæ·¨ÏòÁ¿ +); + +//¼ÆËãÒ»¸öÆ½Ãæµ÷ƽ²ÎÊý¡£ +//Êý¾ÝÊäÈëÖпÉÒÔÓÐÒ»¸öµØÆ½ÃæºÍ²Î¿¼µ÷Æ½Æ½Ãæ£¬ÒÔ×î¸ßµÄÆ½Ãæ½øÐе÷ƽ +//Ðýת¾ØÕóΪµ÷ƽ²ÎÊý£¬¼´½«Æ½Ãæ·¨Ïòµ÷ÕûΪ´¹Ö±ÏòÁ¿µÄ²ÎÊý +SG_APISHARED_EXPORT SSG_planeCalibPara sg_getPlaneCalibPara2( + std::vector< std::vector>& scanLines); + +//Õë¶Ô¿×°å¼ÆËãÒ»¸öÆ½Ãæµ÷ƽ²ÎÊý£ºÌáÈ¡²»¾­¹ý¿×µÄɨÃèÏß½øÐÐÆ½ÃæÄâºÏ +SG_APISHARED_EXPORT SSG_planeCalibPara sg_getHolePlaneCalibPara( + std::vector< std::vector>& scanLines); + +//¼ÆËãÒ»¸öÆ½Ãæµ÷ƽ²ÎÊý¡£ +//ÒÔÊý¾ÝÊäÈëÖÐROIÒÔÄÚµÄµã½øÐÐÆ½ÃæÄâºÏ£¬¼ÆËãµ÷ƽ²ÎÊý +//Ðýת¾ØÕóΪµ÷ƽ²ÎÊý£¬¼´½«Æ½Ãæ·¨Ïòµ÷ÕûΪ´¹Ö±ÏòÁ¿µÄ²ÎÊý +SG_APISHARED_EXPORT SSG_planeCalibPara sg_getPlaneCalibPara_ROIs( + SVzNL3DLaserLine* laser3DPoints, + int lineNum, + std::vector& ROIs); + +//¼ÆËãÒ»¸öÆ½Ãæµ÷ƽ²ÎÊý¡£ +//ÒÔÊý¾ÝÊäÈëÖÐROIÒÔÄÚµÄµã½øÐÐÆ½ÃæÄâºÏ£¬¼ÆËãµ÷ƽ²ÎÊý +//Ðýת¾ØÕóΪµ÷ƽ²ÎÊý£¬¼´½«Æ½Ãæ·¨Ïòµ÷ÕûΪ´¹Ö±ÏòÁ¿µÄ²ÎÊý +SG_APISHARED_EXPORT SSG_planeCalibPara sg_getPlaneCalibPara2_ROI( + std::vector< std::vector>& scanLines, + SVzNL3DRangeD roi); + +//¸ù¾ÝÁ½¸öÏòÁ¿¼ÆËãÐýת¾ØÕó +SG_APISHARED_EXPORT SSG_planeCalibPara wd_computeRTMatrix( + SVzNL3DPoint& vector1, + SVzNL3DPoint& vector2); + +// ´ÓÐýת¾ØÕó¼ÆËãÅ·À­½Ç£¨Z-Y-X˳Ðò£© +SG_APISHARED_EXPORT SSG_EulerAngles rotationMatrixToEulerZYX(const double R[3][3]); +// ´ÓÅ·À­½Ç¼ÆËãÐýת¾ØÕó£¨Z-Y-X˳Ðò£© +SG_APISHARED_EXPORT void eulerToRotationMatrixZYX(const SSG_EulerAngles& angles, double R[3][3]); + +//Ïà»ú×Ë̬µ÷ƽ£¬²¢È¥³ýµØÃæ +///camPoseRΪ3x3¾ØÕó +SG_APISHARED_EXPORT void lineDataRT( + SVzNL3DLaserLine* a_line, + const double* camPoseR, + double groundH); +SG_APISHARED_EXPORT void lineDataRT_vector( + std::vector< SVzNL3DPosition>& a_line, + const double* camPoseR, + double groundH); +SG_APISHARED_EXPORT void HCamera_lineDataRT_vector( + std::vector< SVzNL3DPosition>& a_line, + const double* camPoseR, + double groundH); +SG_APISHARED_EXPORT void lineDataRT_RGBD( + SVzNLXYZRGBDLaserLine* a_line, + const double* camPoseR, + double groundH); + +//»ùÓÚÏàÁÚµãµÄ¾ÛÀà +SG_APISHARED_EXPORT void sg_pointClustering( + std::vector< SVzNL3DPosition>& pts, + double clusterDist, + std::vector>& objClusters //result +); +//ʹÓÃSVzNL3DPositionµÄnPointIdx±íʾ2DÐÅÏ¢£¨¸ß16λLine£¬ µÍ16λptIdx£© +//ËÑË÷ʱËÑË÷ÁÚÓòÒÔ¼ÓËÙ +SG_APISHARED_EXPORT void wd_pointClustering_speedUp( + std::vector< SVzNL3DPosition>& pts, + int lineNum, int ptSize, int clusterCheckWin, //ËÑË÷´°¿Ú + double clusterDist, + int distType, //0 - 2d distance; 1- 3d distance + std::vector>& objClusters //result +); + +//¶ÔÒ»¸ö¸ø¶¨µÄ¾ÛÀࣨÒѾ­Óе㣩¼ÌÐøÔÚÒ»¸öµãÔÆÖоÛÀà +//ʹÓÃSVzNL3DPositionµÄnPointIdx±íʾ2DÐÅÏ¢£¨¸ß16λLine£¬ µÍ16λptIdx£© +//ËÑË÷ʱËÑË÷ÁÚÓòÒÔ¼ÓËÙ +SG_APISHARED_EXPORT void wd_clusterGrowing_speedUp( + std::vector< SVzNL3DPosition>& pts, + std::vector< SVzNL3DPosition >& a_cluster, + SVzNL3DRangeD& growingROI, //¾ÛÀ෶Χ£¬ÓÃÓÚ¼ÓËÙ + int lineNum, int linePtSize, int clusterCheckWin, //ËÑË÷´°¿Ú + double clusterDist, + int distType, //0 - 2d distance; 1- 3d distance + std::vector< SVzNL3DPosition >& added_points +); + +//»ùÓÚÕ¤¸ñÉϵãµÄ´°¿ÚÄÚµÄÏàÁÚµãµÄ¾ÛÀ࣬¾ÛÀàÌõ¼þÓÉ3DµãµÄÁÚÓò¾ö¶¨ +//ʹÓÃvector¹¹³É2ά½á¹¹ÌåÊý×é +SG_APISHARED_EXPORT void wd_gridPointClustering( + std::vector>& featureMask, + std::vector>& feature3DInfo, + int clusterCheckWin, //ËÑË÷´°¿Ú + SSG_treeGrowParam growParam,//¾ÛÀàÌõ¼þ + int clusterID, //µ±Ç°ClusterµÄID + std::vector< SVzNL2DPoint>& a_cluster, //result + SVzNL3DRangeD& clusterRoi //roi3D +); + +//¶ÔɨÃèÊý¾ÝµÄ¾ÛÀà +SG_APISHARED_EXPORT void wd_gridPointClustering_2( + std::vector>& gridData, + std::vector>& pointMaskInfo, //·ÀÖ¹¾ÛÀàÊ±ÖØ¸´Ñ¡ÖÐ + int clusterCheckWin, //ËÑË÷´°¿Ú + SSG_treeGrowParam growParam,//¾ÛÀàÌõ¼þ + int clusterID, //µ±Ç°ClusterµÄID + std::vector< SVzNL2DPoint>& a_cluster, //result + SVzNL3DRangeD& clusterRoi //roi3D +); + +//ʹÓþÛÀà·½·¨Íê³É8Á¬Í¨Á¬Í¨Óò·ÖÎö +SG_APISHARED_EXPORT void wd_gridPointClustering_labelling( + std::vector>& featureMask, + std::vector>& feature3DInfo, + int clusterID, //µ±Ç°ClusterµÄID + std::vector< SVzNL2DPoint>& a_cluster, //result + SVzNLRect& clusterRoi //roi2D +); + +//ʹÓþÛÀà·½·¨Íê³É8Á¬Í¨Á¬Í¨Óò·ÖÎö:ÊÊÓ¦²»Í¬µÄÊý¾Ý½á¹¹ +SG_APISHARED_EXPORT void wd_gridPointClustering_labelling_2( + std::vector>& srcData, + std::vector>& labelMask, + int clusterID, //µ±Ç°ClusterµÄID + std::vector< SVzNL2DPoint>& a_cluster, //result + SVzNL3DRangeD& clusterRoi //roi3D +); + +//¶ÔÕ¤¸ñ»¯Êý¾Ý½øÐÐXYÆ½ÃæÉϵÄͶӰÁ¿»¯£¬²¢¶ÔÁ¿»¯²úÉúµÄ¿Õ°×µã½øÐвåÖµ +SG_APISHARED_EXPORT void pointClout2DProjection( + std::vector< std::vector>& gridScanData, + SVzNLRangeD x_range, + SVzNLRangeD y_range, + double scale, + double cuttingGrndZ, + int edgeSkip, + double inerPolateDistTh, //²åÖµãÐÖµ¡£´óÓÚ´ËãÐÖµµÄ²»½øÐÐÁ¿»¯²åÖµ + cv::Mat& projectionData,//ͶӰÁ¿»¯Êý¾Ý£¬³õʼ»¯ÎªÒ»¸ö¼«´óÖµ1e+6 + cv::Mat& backIndexing //±ê¼Ç×ø±êË÷Òý£¬ÓÃÓÚ»ØÕÒ3D×ø±ê +); + +//¶ÔÕ¤¸ñ»¯Êý¾Ý½øÐÐXYÆ½ÃæÉϵÄͶӰÁ¿»¯£¬ZÖµ±£Áô£¬²¢¶ÔÁ¿»¯²úÉúµÄ¿Õ°×µã½øÐвåÖµ +SG_APISHARED_EXPORT void pointCloud2DQuantization( + std::vector< std::vector>& gridScanData, + SVzNLRangeD x_range, + SVzNLRangeD y_range, + double scale, + int edgeSkip, + double inerPolateDistTh, //²åÖµãÐÖµ¡£´óÓÚ´ËãÐÖµµÄ²»½øÐÐÁ¿»¯²åÖµ + std::vector>& quantiData, //Á¿»¯Êý¾Ý£¬³õʼ»¯ÎªÒ»¸ö¼«´óÖµ1e+6 + std::vector>& backIndexing //±ê¼Ç×ø±êË÷Òý£¬ÓÃÓÚ»ØÕÒ3D×ø±ê +); + +//·ÖË®ÁëËã·¨ +SG_APISHARED_EXPORT void watershed(SWD_waterShedImage& img); +// ¸ù¾ÝÊäÈëµÄÖÖ×Óµã½øÐзÖË®ÁëËã·¨ +SG_APISHARED_EXPORT void wd_seedWatershed( + SWD_waterShedImage& img, + std::vector& watershedSeeds, //ÖÖ×Óµã + int maxLevel, //×î´óˮλ + int startMakerID //ÆðʼMarkerµÄID +); + +//µãÔÆÂ˲¨Ô¤´¦Àí +SG_APISHARED_EXPORT void wd_noiseFilter( + std::vector< std::vector>& scanLines, + const SSG_outlierFilterParam filterParam, + int* errCode); + +//µãÔÆÌî¿×ƽ»¬´¦Àí +SG_APISHARED_EXPORT void wd_pointCloudHoleFilling( + std::vector< std::vector>& scanLines_src, + std::vector< std::vector>& scanLines_dst, + const int fillingHoleSize //Ìî¿×´óС +); + +// Eigen¿âʵÏÖ£º¼ÆËã´Ópts1Ïòpts2µÄÐý×ªÆ½ÒÆ¾ØÕó +//ÐèÒª +SG_APISHARED_EXPORT void caculateRT( + const std::vector& pts1, + const std::vector& pts2, + cv::Mat& R, cv::Mat& T, + cv::Point3d& C1, cv::Point3d& C2); + +//¼ÆËãµãÐý×ªÆ½ÒÆºóµÄλÖà +SG_APISHARED_EXPORT void pointRT(const cv::Mat& R, const cv::Mat& T, + const cv::Point3d& originPt, const cv::Point3d& rtOriginPT, //RT(Ðý×ªÆ½ÒÆ£©Ç°ºóµÄÖÊÐÄ + const cv::Point3d& pt, cv::Point3d& rtPt); //RTǰºóµÄµã + +//¼ÆËãµãÐý×ªÆ½ÒÆºóµÄλÖà +SG_APISHARED_EXPORT void pointRT_2(const cv::Mat& R, const cv::Mat& T, + const cv::Point3d& pt, cv::Point3d& rtPt); //RTǰºóµÄµã + +SG_APISHARED_EXPORT void pointRotate(const cv::Mat& R, + const cv::Point3d& pt, cv::Point3d& rtPt); //RotateǰºóµÄµã + +//´ÓÅ·À­½Ç¼ÆËãÐýת¾ØÕó +SG_APISHARED_EXPORT void WD_EulerRpyToRotation(double rpy[3], double matrix3d[9]); + +//´ÓÅ·À­½Ç¼ÆËã·½ÏòʸÁ¿ +SG_APISHARED_EXPORT void WD_EulerRpyToDirVectors(double rpy[3], std::vector& dirVectors); + +//3x3ƽ»¬ +SG_APISHARED_EXPORT void scanLinesSmooting3x3( + std::vector< std::vector>& gridDataInput, + std::vector< std::vector>& smoothingData +); + + +SG_APISHARED_EXPORT void WD_getHoleInfo( + std::vector< std::vector>& scanLines, + const SSG_lineSegParam lineSegPara, + const SSG_outlierFilterParam filterParam, + const SSG_treeGrowParam growParam, + const double valieCommonNumRatio, + std::vector& segTrees_v, + std::vector& segTrees_h, + std::vector& validObjects +); + +/* Ö§³ÖÕ¤¸ñÊý¾Ý£¨ÒªÇóÊäÈëÕ¤¸ñÊý¾Ý£© */ +//ÌáȡɨÃèÏßÉϵÄVÐÍValley +SG_APISHARED_EXPORT void wd_getLineVFlaws( + std::vector& a_line, + const int lineIdx, + const SWD_valleyParam valleyParam, + const EWD_FlawType detectFlawType, + std::vector< SSG_basicFeatureGap>& valleys); diff --git a/AppAlgo/lapWeldDetection/Inc/SG_baseDataType.h b/AppAlgo/lapWeldDetection/Inc/SG_baseDataType.h index a2c60280..2e07ac18 100644 --- a/AppAlgo/lapWeldDetection/Inc/SG_baseDataType.h +++ b/AppAlgo/lapWeldDetection/Inc/SG_baseDataType.h @@ -6,6 +6,14 @@ #define PI 3.14159265358979323846 +typedef enum +{ + keWD_FlawType_Uknown = 0, + keWD_FlawType_Depression, //°¼ÏÝ + keWD_FlawType_Protrusion, //͹Æð + keSG_FlawType_Dep_Prot, //°¼ÏݺÍ͹Æð»ìºÏ +} EWD_FlawType; + // ¶¨ÒåÅ·À­½Ç½á¹¹Ì壨µ¥Î»£º¶È£© typedef struct{ double roll; // ÈÆXÖáÐýת£¨ºá¹ö£© @@ -90,6 +98,12 @@ typedef struct int end; }SWD_Interval; //Çø¼ä +typedef struct SWD_IndexedValue +{ + int idx; + double value; +}SWD_IndexedValue; + typedef struct { bool validFlag; //ָʾ½á¹ûÊÇ·ñÓÐЧ diff --git a/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.dll b/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.dll index 91ed13a5..fa5e4105 100644 Binary files a/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.dll and b/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.dll differ diff --git a/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.lib b/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.lib index 20f42595..cb6b7ae2 100644 Binary files a/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.lib and b/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.lib differ diff --git a/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.pdb b/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.pdb index 2f9c9ce1..0bcf1d71 100644 Binary files a/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.pdb and b/AppAlgo/lapWeldDetection/Windows/x64/Debug/baseAlgorithm.pdb differ diff --git a/AppAlgo/lapWeldDetection/Windows/x64/Debug/lapWeldDetection.dll b/AppAlgo/lapWeldDetection/Windows/x64/Debug/lapWeldDetection.dll index 868a9edf..2c02ad2c 100644 Binary files a/AppAlgo/lapWeldDetection/Windows/x64/Debug/lapWeldDetection.dll and b/AppAlgo/lapWeldDetection/Windows/x64/Debug/lapWeldDetection.dll differ diff --git a/AppAlgo/lapWeldDetection/Windows/x64/Debug/lapWeldDetection.pdb b/AppAlgo/lapWeldDetection/Windows/x64/Debug/lapWeldDetection.pdb index 77c69985..379fa769 100644 Binary files a/AppAlgo/lapWeldDetection/Windows/x64/Debug/lapWeldDetection.pdb and b/AppAlgo/lapWeldDetection/Windows/x64/Debug/lapWeldDetection.pdb differ diff --git a/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.dll b/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.dll index c7f0dc53..3996da07 100644 Binary files a/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.dll and b/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.dll differ diff --git a/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.lib b/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.lib index d8d20a3f..dde44efd 100644 Binary files a/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.lib and b/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.lib differ diff --git a/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.pdb b/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.pdb index c3f276d1..e7d7a566 100644 Binary files a/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.pdb and b/AppAlgo/lapWeldDetection/Windows/x64/Release/baseAlgorithm.pdb differ diff --git a/AppAlgo/lapWeldDetection/Windows/x64/Release/lapWeldDetection.dll b/AppAlgo/lapWeldDetection/Windows/x64/Release/lapWeldDetection.dll index 44808e6c..ebdf172d 100644 Binary files a/AppAlgo/lapWeldDetection/Windows/x64/Release/lapWeldDetection.dll and b/AppAlgo/lapWeldDetection/Windows/x64/Release/lapWeldDetection.dll differ diff --git a/AppAlgo/lapWeldDetection/Windows/x64/Release/lapWeldDetection.pdb b/AppAlgo/lapWeldDetection/Windows/x64/Release/lapWeldDetection.pdb index 4860d47b..0563316c 100644 Binary files a/AppAlgo/lapWeldDetection/Windows/x64/Release/lapWeldDetection.pdb and b/AppAlgo/lapWeldDetection/Windows/x64/Release/lapWeldDetection.pdb differ