#include #include #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 input_tensor_values = mEngine->preprocessImage(frame); std::vector results = mEngine->runInference(input_tensor_values); float confidence_threshold = 0.4; std::vector 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); emit resultsReady(result); mActive = false; }