algoLib/sourceCode/beltTearingDetection_Export.h
2025-06-08 10:46:41 +08:00

94 lines
2.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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 <vector>
#define ENABLE_CROSS_WISE_TEAR 0
#define OUTPUT_TEARING_POINTS 1
#define KEEP_GAP_AS_FEATURE 1
#define SCAN_BUFF_SIZE 21 //缓存区大小缓存21条扫描线处理中间扫描线
typedef struct
{
double scanXScale; //3D扫描的X精度取决于两条扫描线的间距。
double scanYScale; //3D扫描的Y精度取决于点间距。scanXScale和scanYScale可以在现场安装后扫描数据得到
double differnceBinTh; //一阶差分二值化门限。其物理意义为撕裂斜面的斜率值。默认为1.0
SSG_tearFeatureExtactPara extractPara;
double tearingMinLen; //最小撕裂长度,达到此长度时输出撕裂
double tearingMinGap; //两个同位置的撕裂的间隔。小于此间隔时,视为同一个撕裂。
}SSG_beltTearingParam;
typedef enum
{
keSG_tearType_Uknown = 0,
keSG_tearType_MachineDir, //纵撕
keSG_tearType_CrossWise,//横撕
}ESG_tearType;
typedef enum
{
keSG_tearStatus_Uknown = 0,
keSG_tearStatus_New, //新发现的撕裂
keSG_tearStatus_Growing, //持续的撕裂
keSG_tearStatus_Ended, //撕裂结束
keSG_tearStatus_Invalid, //无效撕裂(可能被合并)
}ESG_tearStatus;
typedef struct
{
int tearID; //每个撕裂有个唯一的序号
ESG_tearStatus tearStatus;
ESG_tearType tearType;
int statLineIdx; //撕裂开始时的扫描线序号
int endLineIdx; //撕裂结束时的扫描线序号,当撕裂持续时,为最新的扫描线序号
double tearDepth;//撕裂深度。-1表示是贯穿型撕裂
double tearWidth;//撕裂宽度
SSG_ROIRectD roi; //撕裂的ROI范围为{左,右,上,下}
#if OUTPUT_TEARING_POINTS
std::vector<SVzNL3DPosition> pts; //撕裂的边界点debug或显示目的
#endif
}SSG_beltTearingInfo;
//处理状态机
typedef enum
{
keSG_HLineProc_Init = 0, //初态
keSG_HLineProc_First_Half,
keSG_HLineProc_Wait_Second,
keSG_HLineProc_Second_Half,
}ESG_HLineProcSM;
typedef struct
{
int hLineIdx;
//SVzNL3DPosition scanBuff[SCAN_BUFF_SIZE]; //循环buff
//int buffHead;//循环buff的头位置
//int buffSize;//循环buff
SVzNL3DPosition preVldData;
SVzNL3DPosition gapPos;
ESG_HLineProcSM hLineSM; //水平扫描线处理状态机
SSG_RUN firstHalf;
SVzNL3DPosition firstHalf_startPt;
SVzNL3DPosition firstHalf_endPt;
SSG_RUN secondHalf;
SVzNL3DPosition secondHalf_startPt;
SVzNL3DPosition secondHalf_endPt;
double gapMaxZ;
}SSG_hLineProInfo;
SG_APISHARED_EXPORT void sg_detectBeltTearing(
SVzNL3DLaserLine* laser3DPoints, //一条扫描线
int lineIdx,
int nPointCount, //每条扫描线的点数量。当采用Grid数据格式时每条扫描线的点的数量是相同的。必须使用Grid格式
int* errCode,
std::vector<SSG_hLineProInfo>& hLineWorkers,
std::vector<SSG_beltTearingInfo>& beltTearings_new,
std::vector<SSG_beltTearingInfo>& beltTearings_growing,
std::vector<SSG_beltTearingInfo>& beltTearings_ended,
std::vector<SSG_beltTearingInfo>& beltTearings_unknown, //未判明,应用无需处理。
const SSG_beltTearingParam measureParam);