Improvements to OPI5 inference

- fixed probability showing 0.50 all the time
- removed commented out code
- fixed bug which prevented used of OPI5 inference in the case of early failure

Type: Bugfix
Issue: https://denyspopov.atlassian.net/browse/AZ-37
This commit is contained in:
Tuomas Järvinen
2024-08-17 15:05:53 +03:00
parent ba810592b5
commit 86c0a7d5c4
@@ -101,7 +101,7 @@ void AiEngineInferenceOpi5::drawObjects(cv::Mat& image, const object_detect_resu
char c_text[256];
sprintf(c_text, "%s %.1f%%", coco_cls_to_name(result.cls_id), result.prop * 100);
cv::Point textOrg(left, top - 5);
cv::putText(image, std::string(c_text), textOrg, cv::FONT_HERSHEY_SIMPLEX, 0.5, cv::Scalar(0, 0, 255), 1);
cv::putText(image, std::string(c_text), textOrg, cv::FONT_HERSHEY_SIMPLEX, result.prop, cv::Scalar(0, 0, 255), 1);
}
}
@@ -118,7 +118,8 @@ void AiEngineInferenceOpi5::performInferenceSlot(cv::Mat frame)
object_detect_result_list od_results;
int ret = inference_yolov8_model(&mRrknnAppCtx0, &imgBuffer, &od_results, mNumber);
if (ret != 0) {
qDebug() << "inference_yolov8_model() failure! ret: " << ret;
qDebug() << "AiEngineInferenceOpi5::performInferenceSlot() failure! ret: " << ret;
mActive = false;
return;
}
@@ -136,34 +137,6 @@ void AiEngineInferenceOpi5::performInferenceSlot(cv::Mat frame)
result.objects.append(object);
}
/*
char text[256];
for (int i = 0; i < od_results.count; i++) {
object_detect_result *det_result = &(od_results.results[i]);
printf("%s @ (%d %d %d %d) %.3f\n", coco_cls_to_name(det_result->cls_id),
det_result->box.left, det_result->box.top,
det_result->box.right, det_result->box.bottom,
det_result->prop);
int x1 = det_result->box.left;
int y1 = det_result->box.top;
int x2 = det_result->box.right;
int y2 = det_result->box.bottom;
draw_rectangle(&imgBuffer, x1, y1, x2 - x1, y2 - y1, COLOR_BLUE, 3);
sprintf(text, "%s %.1f%%", coco_cls_to_name(det_result->cls_id), det_result->prop * 100);
draw_text(&imgBuffer, text, x1, y1 - 20, COLOR_RED, 10);
}
*/
/*
static int imageNum = 0;
std::stringstream ss;
ss << std::setw(4) << std::setfill('0') << imageNum++;
std::string formatted_number = ss.str();
std::string filename = "/tmp/out-" + formatted_number + ".png";
cv::imwrite(filename, scaledFrame);
*/
drawObjects(scaledFrame, od_results);
freeImageBuffer(imgBuffer);