mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 23:46:34 +00:00
New threaded RTSP and AI image recognition.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user