first Commit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include <QImage>
|
||||
#include <QPointF>
|
||||
#include <QRectF>
|
||||
#include <QVector>
|
||||
#include <QString>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
struct GroovePosePrediction
|
||||
{
|
||||
QRectF box;
|
||||
QVector<QPointF> keypoints;
|
||||
QVector<float> keypointConfidence;
|
||||
float confidence = 0.0f;
|
||||
};
|
||||
|
||||
// Independent YOLOv8-pose ONNX session for empty-groove four-point inference.
|
||||
// It intentionally owns its preprocessing, inference and NMS path.
|
||||
class GroovePoseDetector
|
||||
{
|
||||
public:
|
||||
GroovePoseDetector();
|
||||
~GroovePoseDetector();
|
||||
|
||||
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<GroovePosePrediction> detect(const QImage& image,
|
||||
float confidenceThreshold = 0.25f, float nmsThreshold = 0.45f) const;
|
||||
|
||||
private:
|
||||
struct OrtImpl;
|
||||
void setError(const QString& error) const;
|
||||
std::vector<float> preprocess(const QImage& image, float& scale,
|
||||
int& padX, int& padY) const;
|
||||
QVector<GroovePosePrediction> postprocess(const float* output,
|
||||
int numAnchors, int numFields, int originalWidth, int originalHeight,
|
||||
float scale, int padX, int padY,
|
||||
float confidenceThreshold, float nmsThreshold) const;
|
||||
QVector<GroovePosePrediction> nms(QVector<GroovePosePrediction> candidates,
|
||||
float iouThreshold) const;
|
||||
|
||||
std::unique_ptr<OrtImpl> m_ort;
|
||||
bool m_loaded = false;
|
||||
mutable QString m_lastError;
|
||||
QString m_modelPath;
|
||||
int m_inputW = 960;
|
||||
int m_inputH = 960;
|
||||
};
|
||||
Reference in New Issue
Block a user