mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 21:46:33 +00:00
Add functionality to save inference images for the debugging purposes.
Save bmp images of inference results to /tmp as bmp files. BMP was chosen to reduce encoding time. Saving is fully threaded. It can be enable with qmake CONFIG+=save_images option Also: - use antialised fonts in RKNN inference - moved class strings to inference base class - fixed silly segfault in ONNX inference - prevent writing results if class if exceeds valid values Issue: https://denyspopov.atlassian.net/browse/AZ-38 Type: Improvement
This commit is contained in:
@@ -90,6 +90,12 @@ void AiEngineInferenceOpi5::drawObjects(cv::Mat& image, const object_detect_resu
|
||||
for (int i = 0; i < result_list.count; i++) {
|
||||
const object_detect_result& result = result_list.results[i];
|
||||
|
||||
if (result.cls_id >= mClassNames.size()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
fprintf(stderr, "TUOMAS [%d] prop = %f\n", i, result.prop);
|
||||
|
||||
int left = result.box.left;
|
||||
int top = result.box.top;
|
||||
int right = result.box.right;
|
||||
@@ -99,9 +105,10 @@ void AiEngineInferenceOpi5::drawObjects(cv::Mat& image, const object_detect_resu
|
||||
|
||||
// Text
|
||||
char c_text[256];
|
||||
sprintf(c_text, "%s %.1f%%", coco_cls_to_name(result.cls_id), result.prop * 100);
|
||||
//sprintf(c_text, "%s %d%%", coco_cls_to_name(result.cls_id), (int)(round(result.prop * 100)));
|
||||
sprintf(c_text, "%s %d%%", mClassNames[result.cls_id].toStdString().c_str(), (int)(round(result.prop * 100)));
|
||||
cv::Point textOrg(left, top - 5);
|
||||
cv::putText(image, std::string(c_text), textOrg, cv::FONT_HERSHEY_SIMPLEX, result.prop, cv::Scalar(0, 0, 255), 1);
|
||||
cv::putText(image, std::string(c_text), textOrg, cv::FONT_HERSHEY_COMPLEX, result.prop, cv::Scalar(0, 0, 255), 1, cv::LINE_AA);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +124,7 @@ void AiEngineInferenceOpi5::performInferenceSlot(cv::Mat frame)
|
||||
|
||||
object_detect_result_list od_results;
|
||||
int ret = inference_yolov8_model(&mRrknnAppCtx0, &imgBuffer, &od_results, mNumber);
|
||||
freeImageBuffer(imgBuffer);
|
||||
if (ret != 0) {
|
||||
qDebug() << "AiEngineInferenceOpi5::performInferenceSlot() failure! ret: " << ret;
|
||||
mActive = false;
|
||||
@@ -138,8 +146,6 @@ void AiEngineInferenceOpi5::performInferenceSlot(cv::Mat frame)
|
||||
}
|
||||
|
||||
drawObjects(scaledFrame, od_results);
|
||||
freeImageBuffer(imgBuffer);
|
||||
|
||||
result.frame = scaledFrame.clone();
|
||||
emit resultsReady(result);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user