2026-08-18 14:44:38 +08:00

102 lines
2.6 KiB
C++

#ifndef WELDSEAM_IVRCONFIG_H
#define WELDSEAM_IVRCONFIG_H
#include <cstdint>
#include <string>
#include <vector>
#include "VrCommonConfig.h"
#include "VrHandEyeCalibConfig.h"
// 参数默认值与 AppAlgo/lapWeldDetection/lapWeldDetection_test.cpp
// 中 BQ_thinWeldSeamTest 的 BQ_getWeldSeamPose 调用保持一致。
struct VrValleyParam
{
double chkWinWidth = 2.5;
double maxWidth = 20.0;
double minHeight = 1.0;
};
struct VrTreeGrowParam
{
int maxLineSkipNum = 50;
double yDeviationMax = 1.0;
double maxSkipDistance = 30.0;
double zDeviationMax = 5.0;
double minLTypeTreeLen = 50.0;
double minVTypeTreeLen = 50.0;
};
struct VrWeldSeamParam
{
int weldRefPoints = 3;
};
struct VrAlgorithmParams
{
VrValleyParam valleyParam;
VrTreeGrowParam treeGrowParam;
VrWeldSeamParam weldSeamParam;
VrPlaneCalibParam planeCalibParam;
};
struct ConfigResult
{
std::vector<DeviceInfo> cameraList;
VrAlgorithmParams algorithmParams;
std::vector<VrHandEyeCalibMatrix> handEyeCalibMatrixList;
VrDebugParam debugParam;
SerialConfig serialConfig;
uint16_t tcpPort = 7800;
int eulerOrder = 11;
int outputEulerOrder = 10;
int poseOutputOrder = 0;
int byteOrder = 0;
const VrHandEyeCalibMatrix* FindHandEyeMatrix(int cameraIndex) const
{
for (const auto& item : handEyeCalibMatrixList) {
if (item.cameraIndex == cameraIndex) return &item;
}
return nullptr;
}
VrHandEyeCalibMatrix* FindHandEyeMatrix(int cameraIndex)
{
for (auto& item : handEyeCalibMatrixList) {
if (item.cameraIndex == cameraIndex) return &item;
}
return nullptr;
}
VrHandEyeCalibMatrix& EnsureHandEyeMatrix(int cameraIndex)
{
if (auto* item = FindHandEyeMatrix(cameraIndex)) return *item;
VrHandEyeCalibMatrix item;
item.cameraIndex = cameraIndex;
handEyeCalibMatrixList.push_back(item);
return handEyeCalibMatrixList.back();
}
};
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
};
class IVrConfig
{
public:
virtual ~IVrConfig() = default;
static bool CreateInstance(IVrConfig** ppVrConfig);
virtual int LoadConfig(const std::string& filePath, ConfigResult& configResult) = 0;
virtual bool SaveConfig(const std::string& filePath, ConfigResult& configResult) = 0;
virtual void SetConfigChangeNotify(IVrConfigChangeNotify* notify) = 0;
};
#endif // WELDSEAM_IVRCONFIG_H