2025-12-29 01:16:58 +08:00
|
|
|
|
#ifndef IVRCONFIG_H
|
|
|
|
|
|
#define IVRCONFIG_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
|
|
|
|
// 包含公共配置结构体
|
|
|
|
|
|
#include "VrCommonConfig.h"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 海康相机配置参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct HikCameraConfig
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string ip = "192.168.10.64"; // 相机IP地址
|
|
|
|
|
|
int port = 8000; // 端口号
|
|
|
|
|
|
std::string username = ""; // 用户名
|
|
|
|
|
|
std::string password = ""; // 密码
|
|
|
|
|
|
int channelNo = 1; // 通道号
|
|
|
|
|
|
int streamType = 0; // 码流类型:0-主码流,1-子码流
|
|
|
|
|
|
bool enabled = true; // 是否启用
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 隧道检测参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct TunnelDetectionParam
|
|
|
|
|
|
{
|
|
|
|
|
|
double threshold = 50.0; // 检测阈值
|
|
|
|
|
|
double minArea = 1000.0; // 最小区域面积
|
|
|
|
|
|
double maxArea = 100000.0; // 最大区域面积
|
|
|
|
|
|
bool enableAlarm = true; // 是否启用报警
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-01-07 00:34:37 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 通道间距测量算法参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct ChannelSpaceAlgoParam
|
|
|
|
|
|
{
|
|
|
|
|
|
// 角点检测参数
|
|
|
|
|
|
double minEndingGap = 20.0; // Y方向跳变阈值 (mm)
|
|
|
|
|
|
double minEndingGap_z = 50.0; // Z方向跳变阈值 (mm)
|
|
|
|
|
|
double scale = 15.0; // 窗口比例
|
|
|
|
|
|
double cornerTh = 45.0; // 空间角阈值 (°)
|
|
|
|
|
|
double jumpCornerTh_1 = 15.0; // 跳变角阈值1 (°)
|
|
|
|
|
|
double jumpCornerTh_2 = 60.0; // 跳变角阈值2 (°)
|
|
|
|
|
|
|
|
|
|
|
|
// 离群点过滤参数
|
|
|
|
|
|
double continuityTh = 20.0; // 连续性阈值 (mm)
|
|
|
|
|
|
double outlierTh = 5.0; // 离群点阈值
|
|
|
|
|
|
|
|
|
|
|
|
// 树生长参数
|
|
|
|
|
|
double yDeviationMax = 20.0; // Y方向最大偏差 (mm)
|
|
|
|
|
|
double zDeviationMax = 50.0; // Z方向最大偏差 (mm)
|
|
|
|
|
|
int maxLineSkipNum = 10; // 最大跳过线数
|
|
|
|
|
|
double maxSkipDistance = 20.0; // 最大跳过距离 (mm)
|
|
|
|
|
|
double minLTypeTreeLen = 100.0; // L型树最小长度 (mm)
|
|
|
|
|
|
double minVTypeTreeLen = 100.0; // V型树最小长度 (mm)
|
|
|
|
|
|
|
|
|
|
|
|
// 通道参数
|
|
|
|
|
|
double channelWidthMin = 5.0; // 通道宽度最小值 (mm)
|
|
|
|
|
|
double channelWidthMax = 30.0; // 通道宽度最大值 (mm)
|
|
|
|
|
|
double channelSpaceMin = 300.0; // 通道间距最小值 (mm)
|
|
|
|
|
|
double channelSpaceMax = 800.0; // 通道间距最大值 (mm)
|
|
|
|
|
|
|
|
|
|
|
|
// 扫描方向
|
|
|
|
|
|
bool horizonScan = true; // 水平扫描(激光线平行槽道)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-12-29 01:16:58 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 算法参数配置结构
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct VrAlgorithmParams
|
|
|
|
|
|
{
|
|
|
|
|
|
VrPlaneCalibParam planeCalibParam; // 平面校准参数
|
|
|
|
|
|
TunnelDetectionParam tunnelParam; // 隧道检测参数
|
2026-01-07 00:34:37 +08:00
|
|
|
|
ChannelSpaceAlgoParam channelSpaceParam; // 通道间距测量算法参数
|
2025-12-29 01:16:58 +08:00
|
|
|
|
|
|
|
|
|
|
// 显式赋值构造函数,确保正确的深拷贝
|
|
|
|
|
|
VrAlgorithmParams& operator=(const VrAlgorithmParams& other) {
|
|
|
|
|
|
if (this != &other) {
|
|
|
|
|
|
planeCalibParam = other.planeCalibParam;
|
|
|
|
|
|
tunnelParam = other.tunnelParam;
|
2026-01-07 00:34:37 +08:00
|
|
|
|
channelSpaceParam = other.channelSpaceParam;
|
2025-12-29 01:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
return *this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 显式复制构造函数
|
|
|
|
|
|
VrAlgorithmParams(const VrAlgorithmParams& other)
|
|
|
|
|
|
: planeCalibParam(other.planeCalibParam)
|
2026-01-07 00:34:37 +08:00
|
|
|
|
, tunnelParam(other.tunnelParam)
|
|
|
|
|
|
, channelSpaceParam(other.channelSpaceParam) {
|
2025-12-29 01:16:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 默认构造函数
|
|
|
|
|
|
VrAlgorithmParams() = default;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 配置加载结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct ConfigResult
|
|
|
|
|
|
{
|
|
|
|
|
|
std::vector<DeviceInfo> cameraList; // 3D相机列表
|
|
|
|
|
|
std::vector<HikCameraConfig> hikCameraList; // 海康相机列表
|
|
|
|
|
|
std::vector<DeviceInfo> deviceList; // 其他设备列表
|
|
|
|
|
|
VrAlgorithmParams algorithmParams; // 算法参数
|
|
|
|
|
|
VrDebugParam debugParam; // 调试参数
|
|
|
|
|
|
SerialConfig serialConfig; // 串口配置
|
|
|
|
|
|
|
|
|
|
|
|
// 显式赋值构造函数,确保正确的深拷贝
|
|
|
|
|
|
ConfigResult& operator=(const ConfigResult& other) {
|
|
|
|
|
|
if (this != &other) {
|
|
|
|
|
|
cameraList = other.cameraList;
|
|
|
|
|
|
hikCameraList = other.hikCameraList;
|
|
|
|
|
|
deviceList = other.deviceList;
|
|
|
|
|
|
algorithmParams = other.algorithmParams;
|
|
|
|
|
|
debugParam = other.debugParam;
|
|
|
|
|
|
serialConfig = other.serialConfig;
|
|
|
|
|
|
}
|
|
|
|
|
|
return *this;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 显式复制构造函数
|
|
|
|
|
|
ConfigResult(const ConfigResult& other)
|
|
|
|
|
|
: cameraList(other.cameraList)
|
|
|
|
|
|
, hikCameraList(other.hikCameraList)
|
|
|
|
|
|
, deviceList(other.deviceList)
|
|
|
|
|
|
, algorithmParams(other.algorithmParams)
|
|
|
|
|
|
, debugParam(other.debugParam)
|
|
|
|
|
|
, serialConfig(other.serialConfig) {
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 默认构造函数
|
|
|
|
|
|
ConfigResult() = default;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 配置加载错误代码
|
|
|
|
|
|
*/
|
|
|
|
|
|
enum LoadConfigErrorCode
|
|
|
|
|
|
{
|
|
|
|
|
|
LOAD_CONFIG_SUCCESS = 0, // 加载成功
|
|
|
|
|
|
LOAD_CONFIG_FILE_NOT_FOUND = -1, // 配置文件不存在
|
|
|
|
|
|
LOAD_CONFIG_PARSE_ERROR = -2, // 配置文件解析错误
|
|
|
|
|
|
LOAD_CONFIG_INVALID_FORMAT = -3, // 配置文件格式无效
|
|
|
|
|
|
LOAD_CONFIG_UNKNOWN_ERROR = -99 // 未知错误
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief VrConfig接口类
|
|
|
|
|
|
*/
|
|
|
|
|
|
class IVrConfig
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 虚析构函数
|
|
|
|
|
|
*/
|
|
|
|
|
|
virtual ~IVrConfig() {}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 创建实例
|
|
|
|
|
|
* @return 实例
|
|
|
|
|
|
*/
|
|
|
|
|
|
static bool CreateInstance(IVrConfig** ppVrConfig);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 加载配置文件
|
|
|
|
|
|
* @param filePath 配置文件路径
|
|
|
|
|
|
* @param configResult 输出参数,加载的配置结果
|
|
|
|
|
|
* @return 错误代码 (LoadConfigErrorCode): 0=成功, 负值表示错误
|
|
|
|
|
|
*/
|
|
|
|
|
|
virtual int LoadConfig(const std::string& filePath, ConfigResult& configResult) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 保存配置文件
|
|
|
|
|
|
* @param filePath 配置文件路径
|
|
|
|
|
|
* @param configResult 配置结果
|
|
|
|
|
|
* @return 是否保存成功
|
|
|
|
|
|
*/
|
|
|
|
|
|
virtual bool SaveConfig(const std::string& filePath, ConfigResult& configResult) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 设置配置改变通知回调
|
|
|
|
|
|
* @param notify 通知接口指针
|
|
|
|
|
|
*/
|
|
|
|
|
|
virtual void SetConfigChangeNotify(IVrConfigChangeNotify* notify) = 0;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // IVRCONFIG_H
|