From 66b044e787390ef52b783ce4b47c10e0c9829745 Mon Sep 17 00:00:00 2001 From: jerryzeng Date: Sat, 6 Dec 2025 00:11:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96export?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BQ_workpieceCornerExtraction_Export.h | 12 +- sourceCode/SG_algo_Export.h | 22 ++++ sourceCode/SG_bagPositioning_Export.h | 3 +- sourceCode/SG_baseAlgo_Export.h | 9 +- sourceCode/SG_baseFunc.cpp | 6 +- sourceCode/SX_lapWeldDetection_Export.h | 4 +- sourceCode/WD_noiseFilter.cpp | 62 +++++++++++ sourceCode/WD_particleSizeMeasure_Export.h | 4 +- sourceCode/aruco.hpp | 103 ++++++++++++++++++ sourceCode/beltTearingDetection_Export.h | 20 +--- sourceCode/binocularMarkCam_Export.h | 13 +-- 11 files changed, 202 insertions(+), 56 deletions(-) create mode 100644 sourceCode/SG_algo_Export.h create mode 100644 sourceCode/WD_noiseFilter.cpp create mode 100644 sourceCode/aruco.hpp diff --git a/sourceCode/BQ_workpieceCornerExtraction_Export.h b/sourceCode/BQ_workpieceCornerExtraction_Export.h index 8feea26..9282e23 100644 --- a/sourceCode/BQ_workpieceCornerExtraction_Export.h +++ b/sourceCode/BQ_workpieceCornerExtraction_Export.h @@ -1,10 +1,8 @@ #pragma once -#include "SG_baseAlgo_Export.h" -#include "SG_baseDataType.h" +#include "SG_algo_Export.h" #include - #define _OUTPUT_DEBUG_DATA 1 typedef struct @@ -55,11 +53,7 @@ SG_APISHARED_EXPORT void sx_BQ_lineDataR( const double* camPoseR, double groundH); -<<<<<<< HEAD -//提取搭接焊缝 -======= //提取工件角点及定位长度信息 ->>>>>>> 19b51a73a7f69f892049985dacce8d76724f405c SG_APISHARED_EXPORT SSX_BQworkpieceResult sx_BQ_getWorkpieceCorners( std::vector< std::vector>& scanLines, const SSG_cornerParam cornerPara, @@ -70,8 +64,4 @@ SG_APISHARED_EXPORT SSX_BQworkpieceResult sx_BQ_getWorkpieceCorners( #if _OUTPUT_DEBUG_DATA SSX_debugInfo* debug_conturs, #endif -<<<<<<< HEAD int* errCode); -======= - int* errCode); ->>>>>>> 19b51a73a7f69f892049985dacce8d76724f405c diff --git a/sourceCode/SG_algo_Export.h b/sourceCode/SG_algo_Export.h new file mode 100644 index 0000000..2ab702e --- /dev/null +++ b/sourceCode/SG_algo_Export.h @@ -0,0 +1,22 @@ +#pragma once + +#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) +# define Q_DECL_EXPORT __declspec(dllexport) +# define Q_DECL_IMPORT __declspec(dllimport) +#else +# define Q_DECL_EXPORT __attribute__((visibility("default"))) +# define Q_DECL_IMPORT __attribute__((visibility("default"))) +#endif + +#if defined(SG_API_LIBRARY) +# define SG_APISHARED_EXPORT Q_DECL_EXPORT +#else +# define SG_APISHARED_EXPORT Q_DECL_IMPORT +#endif + +#include "SG_baseDataType.h" + + +#ifndef M_PI +#define M_PI 3.14159265358979323846 // pi +#endif // !M_PI diff --git a/sourceCode/SG_bagPositioning_Export.h b/sourceCode/SG_bagPositioning_Export.h index 8843db6..0fbfd4a 100644 --- a/sourceCode/SG_bagPositioning_Export.h +++ b/sourceCode/SG_bagPositioning_Export.h @@ -4,8 +4,7 @@ #define BAG_ALGO_USE_CORNER_FEATURE 1 #define RGN_HIST_SIZE 16 //目标颜色统计的数目 -#include "SG_baseAlgo_Export.h" -#include "SG_baseDataType.h" +#include "SG_algo_Export.h" #include typedef struct diff --git a/sourceCode/SG_baseAlgo_Export.h b/sourceCode/SG_baseAlgo_Export.h index 511d5d4..15c318f 100644 --- a/sourceCode/SG_baseAlgo_Export.h +++ b/sourceCode/SG_baseAlgo_Export.h @@ -1,12 +1,5 @@ #pragma once - -#if defined(SG_API_LIBRARY) -# define SG_APISHARED_EXPORT __declspec(dllexport) -#else -# define SG_APISHARED_EXPORT __declspec(dllimport) -#endif - -#include "SG_baseDataType.h" +#include "SG_algo_Export.h" #include #include diff --git a/sourceCode/SG_baseFunc.cpp b/sourceCode/SG_baseFunc.cpp index 1dd952f..20afe9d 100644 --- a/sourceCode/SG_baseFunc.cpp +++ b/sourceCode/SG_baseFunc.cpp @@ -1,12 +1,16 @@ #include "SG_baseDataType.h" #include "SG_baseAlgo_Export.h" #include +#ifdef __WIN32 #include +#endif // __WIN32 + #include #include -//计算扫描ROI + SVzNL3DRangeD sg_getScanDataROI( +//计算扫描ROI SVzNL3DLaserLine* laser3DPoints, int lineNum) { diff --git a/sourceCode/SX_lapWeldDetection_Export.h b/sourceCode/SX_lapWeldDetection_Export.h index 137ca8f..55673c5 100644 --- a/sourceCode/SX_lapWeldDetection_Export.h +++ b/sourceCode/SX_lapWeldDetection_Export.h @@ -1,9 +1,7 @@ #pragma once -#include "SG_baseAlgo_Export.h" -#include "SG_baseDataType.h" +#include "SG_algo_Export.h" #include -#include typedef enum { diff --git a/sourceCode/WD_noiseFilter.cpp b/sourceCode/WD_noiseFilter.cpp new file mode 100644 index 0000000..269ea27 --- /dev/null +++ b/sourceCode/WD_noiseFilter.cpp @@ -0,0 +1,62 @@ +#include "SG_baseDataType.h" +#include "SG_baseAlgo_Export.h" +#include + +void wd_noiseFilter( + std::vector< std::vector>& scanLines, + const SSG_outlierFilterParam filterParam, + int* errCode) +{ + *errCode = 0; + int lineNum = (int)scanLines.size(); + int nPointCnt = (int)scanLines[0].size(); + bool vldGrid = true; + //垂直方向过滤 + for (int i = 0; i < lineNum; i++) + { + if (nPointCnt != (int)scanLines[i].size()) + vldGrid = false; + wd_vectorDataRemoveOutlier_overwrite( + scanLines[i], + filterParam); + } + if (false == vldGrid) + { + *errCode = SG_ERR_3D_DATA_INVLD; + return; + } + //水平方向过滤 + int hLineNum = nPointCnt; //Grid格式,所有扫描线的点数是一样的 + //生成水平扫描数据 + std::vector> filterHLines; + filterHLines.resize(hLineNum); + for (int i = 0; i < hLineNum; i++) + filterHLines[i].resize(lineNum); + for (int line = 0; line < lineNum; line++) + { + for (int j = 0; j < hLineNum; j++) + { + filterHLines[j][line] = scanLines[line][j]; + filterHLines[j][line].pt3D.x = scanLines[line][j].pt3D.y; + filterHLines[j][line].pt3D.y = scanLines[line][j].pt3D.x; + } + } + for (int hLine = 0; hLine < hLineNum; hLine++) + { + //滤波,滤除异常点 + std::vector filterData; + std::vector lineNoise; + sg_lineDataRemoveOutlier( + (SVzNL3DPosition*)filterHLines[hLine].data(), + (int)filterHLines[hLine].size(), + filterParam, + filterData, + lineNoise); + for (int j = 0; j < lineNoise.size(); j++) + { + int lineIdx = lineNoise[j]; + scanLines[lineIdx][hLine].pt3D.z = 0; + } + } + return; +} diff --git a/sourceCode/WD_particleSizeMeasure_Export.h b/sourceCode/WD_particleSizeMeasure_Export.h index 62d26cb..3f38a3f 100644 --- a/sourceCode/WD_particleSizeMeasure_Export.h +++ b/sourceCode/WD_particleSizeMeasure_Export.h @@ -1,9 +1,7 @@ #pragma once -#include "SG_baseAlgo_Export.h" -#include "SG_baseDataType.h" +#include "SG_algo_Export.h" #include -#include #define OUTPUT_DEBUG 0 diff --git a/sourceCode/aruco.hpp b/sourceCode/aruco.hpp new file mode 100644 index 0000000..3693c38 --- /dev/null +++ b/sourceCode/aruco.hpp @@ -0,0 +1,103 @@ +// This file is part of OpenCV project. +// It is subject to the license terms in the LICENSE file found in the top-level directory +// of this distribution and at http://opencv.org/license.html +#ifndef OPENCV_ARUCO_HPP +#define OPENCV_ARUCO_HPP + +#include "opencv2/objdetect/aruco_detector.hpp" +#include "aruco/aruco_calib.hpp" + +namespace cv { +namespace aruco { + +/** + * @defgroup aruco Aruco markers, module functionality was moved to objdetect module + * @{ + * ArUco Marker Detection, module functionality was moved to objdetect module + * @sa ArucoDetector, CharucoDetector, Board, GridBoard, CharucoBoard + * @} + */ + +//! @addtogroup aruco +//! @{ + +/** @brief detect markers +@deprecated Use class ArucoDetector::detectMarkers +*/ +CV_EXPORTS_W void detectMarkers(InputArray image, const Ptr &dictionary, OutputArrayOfArrays corners, + OutputArray ids, const Ptr ¶meters = makePtr(), + OutputArrayOfArrays rejectedImgPoints = noArray()); + +/** @brief refine detected markers +@deprecated Use class ArucoDetector::refineDetectedMarkers +*/ +CV_EXPORTS_W void refineDetectedMarkers(InputArray image,const Ptr &board, + InputOutputArrayOfArrays detectedCorners, + InputOutputArray detectedIds, InputOutputArrayOfArrays rejectedCorners, + InputArray cameraMatrix = noArray(), InputArray distCoeffs = noArray(), + float minRepDistance = 10.f, float errorCorrectionRate = 3.f, + bool checkAllOrders = true, OutputArray recoveredIdxs = noArray(), + const Ptr ¶meters = makePtr()); + +/** @brief draw planar board +@deprecated Use Board::generateImage +*/ +CV_EXPORTS_W void drawPlanarBoard(const Ptr &board, Size outSize, OutputArray img, int marginSize, + int borderBits); + +/** @brief get board object and image points +@deprecated Use Board::matchImagePoints +*/ +CV_EXPORTS_W void getBoardObjectAndImagePoints(const Ptr &board, InputArrayOfArrays detectedCorners, + InputArray detectedIds, OutputArray objPoints, OutputArray imgPoints); + + +/** @deprecated Use Board::matchImagePoints and cv::solvePnP + */ +CV_EXPORTS_W int estimatePoseBoard(InputArrayOfArrays corners, InputArray ids, const Ptr &board, + InputArray cameraMatrix, InputArray distCoeffs, InputOutputArray rvec, + InputOutputArray tvec, bool useExtrinsicGuess = false); + +/** + * @brief Pose estimation for a ChArUco board given some of their corners + * @param charucoCorners vector of detected charuco corners + * @param charucoIds list of identifiers for each corner in charucoCorners + * @param board layout of ChArUco board. + * @param cameraMatrix input 3x3 floating-point camera matrix + * \f$A = \vecthreethree{f_x}{0}{c_x}{0}{f_y}{c_y}{0}{0}{1}\f$ + * @param distCoeffs vector of distortion coefficients + * \f$(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6],[s_1, s_2, s_3, s_4]])\f$ of 4, 5, 8 or 12 elements + * @param rvec Output vector (e.g. cv::Mat) corresponding to the rotation vector of the board + * (see cv::Rodrigues). + * @param tvec Output vector (e.g. cv::Mat) corresponding to the translation vector of the board. + * @param useExtrinsicGuess defines whether initial guess for \b rvec and \b tvec will be used or not. + * + * This function estimates a Charuco board pose from some detected corners. + * The function checks if the input corners are enough and valid to perform pose estimation. + * If pose estimation is valid, returns true, else returns false. + * @deprecated Use CharucoBoard::matchImagePoints and cv::solvePnP + * @sa use cv::drawFrameAxes to get world coordinate system axis for object points + */ +CV_EXPORTS_W bool estimatePoseCharucoBoard(InputArray charucoCorners, InputArray charucoIds, + const Ptr &board, InputArray cameraMatrix, + InputArray distCoeffs, InputOutputArray rvec, + InputOutputArray tvec, bool useExtrinsicGuess = false); + +/** @deprecated Use cv::solvePnP + */ +CV_EXPORTS_W void estimatePoseSingleMarkers(InputArrayOfArrays corners, float markerLength, + InputArray cameraMatrix, InputArray distCoeffs, + OutputArray rvecs, OutputArray tvecs, OutputArray objPoints = noArray(), + const Ptr& estimateParameters = makePtr()); + + +/** @deprecated Use CharucoBoard::checkCharucoCornersCollinear + */ +CV_EXPORTS_W bool testCharucoCornersCollinear(const Ptr &board, InputArray charucoIds); + +//! @} + +} +} + +#endif diff --git a/sourceCode/beltTearingDetection_Export.h b/sourceCode/beltTearingDetection_Export.h index 10b85cc..34b0391 100644 --- a/sourceCode/beltTearingDetection_Export.h +++ b/sourceCode/beltTearingDetection_Export.h @@ -1,22 +1,6 @@ #pragma once - -#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__) -# define Q_DECL_EXPORT __declspec(dllexport) -# define Q_DECL_IMPORT __declspec(dllimport) -#else -# define Q_DECL_EXPORT __attribute__((visibility("default"))) -# define Q_DECL_IMPORT __attribute__((visibility("default"))) -#endif - -#if defined(SG_API_LIBRARY) -# define SG_BELTSHARED_EXPORT Q_DECL_EXPORT -#else -# define SG_BELTSHARED_EXPORT Q_DECL_IMPORT -#endif - - -#include "SG_baseDataType.h" +#include "SG_algo_Export.h" #include #define ENABLE_CROSS_WISE_TEAR 0 @@ -91,7 +75,7 @@ typedef struct }SSG_hLineProInfo; -SG_BELTSHARED_EXPORT void sg_detectBeltTearing( +SG_APISHARED_EXPORT void sg_detectBeltTearing( SVzNL3DLaserLine* laser3DPoints, //一条扫描线 int lineIdx, int nPointCount, //每条扫描线的点数量。当采用Grid数据格式时,每条扫描线的点的数量是相同的。必须使用Grid格式 diff --git a/sourceCode/binocularMarkCam_Export.h b/sourceCode/binocularMarkCam_Export.h index cb80557..45e7c25 100644 --- a/sourceCode/binocularMarkCam_Export.h +++ b/sourceCode/binocularMarkCam_Export.h @@ -1,16 +1,9 @@ #pragma once -#if defined(SG_API_LIBRARY) -# define WD_APISHARED_EXPORT __declspec(dllexport) -#else -# define WD_APISHARED_EXPORT __declspec(dllimport) -#endif - -#include "SG_baseDataType.h" +#include "SG_algo_Export.h" #include #include - typedef struct { cv::Size patternSize; //3x3 mark @@ -26,10 +19,10 @@ typedef struct int boardChaucoIDNum; //每块Mark的charuco码的数量。对于3x3的charuco, 二维码的个数为4 }SWD_BQ_MarkBoardInfo; //读版本号 -WD_APISHARED_EXPORT const char* wd_charuco3DMarkVersion(void); +SG_APISHARED_EXPORT const char* wd_charuco3DMarkVersion(void); //提取查科Mark3D信息 -WD_APISHARED_EXPORT void wd_BQ_getCharuco3DMark( +SG_APISHARED_EXPORT void wd_BQ_getCharuco3DMark( cv::Mat& leftImage, cv::Mat& rightImage, cv::Mat& cameraMatrixL,