first Commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
// 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 <QImage>
|
||||
#include <QRectF>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
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<GrooveDetectionResult> detect(const QImage& image,
|
||||
float confidenceThreshold = 0.25f, float nmsThreshold = 0.45f);
|
||||
|
||||
private:
|
||||
struct OrtImpl;
|
||||
|
||||
std::vector<float> preprocess(const QImage& image) const;
|
||||
QVector<GrooveDetectionResult> postprocess(const float* output,
|
||||
int numAnchors, int numFields, int originalWidth, int originalHeight,
|
||||
float confidenceThreshold, float nmsThreshold) const;
|
||||
QVector<GrooveDetectionResult> nms(
|
||||
QVector<GrooveDetectionResult> candidates, float iouThreshold) const;
|
||||
void setError(const QString& error);
|
||||
|
||||
std::unique_ptr<OrtImpl> m_ort;
|
||||
bool m_loaded = false;
|
||||
QString m_modelPath;
|
||||
QString m_lastError;
|
||||
int m_inputW = 1280;
|
||||
int m_inputH = 1280;
|
||||
};
|
||||
Reference in New Issue
Block a user