mirror of
https://github.com/azaion/autopilot.git
synced 2026-04-22 22:26:35 +00:00
be59a02f9b
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
32 lines
853 B
C++
32 lines
853 B
C++
#include <QFile>
|
|
#include <QDataStream>
|
|
#include <QDebug>
|
|
#include "aiengineimagesaver.h"
|
|
|
|
AiEngineImageSaver::AiEngineImageSaver(const cv::Mat &image, int imageNumber, QObject *parent)
|
|
: QThread(parent), image(image.clone()), imageNumber(imageNumber)
|
|
{
|
|
}
|
|
|
|
AiEngineImageSaver::~AiEngineImageSaver()
|
|
{
|
|
wait();
|
|
}
|
|
|
|
void AiEngineImageSaver::run()
|
|
{
|
|
if (image.empty() || image.channels() == 0) {
|
|
qWarning() << "AiEngineImageSaver. Empty image or no channels, nothing to save.";
|
|
return;
|
|
}
|
|
|
|
// Calculate the size of the upper half
|
|
int halfHeight = image.rows / 2;
|
|
cv::Mat upperHalf = image(cv::Rect(0, 0, image.cols, halfHeight));
|
|
|
|
// Use bpm to reduce encoding time.
|
|
QString filePath = QString("/tmp/image-%1.bmp").arg(imageNumber, 5, 10, QChar('0'));
|
|
|
|
cv::imwrite(filePath.toStdString(), upperHalf);
|
|
}
|