APT demod: save image in image worker

pull/866/head
f4exb 2021-04-22 23:37:10 +02:00
rodzic aac8f6fe2c
commit 6b106f21ad
3 zmienionych plików z 61 dodań i 2 usunięć

Wyświetl plik

@ -651,20 +651,26 @@ int APTDemod::webapiActionsPost(
{
SWGSDRangel::SWGAPTDemodActions_los* los = swgAPTDemodActions->getLos();
QString *satelliteName = los->getSatelliteName();
if (satelliteName != nullptr)
{
if (matchSatellite(*satelliteName))
{
// Save image
if (m_settings.m_autoSave)
saveImageToDisk();
{
APTDemodImageWorker::MsgSaveImageToDisk *msg = APTDemodImageWorker::MsgSaveImageToDisk::create();
m_imageWorker->getInputMessageQueue()->push(msg);
}
// Disable decoder
APTDemodSettings settings = m_settings;
settings.m_decodeEnabled = false;
m_inputMessageQueue.push(MsgConfigureAPTDemod::create(settings, false));
if (m_guiMessageQueue)
if (m_guiMessageQueue) {
m_guiMessageQueue->push(MsgConfigureAPTDemod::create(settings, false));
}
}
return 202;
}

Wyświetl plik

@ -18,10 +18,14 @@
#include <algorithm>
#include <QTime>
#include <QDebug>
#include "aptdemod.h"
#include "aptdemodimageworker.h"
MESSAGE_CLASS_DEFINITION(APTDemodImageWorker::MsgConfigureAPTDemodImageWorker, Message)
MESSAGE_CLASS_DEFINITION(APTDemodImageWorker::MsgSaveImageToDisk, Message)
APTDemodImageWorker::APTDemodImageWorker() :
m_messageQueueToGUI(nullptr),
@ -90,6 +94,11 @@ bool APTDemodImageWorker::handleMessage(const Message& cmd)
applySettings(cfg.getSettings(), cfg.getForce());
return true;
}
else if (MsgSaveImageToDisk::match(cmd))
{
saveImageToDisk();
return true;
}
else if (APTDemod::MsgPixels::match(cmd))
{
QMutexLocker mutexLocker(&m_mutex);
@ -259,6 +268,32 @@ QImage APTDemodImageWorker::extractImage(QImage image)
}
}
void APTDemodImageWorker::saveImageToDisk()
{
QStringList imageTypes;
QImage image = processImage(imageTypes);
if (image.height() >= m_settings.m_autoSaveMinScanLines)
{
QString filename;
QDateTime datetime = QDateTime::currentDateTime();
filename = QString("apt_%1_%2.png").arg(m_satelliteName).arg(datetime.toString("yyyyMMdd_hhmm"));
if (!m_settings.m_autoSavePath.isEmpty())
{
if (m_settings.m_autoSavePath.endsWith('/')) {
filename = m_settings.m_autoSavePath + filename;
} else {
filename = m_settings.m_autoSavePath + '/' + filename;
}
}
if (!image.save(filename)) {
qCritical() << "Failed to save APT image to: " << filename;
}
}
}
void APTDemodImageWorker::copyImage(apt_image_t *dst, apt_image_t *src)
{
dst->nrow = src->nrow;

Wyświetl plik

@ -57,6 +57,23 @@ public:
{ }
};
class MsgSaveImageToDisk : public Message {
MESSAGE_CLASS_DECLARATION
public:
static MsgSaveImageToDisk* create()
{
return new MsgSaveImageToDisk();
}
private:
MsgSaveImageToDisk() :
Message()
{
}
};
APTDemodImageWorker();
~APTDemodImageWorker();
void reset();
@ -87,6 +104,7 @@ private:
void resetDecoder();
void processPixels(const float *pixels);
void sendImageToGUI();
void saveImageToDisk();
QImage processImage(QStringList& imageTypes);
QImage extractImage(QImage image);