mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 11:16:34 +00:00
Fixed PC build to work with ONNX Yolov10 files
This commit is contained in:
@@ -2,17 +2,18 @@
|
||||
#include <QThread>
|
||||
#include "aiengineinferenceonnx.h"
|
||||
|
||||
|
||||
AiEngineInferenceOnnx::AiEngineInferenceOnnx(QString modelPath, QObject *parent)
|
||||
: AiEngineInference{modelPath, parent}
|
||||
{
|
||||
qDebug() << "TUOMAS test mModelPath=" << mModelPath;
|
||||
//qDebug() << "TUOMAS test mModelPath=" << mModelPath;
|
||||
mEngine = new InferenceEngine(modelPath.toStdString());
|
||||
}
|
||||
|
||||
|
||||
void AiEngineInferenceOnnx::performInferenceSlot(cv::Mat frame)
|
||||
{
|
||||
qDebug() << "performInferenceSlot() in thread: " << QThread::currentThreadId();
|
||||
//qDebug() << "performInferenceSlot() in thread: " << QThread::currentThreadId();
|
||||
|
||||
mActive = true;
|
||||
|
||||
@@ -20,12 +21,24 @@ void AiEngineInferenceOnnx::performInferenceSlot(cv::Mat frame)
|
||||
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;
|
||||
float confidence_threshold = 0.4;
|
||||
std::vector<Detection> detections = mEngine->filterDetections(results, confidence_threshold, mEngine->input_shape[2], mEngine->input_shape[3], orig_width, orig_height);
|
||||
|
||||
AiEngineInferenceResult result;
|
||||
for (uint32_t i = 0; i < detections.size(); i++) {
|
||||
const Detection &detection = detections[i];
|
||||
|
||||
AiEngineObject object;
|
||||
object.classId = detection.class_id;
|
||||
object.propability = detection.confidence;
|
||||
object.rectangle.top = detection.bbox.y;
|
||||
object.rectangle.left = detection.bbox.x;
|
||||
object.rectangle.bottom = detection.bbox.y + detection.bbox.height;
|
||||
object.rectangle.right = detection.bbox.x + detection.bbox.width;
|
||||
result.objects.append(object);
|
||||
}
|
||||
|
||||
result.frame = mEngine->draw_labels(frame.clone(), detections);
|
||||
result.objects = 1;
|
||||
emit resultsReady(result);
|
||||
|
||||
mActive = false;
|
||||
|
||||
Reference in New Issue
Block a user