#ifndef IVRCONFIG_H #define IVRCONFIG_H #include #include #include #include #include #include "ILedDisplayDevice.h" #include "IRsLidarDevice.h" #include "IVisionApplicationStatus.h" #include "VrCommonConfig.h" struct VrParkingSpaceGuideParam { double minGuideDistance = 200.0; double maxGuideDistance = 8000.0; double targetStopOffset = 500.0; double lateralTolerance = 100.0; double angleTolerance = 5.0; double confidenceThreshold = 0.60; }; struct VrAlgorithmParams { VrParkingSpaceGuideParam guideParam; VrAlgorithmParams() = default; VrAlgorithmParams(const VrAlgorithmParams&) = default; VrAlgorithmParams& operator=(const VrAlgorithmParams&) = default; }; struct UdpBroadcastConfig { bool enabled = false; std::string address = "239.255.0.1"; int port = 8800; std::string targetId = "T001"; std::string parkId = "P01"; }; struct MvsCameraConfig { bool enabled = true; std::string serialNumber; int deviceIndex = 0; }; struct HttpServerConfig { bool enabled = true; std::string address = "0.0.0.0"; int port = 8801; int maxQueued = 16; int maxThreads = 4; }; struct ConfigResult { std::vector cameraList; MvsCameraConfig mvsCamera; RsLidarConfig lidarConfig; LedDisplayConfig ledDisplayConfig; UdpBroadcastConfig udpBroadcastConfig; HttpServerConfig httpServerConfig; VrAlgorithmParams algorithmParams; VrDebugParam debugParam; ConfigResult() = default; ConfigResult(const ConfigResult&) = default; ConfigResult& operator=(const ConfigResult&) = default; void Normalize() { cameraList.clear(); DeviceInfo camera; camera.index = 1; camera.name = "平面相机"; camera.ip = mvsCamera.serialNumber; camera.baseDistance = 0.0; cameraList.push_back(camera); if (mvsCamera.deviceIndex < 0) { mvsCamera.deviceIndex = 0; } if (udpBroadcastConfig.address.empty()) { udpBroadcastConfig.address = "239.255.0.1"; } if (udpBroadcastConfig.port <= 0 || udpBroadcastConfig.port > 65535) { udpBroadcastConfig.port = 8800; } if (udpBroadcastConfig.targetId.empty()) { udpBroadcastConfig.targetId = "T001"; } if (udpBroadcastConfig.parkId.empty()) { udpBroadcastConfig.parkId = "P01"; } if (httpServerConfig.address.empty()) { httpServerConfig.address = "0.0.0.0"; } if (httpServerConfig.port <= 0 || httpServerConfig.port > 65535) { httpServerConfig.port = 8801; } if (httpServerConfig.maxQueued <= 0) { httpServerConfig.maxQueued = 16; } if (httpServerConfig.maxThreads <= 0) { httpServerConfig.maxThreads = 4; } if (ledDisplayConfig.ip.empty()) { ledDisplayConfig.ip = "192.168.1.100"; } if (ledDisplayConfig.port <= 0 || ledDisplayConfig.port > 65535) { ledDisplayConfig.port = 5005; } if (ledDisplayConfig.slaveId < 0 || ledDisplayConfig.slaveId > 65535) { ledDisplayConfig.slaveId = 0xFFFE; } if (ledDisplayConfig.startAddress < 0 || ledDisplayConfig.startAddress > 31) { ledDisplayConfig.startAddress = 0; } if (ledDisplayConfig.timeoutMs < 100) { ledDisplayConfig.timeoutMs = 1000; } if (ledDisplayConfig.controllerType < 0 || ledDisplayConfig.controllerType > 255) { ledDisplayConfig.controllerType = 0xFE; } if (ledDisplayConfig.areaX < 0) { ledDisplayConfig.areaX = 0; } if (ledDisplayConfig.areaY < 0) { ledDisplayConfig.areaY = 0; } if (ledDisplayConfig.areaWidth <= 0) { ledDisplayConfig.areaWidth = 64; } if (ledDisplayConfig.areaHeight <= 0) { ledDisplayConfig.areaHeight = 32; } if (ledDisplayConfig.dynamicTimeoutSec < 0 || ledDisplayConfig.dynamicTimeoutSec > 65535) { ledDisplayConfig.dynamicTimeoutSec = 10; } if (ledDisplayConfig.displayMode < 1 || ledDisplayConfig.displayMode > 7) { ledDisplayConfig.displayMode = 1; } if (ledDisplayConfig.speed < 0 || ledDisplayConfig.speed > 24) { ledDisplayConfig.speed = 2; } if (ledDisplayConfig.stayTime < 0 || ledDisplayConfig.stayTime > 255) { ledDisplayConfig.stayTime = 10; } } }; 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; }; struct ParkingSpaceGuidePosition : public PositionData { ParkingSpaceGuidePosition() : PositionData() {} ParkingSpaceGuidePosition(double x, double y, double z, double roll, double pitch, double yaw) : PositionData(x, y, z, roll, pitch, yaw) { } }; struct ParkingSpaceGuideInfo { QString targetId; QString parkId; QString modelType; bool hasException = false; double distance = 0.0; double lateralOffset = 0.0; double angle = 0.0; double aircraftSpeed = 0.0; double confidence = 0.0; int guideStateCode = 0; QString guideText; }; struct DetectionResult : public DetectionResultData { std::vector parkingSpaceInfoList; QString message; }; struct ParkingSpaceGuideDetectOutput { bool success = true; int errorCode = 0; QString message; int cameraIndex = 1; qint64 timestamp = 0; std::vector guideOutputs; }; Q_DECLARE_METATYPE(ParkingSpaceGuidePosition) Q_DECLARE_METATYPE(ParkingSpaceGuideInfo) Q_DECLARE_METATYPE(DetectionResult) #endif // IVRCONFIG_H