working yolo default model with opencv

This commit is contained in:
Tuomas Järvinen
2024-08-25 18:26:19 +03:00
parent be59a02f9b
commit ef137fbc4b
6 changed files with 747 additions and 1 deletions
@@ -90,6 +90,9 @@ void AiEngineInferencevOnnxRuntime::performInferenceSlot(cv::Mat frame)
qDebug() << "performInferenceSlot() invalid classId =" << detection.classId;
continue;
}
else {
cv::imwrite("scaledImage.png", scaledImage);
}
// Add detected objects to the results
AiEngineObject object;
@@ -28,11 +28,13 @@ std::vector<Detection> Inference::runInference(const cv::Mat &input)
int rows = outputs[0].size[1];
int dimensions = outputs[0].size[2];
bool yolov8 = false;
bool yolov8 = true;
// yolov5 has an output of shape (batchSize, 25200, 85) (Num classes + box[x,y,w,h] + confidence[c])
// yolov8 has an output of shape (batchSize, 84, 8400) (Num classes + box[x,y,w,h])
/*
if (dimensions > rows) // Check if the shape[2] is more than shape[1] (yolov8)
{
std::cout << "yolov8 = " << yolov8 << std::endl;
yolov8 = true;
rows = outputs[0].size[2];
dimensions = outputs[0].size[1];
@@ -40,6 +42,8 @@ std::vector<Detection> Inference::runInference(const cv::Mat &input)
outputs[0] = outputs[0].reshape(1, dimensions);
cv::transpose(outputs[0], outputs[0]);
}
*/
float *data = (float *)outputs[0].data;
float x_factor = modelInput.cols / modelShape.width;