// GrooveOccupancyDetector.h // Dedicated ONNX detector for tray-groove occupancy. It intentionally has no // dependency on YoloDetector so changes here cannot affect part recognition. #pragma once #include #include #include #include #include #include struct GrooveDetectionResult { QRectF box; int classId = 0; // 0 = empty_groove, 1 = occupied_groove float confidence = 0.f; }; class GrooveOccupancyDetector { public: GrooveOccupancyDetector(); ~GrooveOccupancyDetector(); bool loadModel(const QString& onnxPath); bool isLoaded() const { return m_loaded; } QString modelPath() const { return m_modelPath; } QString lastError() const { return m_lastError; } int inputWidth() const { return m_inputW; } int inputHeight() const { return m_inputH; } QVector detect(const QImage& image, float confidenceThreshold = 0.25f, float nmsThreshold = 0.45f); private: struct OrtImpl; std::vector preprocess(const QImage& image) const; QVector postprocess(const float* output, int numAnchors, int numFields, int originalWidth, int originalHeight, float confidenceThreshold, float nmsThreshold) const; QVector nms( QVector candidates, float iouThreshold) const; void setError(const QString& error); std::unique_ptr m_ort; bool m_loaded = false; QString m_modelPath; QString m_lastError; int m_inputW = 1280; int m_inputH = 1280; };