632 lines
24 KiB
C++
632 lines
24 KiB
C++
#ifndef IVRCONFIG_H
|
|
#define IVRCONFIG_H
|
|
|
|
#include <algorithm>
|
|
#include <cstdint>
|
|
#include <cmath>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include <QMetaType>
|
|
#include <QString>
|
|
|
|
#include "ILedDisplayDevice.h"
|
|
#include "IRsLidarDevice.h"
|
|
#include "IVisionApplicationStatus.h"
|
|
#include "VrCommonConfig.h"
|
|
|
|
struct VrGuideDecisionParam
|
|
{
|
|
double lateralTolerance = 100.0;
|
|
double angleTolerance = 5.0;
|
|
};
|
|
|
|
struct VrPlaneParkingParam
|
|
{
|
|
double parkingPointX = 0.0;
|
|
double parkingPointY = 0.0;
|
|
double parkingPointZ = 0.0;
|
|
double guideLinePointX = 0.0;
|
|
double guideLinePointY = 20000.0;
|
|
double guideLinePointZ = 0.0;
|
|
double guidingRange = 50000.0;
|
|
double parkingRange = 10000.0;
|
|
double distFromNoseToWheel = 4000.0;
|
|
};
|
|
|
|
struct VrPlaneGroundCalibrationParam
|
|
{
|
|
double planeCalib[9] = {1.0, 0.0, 0.0,
|
|
0.0, 1.0, 0.0,
|
|
0.0, 0.0, 1.0};
|
|
double planeHeight = -1.0;
|
|
double invRMatrix[9] = {1.0, 0.0, 0.0,
|
|
0.0, 1.0, 0.0,
|
|
0.0, 0.0, 1.0};
|
|
};
|
|
|
|
struct VrPlaneTreeGrowParam
|
|
{
|
|
double yDeviationMax = 300.0;
|
|
double zDeviationMax = 300.0;
|
|
int maxLineSkipNum = 10;
|
|
double maxSkipDistance = 300.0;
|
|
double minLTypeTreeLen = 500.0;
|
|
double minVTypeTreeLen = 500.0;
|
|
};
|
|
|
|
struct VrParkingProcessParam
|
|
{
|
|
double dockingStartDistance = 100000.0;
|
|
double captureStartDistance = 80000.0;
|
|
double approachStartDistance = 25000.0;
|
|
double slowDistance = 15000.0;
|
|
double stopDistanceTolerance = 100.0;
|
|
double overshootDistance = 500.0;
|
|
double stoppedShortMinDistance = 300.0;
|
|
double maxApproachSpeed = 2000.0;
|
|
double stoppedSpeedThreshold = 100.0;
|
|
double speedFilterAlpha = 0.3;
|
|
double distanceChangeThreshold = 10000.0;
|
|
double lateralOffsetChangeThreshold = 3000.0;
|
|
int stopStableFrames = 5;
|
|
int stoppedShortStableFrames = 5;
|
|
int errorFrameThreshold = 10;
|
|
int lostFrameThreshold = 5;
|
|
int completedHoldFrames = 3;
|
|
};
|
|
|
|
struct VrModelRecognitionParam
|
|
{
|
|
double modelVerifyDistance = 25000.0;
|
|
double roiX = 0.0;
|
|
double roiY = 0.0;
|
|
double roiWidth = 1.0;
|
|
double roiHeight = 1.0;
|
|
double confidenceThreshold = 0.6;
|
|
int maxRecognitionAttempts = 2;
|
|
};
|
|
|
|
struct VrPersonDetectionParam
|
|
{
|
|
bool enabled = true;
|
|
double roiX = 0.0;
|
|
double roiY = 0.0;
|
|
double roiWidth = 1.0;
|
|
double roiHeight = 1.0;
|
|
double confidenceThreshold = 0.5;
|
|
int stableFrames = 3;
|
|
int detectionIntervalMs = 500;
|
|
};
|
|
|
|
struct VrAlgorithmParams
|
|
{
|
|
VrPlaneParkingParam planeParkingParam;
|
|
VrPlaneGroundCalibrationParam groundCalibrationParam;
|
|
VrPlaneTreeGrowParam treeGrowParam;
|
|
VrGuideDecisionParam guideDecisionParam;
|
|
VrParkingProcessParam processParam;
|
|
VrModelRecognitionParam modelRecognitionParam;
|
|
VrPersonDetectionParam personDetectionParam;
|
|
|
|
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;
|
|
double frameRate = 10.0;
|
|
bool autoExposureEnabled = true;
|
|
int exposureRoiX = 0;
|
|
int exposureRoiY = 0;
|
|
int exposureRoiWidth = 0; // 0 means the remaining image width.
|
|
int exposureRoiHeight = 0; // 0 means the remaining image height.
|
|
double exposureReferenceGray = 105.0;
|
|
double exposureGrayTolerance = 10.0;
|
|
};
|
|
|
|
struct HttpServerConfig
|
|
{
|
|
bool enabled = true;
|
|
std::string address = "0.0.0.0";
|
|
int port = 8801;
|
|
int maxQueued = 16;
|
|
int maxThreads = 4;
|
|
};
|
|
|
|
struct HttpFlvStreamConfig
|
|
{
|
|
bool enabled = true;
|
|
std::string publishHost = "127.0.0.1";
|
|
int publishPort = 1935;
|
|
std::string publishPath = "/live/parking";
|
|
int httpPort = 8080; // ZLMediaKit HTTP 端口,仅用于生成展示地址
|
|
int fps = 10;
|
|
int gop = 10;
|
|
int bitrateKbps = 4096;
|
|
};
|
|
|
|
struct RemoteViewConfig
|
|
{
|
|
bool enabled = true;
|
|
int discoveryPort = 5555;
|
|
int controlPort = 15655;
|
|
int publishPort = 15656;
|
|
std::string topic = "parking_guide";
|
|
};
|
|
|
|
struct EmergencyStopConfig
|
|
{
|
|
bool enabled = true;
|
|
std::string directionPath =
|
|
"/sys/external_gpio/jwsioc_inout_gpio3";
|
|
std::string valuePath = "/sys/external_gpio/jwsioc_gpio3";
|
|
int pollIntervalMs = 10;
|
|
int debounceMs = 50;
|
|
int reconnectIntervalMs = 1000;
|
|
};
|
|
|
|
struct ConfigResult
|
|
{
|
|
std::vector<DeviceInfo> cameraList;
|
|
MvsCameraConfig mvsCamera;
|
|
RsLidarConfig lidarConfig;
|
|
LedDisplayConfig ledDisplayConfig;
|
|
UdpBroadcastConfig udpBroadcastConfig;
|
|
HttpServerConfig httpServerConfig;
|
|
HttpFlvStreamConfig httpFlvStreamConfig;
|
|
RemoteViewConfig remoteViewConfig;
|
|
EmergencyStopConfig emergencyStopConfig;
|
|
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 (!std::isfinite(mvsCamera.frameRate) ||
|
|
mvsCamera.frameRate <= 0.0 || mvsCamera.frameRate > 120.0) {
|
|
mvsCamera.frameRate = 10.0;
|
|
}
|
|
mvsCamera.exposureRoiX =
|
|
(std::max)(0, mvsCamera.exposureRoiX);
|
|
mvsCamera.exposureRoiY =
|
|
(std::max)(0, mvsCamera.exposureRoiY);
|
|
mvsCamera.exposureRoiWidth =
|
|
(std::max)(0, mvsCamera.exposureRoiWidth);
|
|
mvsCamera.exposureRoiHeight =
|
|
(std::max)(0, mvsCamera.exposureRoiHeight);
|
|
if (!std::isfinite(mvsCamera.exposureReferenceGray) ||
|
|
mvsCamera.exposureReferenceGray < 0.0 ||
|
|
mvsCamera.exposureReferenceGray > 255.0) {
|
|
mvsCamera.exposureReferenceGray = 105.0;
|
|
}
|
|
if (!std::isfinite(mvsCamera.exposureGrayTolerance) ||
|
|
mvsCamera.exposureGrayTolerance <= 0.0 ||
|
|
mvsCamera.exposureGrayTolerance > 255.0) {
|
|
mvsCamera.exposureGrayTolerance = 10.0;
|
|
}
|
|
|
|
const auto validPort = [](int port) {
|
|
return port > 0 && port <= 65535;
|
|
};
|
|
if (!validPort(remoteViewConfig.discoveryPort)) {
|
|
remoteViewConfig.discoveryPort = 5555;
|
|
}
|
|
if (!validPort(remoteViewConfig.controlPort)) {
|
|
remoteViewConfig.controlPort = 15655;
|
|
}
|
|
if (!validPort(remoteViewConfig.publishPort) ||
|
|
remoteViewConfig.publishPort == remoteViewConfig.controlPort) {
|
|
remoteViewConfig.publishPort =
|
|
remoteViewConfig.controlPort == 15656 ? 15657 : 15656;
|
|
}
|
|
if (remoteViewConfig.topic.empty()) {
|
|
remoteViewConfig.topic = "parking_guide";
|
|
}
|
|
|
|
if (emergencyStopConfig.directionPath.empty()) {
|
|
emergencyStopConfig.directionPath =
|
|
"/sys/external_gpio/jwsioc_inout_gpio3";
|
|
}
|
|
if (emergencyStopConfig.valuePath.empty()) {
|
|
emergencyStopConfig.valuePath =
|
|
"/sys/external_gpio/jwsioc_gpio3";
|
|
}
|
|
if (emergencyStopConfig.pollIntervalMs < 1 ||
|
|
emergencyStopConfig.pollIntervalMs > 1000) {
|
|
emergencyStopConfig.pollIntervalMs = 10;
|
|
}
|
|
if (emergencyStopConfig.debounceMs < 0 ||
|
|
emergencyStopConfig.debounceMs > 5000) {
|
|
emergencyStopConfig.debounceMs = 50;
|
|
}
|
|
if (emergencyStopConfig.reconnectIntervalMs < 100 ||
|
|
emergencyStopConfig.reconnectIntervalMs > 60000) {
|
|
emergencyStopConfig.reconnectIntervalMs = 1000;
|
|
}
|
|
|
|
VrGuideDecisionParam& guide = algorithmParams.guideDecisionParam;
|
|
if (!std::isfinite(guide.lateralTolerance) || guide.lateralTolerance < 0.0) {
|
|
guide.lateralTolerance = 100.0;
|
|
}
|
|
if (!std::isfinite(guide.angleTolerance) || guide.angleTolerance < 0.0 || guide.angleTolerance > 180.0) {
|
|
guide.angleTolerance = 5.0;
|
|
}
|
|
|
|
VrPlaneParkingParam& parking = algorithmParams.planeParkingParam;
|
|
if (!std::isfinite(parking.parkingPointX)) parking.parkingPointX = 0.0;
|
|
if (!std::isfinite(parking.parkingPointY)) parking.parkingPointY = 0.0;
|
|
if (!std::isfinite(parking.parkingPointZ)) parking.parkingPointZ = 0.0;
|
|
if (!std::isfinite(parking.guideLinePointX)) parking.guideLinePointX = parking.parkingPointX;
|
|
if (!std::isfinite(parking.guideLinePointY)) parking.guideLinePointY = parking.parkingPointY + 20000.0;
|
|
if (!std::isfinite(parking.guideLinePointZ)) parking.guideLinePointZ = parking.parkingPointZ;
|
|
const double guideDx = parking.guideLinePointX - parking.parkingPointX;
|
|
const double guideDy = parking.guideLinePointY - parking.parkingPointY;
|
|
const double guideDz = parking.guideLinePointZ - parking.parkingPointZ;
|
|
if (std::sqrt(guideDx * guideDx + guideDy * guideDy + guideDz * guideDz) < 20000.0) {
|
|
parking.guideLinePointX = parking.parkingPointX;
|
|
parking.guideLinePointY = parking.parkingPointY + 20000.0;
|
|
parking.guideLinePointZ = parking.parkingPointZ;
|
|
}
|
|
if (!std::isfinite(parking.guidingRange) || parking.guidingRange <= 0.0) {
|
|
parking.guidingRange = 50000.0;
|
|
}
|
|
if (!std::isfinite(parking.parkingRange) || parking.parkingRange <= 0.0) {
|
|
parking.parkingRange = 10000.0;
|
|
}
|
|
if (!std::isfinite(parking.distFromNoseToWheel) || parking.distFromNoseToWheel < 0.0) {
|
|
parking.distFromNoseToWheel = 4000.0;
|
|
}
|
|
|
|
VrPlaneGroundCalibrationParam& ground = algorithmParams.groundCalibrationParam;
|
|
for (int i = 0; i < 9; ++i) {
|
|
const double identityValue = (i % 4 == 0) ? 1.0 : 0.0;
|
|
if (!std::isfinite(ground.planeCalib[i])) ground.planeCalib[i] = identityValue;
|
|
if (!std::isfinite(ground.invRMatrix[i])) ground.invRMatrix[i] = identityValue;
|
|
}
|
|
if (!std::isfinite(ground.planeHeight)) ground.planeHeight = -1.0;
|
|
|
|
VrPlaneTreeGrowParam& tree = algorithmParams.treeGrowParam;
|
|
if (!std::isfinite(tree.yDeviationMax) || tree.yDeviationMax <= 0.0) tree.yDeviationMax = 300.0;
|
|
if (!std::isfinite(tree.zDeviationMax) || tree.zDeviationMax <= 0.0) tree.zDeviationMax = 300.0;
|
|
if (tree.maxLineSkipNum < -1) tree.maxLineSkipNum = 10;
|
|
if (!std::isfinite(tree.maxSkipDistance) || tree.maxSkipDistance < -1.0) tree.maxSkipDistance = 300.0;
|
|
if (!std::isfinite(tree.minLTypeTreeLen) || tree.minLTypeTreeLen < 0.0) tree.minLTypeTreeLen = 500.0;
|
|
if (!std::isfinite(tree.minVTypeTreeLen) || tree.minVTypeTreeLen < 0.0) tree.minVTypeTreeLen = 500.0;
|
|
|
|
VrParkingProcessParam& process = algorithmParams.processParam;
|
|
if (!std::isfinite(process.dockingStartDistance) || process.dockingStartDistance < 0.0) process.dockingStartDistance = 100000.0;
|
|
if (!std::isfinite(process.captureStartDistance) || process.captureStartDistance < 0.0) process.captureStartDistance = 80000.0;
|
|
if (!std::isfinite(process.approachStartDistance) || process.approachStartDistance < 0.0) process.approachStartDistance = 25000.0;
|
|
if (!std::isfinite(process.slowDistance) || process.slowDistance < 0.0) process.slowDistance = 15000.0;
|
|
if (!std::isfinite(process.stopDistanceTolerance) || process.stopDistanceTolerance < 0.0) process.stopDistanceTolerance = 100.0;
|
|
if (!std::isfinite(process.overshootDistance) || process.overshootDistance < 0.0) process.overshootDistance = 500.0;
|
|
if (!std::isfinite(process.stoppedShortMinDistance) || process.stoppedShortMinDistance < 0.0) process.stoppedShortMinDistance = 300.0;
|
|
if (!std::isfinite(process.maxApproachSpeed) || process.maxApproachSpeed < 0.0) process.maxApproachSpeed = 2000.0;
|
|
if (!std::isfinite(process.stoppedSpeedThreshold) || process.stoppedSpeedThreshold < 0.0) process.stoppedSpeedThreshold = 100.0;
|
|
if (!std::isfinite(process.speedFilterAlpha) || process.speedFilterAlpha < 0.0 || process.speedFilterAlpha > 1.0) process.speedFilterAlpha = 0.3;
|
|
if (!std::isfinite(process.distanceChangeThreshold) || process.distanceChangeThreshold < 0.0) process.distanceChangeThreshold = 10000.0;
|
|
if (!std::isfinite(process.lateralOffsetChangeThreshold) || process.lateralOffsetChangeThreshold < 0.0) process.lateralOffsetChangeThreshold = 3000.0;
|
|
if (process.stopStableFrames <= 0) process.stopStableFrames = 5;
|
|
if (process.stoppedShortStableFrames <= 0) process.stoppedShortStableFrames = 5;
|
|
if (process.errorFrameThreshold <= 0) process.errorFrameThreshold = 10;
|
|
if (process.lostFrameThreshold <= 0) process.lostFrameThreshold = 5;
|
|
if (process.completedHoldFrames <= 0) process.completedHoldFrames = 3;
|
|
process.slowDistance = (std::max)(
|
|
process.slowDistance,
|
|
process.stopDistanceTolerance + 1.0);
|
|
process.approachStartDistance = (std::max)(
|
|
process.approachStartDistance,
|
|
process.slowDistance + 1.0);
|
|
process.captureStartDistance = (std::max)(
|
|
process.captureStartDistance,
|
|
process.approachStartDistance + 1.0);
|
|
process.dockingStartDistance = (std::max)(
|
|
process.dockingStartDistance,
|
|
process.captureStartDistance + 1.0);
|
|
process.overshootDistance = (std::max)(process.overshootDistance,
|
|
process.stopDistanceTolerance);
|
|
process.stoppedShortMinDistance = (std::max)(process.stoppedShortMinDistance,
|
|
process.stopDistanceTolerance);
|
|
process.maxApproachSpeed = (std::max)(
|
|
process.maxApproachSpeed,
|
|
process.stoppedSpeedThreshold + 1.0);
|
|
|
|
VrModelRecognitionParam& model = algorithmParams.modelRecognitionParam;
|
|
if (!std::isfinite(model.modelVerifyDistance)) model.modelVerifyDistance = 25000.0;
|
|
if (!std::isfinite(model.roiX)) model.roiX = 0.0;
|
|
if (!std::isfinite(model.roiY)) model.roiY = 0.0;
|
|
if (!std::isfinite(model.roiWidth) || model.roiWidth <= 0.0) model.roiWidth = 1.0;
|
|
if (!std::isfinite(model.roiHeight) || model.roiHeight <= 0.0) model.roiHeight = 1.0;
|
|
model.roiX = std::clamp(model.roiX, 0.0, 1.0);
|
|
model.roiY = std::clamp(model.roiY, 0.0, 1.0);
|
|
if (model.roiX >= 1.0) model.roiX = 0.0;
|
|
if (model.roiY >= 1.0) model.roiY = 0.0;
|
|
model.roiWidth = std::clamp(model.roiWidth, 0.0, 1.0 - model.roiX);
|
|
model.roiHeight = std::clamp(model.roiHeight, 0.0, 1.0 - model.roiY);
|
|
if (model.roiWidth <= 0.0) model.roiWidth = 1.0 - model.roiX;
|
|
if (model.roiHeight <= 0.0) model.roiHeight = 1.0 - model.roiY;
|
|
if (!std::isfinite(model.confidenceThreshold) || model.confidenceThreshold < 0.0 || model.confidenceThreshold > 1.0) model.confidenceThreshold = 0.6;
|
|
if (model.maxRecognitionAttempts <= 0) model.maxRecognitionAttempts = 2;
|
|
|
|
VrPersonDetectionParam& person = algorithmParams.personDetectionParam;
|
|
if (!std::isfinite(person.roiX)) person.roiX = 0.0;
|
|
if (!std::isfinite(person.roiY)) person.roiY = 0.0;
|
|
if (!std::isfinite(person.roiWidth) || person.roiWidth <= 0.0) person.roiWidth = 1.0;
|
|
if (!std::isfinite(person.roiHeight) || person.roiHeight <= 0.0) person.roiHeight = 1.0;
|
|
person.roiX = std::clamp(person.roiX, 0.0, 1.0);
|
|
person.roiY = std::clamp(person.roiY, 0.0, 1.0);
|
|
if (person.roiX >= 1.0) person.roiX = 0.0;
|
|
if (person.roiY >= 1.0) person.roiY = 0.0;
|
|
person.roiWidth = std::clamp(person.roiWidth, 0.0, 1.0 - person.roiX);
|
|
person.roiHeight = std::clamp(person.roiHeight, 0.0, 1.0 - person.roiY);
|
|
if (person.roiWidth <= 0.0) person.roiWidth = 1.0 - person.roiX;
|
|
if (person.roiHeight <= 0.0) person.roiHeight = 1.0 - person.roiY;
|
|
if (!std::isfinite(person.confidenceThreshold) ||
|
|
person.confidenceThreshold < 0.0 ||
|
|
person.confidenceThreshold > 1.0) {
|
|
person.confidenceThreshold = 0.5;
|
|
}
|
|
if (person.stableFrames <= 0) person.stableFrames = 3;
|
|
if (person.detectionIntervalMs < 10 || person.detectionIntervalMs > 60000) {
|
|
person.detectionIntervalMs = 500;
|
|
}
|
|
|
|
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 (httpFlvStreamConfig.publishHost.empty()) {
|
|
httpFlvStreamConfig.publishHost = "127.0.0.1";
|
|
}
|
|
if (!validPort(httpFlvStreamConfig.publishPort)) {
|
|
httpFlvStreamConfig.publishPort = 1935;
|
|
}
|
|
if (httpFlvStreamConfig.publishPath.empty()) {
|
|
httpFlvStreamConfig.publishPath = "/live/parking";
|
|
} else if (httpFlvStreamConfig.publishPath.front() != '/') {
|
|
httpFlvStreamConfig.publishPath.insert(
|
|
httpFlvStreamConfig.publishPath.begin(), '/');
|
|
}
|
|
if (!validPort(httpFlvStreamConfig.httpPort)) {
|
|
httpFlvStreamConfig.httpPort = 8080;
|
|
}
|
|
if (httpFlvStreamConfig.fps < 1 || httpFlvStreamConfig.fps > 60) {
|
|
httpFlvStreamConfig.fps = 10;
|
|
}
|
|
if (httpFlvStreamConfig.gop < 1 ||
|
|
httpFlvStreamConfig.gop > httpFlvStreamConfig.fps * 10) {
|
|
httpFlvStreamConfig.gop = httpFlvStreamConfig.fps;
|
|
}
|
|
if (httpFlvStreamConfig.bitrateKbps < 128 ||
|
|
httpFlvStreamConfig.bitrateKbps > 100000) {
|
|
httpFlvStreamConfig.bitrateKbps = 4096;
|
|
}
|
|
if (remoteViewConfig.discoveryPort <= 0 ||
|
|
remoteViewConfig.discoveryPort > 65535) {
|
|
remoteViewConfig.discoveryPort = 5555;
|
|
}
|
|
if (remoteViewConfig.controlPort <= 0 ||
|
|
remoteViewConfig.controlPort > 65535) {
|
|
remoteViewConfig.controlPort = 15655;
|
|
}
|
|
if (remoteViewConfig.publishPort <= 0 ||
|
|
remoteViewConfig.publishPort > 65535) {
|
|
remoteViewConfig.publishPort = 15656;
|
|
}
|
|
if (remoteViewConfig.controlPort == remoteViewConfig.publishPort) {
|
|
remoteViewConfig.publishPort = remoteViewConfig.controlPort == 65535
|
|
? 15656
|
|
: remoteViewConfig.controlPort + 1;
|
|
}
|
|
if (remoteViewConfig.topic.empty()) {
|
|
remoteViewConfig.topic = "parking_guide";
|
|
}
|
|
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<double>
|
|
{
|
|
ParkingSpaceGuidePosition() : PositionData<double>() {}
|
|
ParkingSpaceGuidePosition(double x, double y, double z,
|
|
double roll, double pitch, double yaw)
|
|
: PositionData<double>(x, y, z, roll, pitch, yaw)
|
|
{
|
|
}
|
|
};
|
|
|
|
enum class ParkingGuideState : int
|
|
{
|
|
Unknown = 0,
|
|
DockingStarted = 1,
|
|
Capturing = 2,
|
|
Tracking = 3,
|
|
ApproachRate = 4,
|
|
CenterLineAligned = 5,
|
|
Slow = 6,
|
|
AzimuthGuidance = 7,
|
|
StopPositionReached = 8,
|
|
DockingCompleted = 9,
|
|
Overshot = 10,
|
|
StoppedShort = 11,
|
|
Waiting = 12,
|
|
SlowBadWeather = 13,
|
|
SlowAircraftLost = 14,
|
|
AircraftVerificationFailed = 15,
|
|
GateBlocked = 16,
|
|
ViewBlocked = 17,
|
|
SbuStop = 18,
|
|
TooFast = 19,
|
|
EmergencyStop = 20,
|
|
ChocksOn = 21,
|
|
SystemError = 22,
|
|
SystemFailure = 23,
|
|
PowerFailure = 24
|
|
};
|
|
|
|
inline ParkingGuideState ParkingGuideStateFromCode(int guideStateCode)
|
|
{
|
|
if (guideStateCode < static_cast<int>(ParkingGuideState::Unknown) ||
|
|
guideStateCode > static_cast<int>(ParkingGuideState::PowerFailure)) {
|
|
return ParkingGuideState::Unknown;
|
|
}
|
|
|
|
return static_cast<ParkingGuideState>(guideStateCode);
|
|
}
|
|
|
|
struct ParkingSpaceGuideInfo
|
|
{
|
|
QString targetId;
|
|
QString parkId;
|
|
QString expectedModelType;
|
|
QString modelType;
|
|
bool modelMatched = false;
|
|
bool modelVerificationSupported = true;
|
|
bool personInChockRegion = false;
|
|
bool chocksConfirmed = false;
|
|
int personCount = 0;
|
|
bool hasException = false;
|
|
double distance = 0.0;
|
|
double lateralOffset = 0.0;
|
|
double angle = 0.0;
|
|
double aircraftSpeed = 0.0;
|
|
double confidence = 0.0;
|
|
double personConfidence = 0.0;
|
|
int guideStateCode = 0;
|
|
QString guideText;
|
|
};
|
|
|
|
struct DetectionResult : public DetectionResultData<ParkingSpaceGuidePosition>
|
|
{
|
|
std::vector<ParkingSpaceGuideInfo> parkingSpaceInfoList;
|
|
QString message;
|
|
bool imageIsRoi = false;
|
|
};
|
|
|
|
struct ParkingSpaceGuideDetectOutput
|
|
{
|
|
bool success = true;
|
|
int errorCode = 0;
|
|
QString message;
|
|
int cameraIndex = 1;
|
|
qint64 timestamp = 0;
|
|
std::vector<ParkingSpaceGuideInfo> guideOutputs;
|
|
};
|
|
|
|
Q_DECLARE_METATYPE(ParkingSpaceGuidePosition)
|
|
Q_DECLARE_METATYPE(ParkingSpaceGuideInfo)
|
|
Q_DECLARE_METATYPE(DetectionResult)
|
|
|
|
#endif // IVRCONFIG_H
|