2026-04-19 12:28:59 +08:00

164 lines
4.0 KiB
C++

#ifndef IVRCONFIG_H
#define IVRCONFIG_H
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
#include <QString>
#include "VrCommonConfig.h"
#include "VrHandEyeCalibConfig.h"
struct VrScrewParam
{
double rodDiameter = 10.0;
bool isHorizonScan = true;
};
struct VrCornerParam
{
double minEndingGap = 20.0;
double minEndingGap_z = 5.0;
double scale = 2.5;
double cornerTh = 60.0;
double jumpCornerTh_1 = 15.0;
double jumpCornerTh_2 = 60.0;
};
struct VrOutlierFilterParam
{
double continuityTh = 20.0;
double outlierTh = 5.0;
};
struct VrTreeGrowParam
{
double yDeviation_max = 20.0;
double zDeviation_max = 50.0;
int maxLineSkipNum = 10;
double maxSkipDistance = 20.0;
double minLTypeTreeLen = 10.0;
double minVTypeTreeLen = 10.0;
};
struct VrAlgorithmParams
{
VrScrewParam screwParam;
VrCornerParam cornerParam;
VrOutlierFilterParam filterParam;
VrTreeGrowParam growParam;
VrPlaneCalibParam planeCalibParam;
};
struct ConfigResult
{
std::vector<DeviceInfo> cameraList;
VrDebugParam debugParam;
SerialConfig serialConfig;
uint16_t tcpPort = 7800;
int eulerOrder = 11;
int outputEulerOrder = 10;
int poseOutputOrder = 0;
int dirVectorInvert = 0;
int byteOrder = 0;
int longAxisDir = 0;
std::vector<VrHandEyeCalibMatrix> handEyeCalibMatrixList;
VrAlgorithmParams algorithmParams;
ConfigResult& operator=(const ConfigResult& other)
{
if (this != &other) {
cameraList = other.cameraList;
debugParam = other.debugParam;
serialConfig = other.serialConfig;
tcpPort = other.tcpPort;
eulerOrder = other.eulerOrder;
outputEulerOrder = other.outputEulerOrder;
poseOutputOrder = other.poseOutputOrder;
dirVectorInvert = other.dirVectorInvert;
byteOrder = other.byteOrder;
longAxisDir = other.longAxisDir;
handEyeCalibMatrixList = other.handEyeCalibMatrixList;
algorithmParams = other.algorithmParams;
}
return *this;
}
ConfigResult(const ConfigResult& other)
: cameraList(other.cameraList)
, debugParam(other.debugParam)
, serialConfig(other.serialConfig)
, tcpPort(other.tcpPort)
, eulerOrder(other.eulerOrder)
, outputEulerOrder(other.outputEulerOrder)
, poseOutputOrder(other.poseOutputOrder)
, dirVectorInvert(other.dirVectorInvert)
, byteOrder(other.byteOrder)
, longAxisDir(other.longAxisDir)
, handEyeCalibMatrixList(other.handEyeCalibMatrixList)
, algorithmParams(other.algorithmParams)
{
}
ConfigResult() = default;
};
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() {}
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;
};
enum DetectionType {
DETECTION_TYPE_SCREW = 1,
DETECTION_TYPE_TOOL_DISK = 2
};
struct ScrewDetectOutput {
double x = 0.0;
double y = 0.0;
double z = 0.0;
double roll = 0.0;
double pitch = 0.0;
double yaw = 0.0;
};
struct ToolDiskDetectOutput {
double x = 0.0;
double y = 0.0;
double z = 0.0;
double roll = 0.0;
double pitch = 0.0;
double yaw = 0.0;
};
struct ProtocolDetectionOutput {
DetectionType type = DETECTION_TYPE_SCREW;
bool success = true;
int errorCode = 0;
QString message;
int cameraIndex = 0;
qint64 timestamp = 0;
std::vector<ScrewDetectOutput> screwOutputs;
std::vector<ToolDiskDetectOutput> toolDiskOutputs;
};
#endif // IVRCONFIG_H