#ifndef DETECTIONOUTPUTCONVERTER_H #define DETECTIONOUTPUTCONVERTER_H #include "IVrConfig.h" #include #include #include #include // 前向声明(避免循环依赖,DetectionResult 在 App 层定义) struct ScrewInfo; struct ScrewPosition; /** * @brief 检测结果转换工具类 * * 负责将算法检测结果转换为协议输出格式,以及序列化为JSON * 放在 ScrewPositionConfig 层,供 Presenter 和 TCP 协议层使用 */ class DetectionOutputConverter { public: /** * @brief 将螺杆检测结果转换为协议输出格式 */ static ProtocolDetectionOutput ConvertScrewResult( const std::vector& screwInfoList, int cameraIndex, bool success = true, int errorCode = 0, const QString& message = QStringLiteral("\u68c0\u6d4b\u6210\u529f")); /** * @brief 将工具盘检测结果转换为协议输出格式 */ static ProtocolDetectionOutput ConvertToolDiskResult( const std::vector& positions, int cameraIndex, bool success = true, int errorCode = 0, const QString& message = QStringLiteral("\u5de5\u5177\u76d8\u68c0\u6d4b\u6210\u529f")); /** * @brief 将螺杆检测协议输出序列化为JSON */ static QJsonObject ScrewOutputToJson(const ProtocolDetectionOutput& output); /** * @brief 将工具盘检测协议输出序列化为JSON */ static QJsonObject ToolDiskOutputToJson(const ProtocolDetectionOutput& output); /** * @brief 将协议输出序列化为JSON(根据类型自动选择) */ static QJsonObject ToJson(const ProtocolDetectionOutput& output); }; #endif // DETECTIONOUTPUTCONVERTER_H