mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 22:36:34 +00:00
33 lines
1.2 KiB
C++
33 lines
1.2 KiB
C++
#include <QDebug>
|
|
#include <QThread>
|
|
#include "aiengineinferenceonnx.h"
|
|
|
|
AiEngineInferenceOnnx::AiEngineInferenceOnnx(QString modelPath, QObject *parent)
|
|
: AiEngineInference{modelPath, parent}
|
|
{
|
|
qDebug() << "TUOMAS test mModelPath=" << mModelPath;
|
|
mEngine = new InferenceEngine(modelPath.toStdString());
|
|
}
|
|
|
|
|
|
void AiEngineInferenceOnnx::performInferenceSlot(cv::Mat frame)
|
|
{
|
|
qDebug() << "performInferenceSlot() in thread: " << QThread::currentThreadId();
|
|
|
|
mActive = true;
|
|
|
|
int orig_width = frame.cols;
|
|
int orig_height = frame.rows;
|
|
std::vector<float> input_tensor_values = mEngine->preprocessImage(frame);
|
|
std::vector<float> results = mEngine->runInference(input_tensor_values);
|
|
float confidence_threshold = 0.5;
|
|
std::vector<Detection> detections = mEngine->filterDetections(results, confidence_threshold, mEngine->input_shape[2], mEngine->input_shape[3], orig_width, orig_height);
|
|
|
|
AiEngineInferenceResult result;
|
|
result.frame = mEngine->draw_labels(frame.clone(), detections);
|
|
result.objects = 1;
|
|
emit resultsReady(result);
|
|
|
|
mActive = false;
|
|
}
|