From 4b34688a424635bb7daefe00174060e2f20de604 Mon Sep 17 00:00:00 2001 From: Helen Oleynikova Date: Mon, 14 Jul 2014 11:21:17 +0200 Subject: [PATCH] Fixed video transmission. --- src/uas/UAS.cc | 12 ++++++++++-- src/ui/HUD.cc | 7 +++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index 020516b52..8201184a0 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -1329,10 +1329,13 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ++imagePacketsArrived; // emit signal if all packets arrived + // && seq >= imagePackets-1 if ((imagePacketsArrived >= imagePackets)) { // Restart statemachine emit imageReady(this); + //imagePacketsArrived = 0; + //imagePackets = 0; //qDebug() << "imageReady emitted. all packets arrived"; } } @@ -2142,11 +2145,16 @@ QImage UAS::getImage() if (!image.loadFromData(imageRecBuffer)) { qDebug() << __FILE__ << __LINE__ << "Loading data from image buffer failed!"; + //imagePacketsArrived = 0; + //imagePackets = 0; + return QImage(); } } + // Restart statemachine imagePacketsArrived = 0; - //imageRecBuffer.clear(); + imagePackets = 0; + imageRecBuffer.clear(); return image; } @@ -3148,7 +3156,7 @@ void UAS::sendHilGroundTruth(quint64 time_us, float roll, float pitch, float yaw Q_UNUSED(xacc); Q_UNUSED(yacc); Q_UNUSED(zacc); - + // Emit attitude for cross-check emit valueChanged(uasId, "roll sim", "rad", roll, getUnixTime()); emit valueChanged(uasId, "pitch sim", "rad", pitch, getUnixTime()); diff --git a/src/ui/HUD.cc b/src/ui/HUD.cc index 90b1ca0b7..e4386ae8e 100644 --- a/src/ui/HUD.cc +++ b/src/ui/HUD.cc @@ -119,7 +119,7 @@ HUD::HUD(int width, int height, QWidget* parent) { Q_UNUSED(width); Q_UNUSED(height); - + // Set auto fill to false setAutoFillBackground(false); @@ -1374,7 +1374,10 @@ void HUD::copyImage(UASInterface* uas) UAS* u = qobject_cast(uas); if (u) { - this->glImage = u->getImage(); + QImage temp_im = u->getImage(); + if (temp_im.byteCount() > 0) { + this->glImage = temp_im;//u->getImage(); + } // Save to directory if logging is enabled if (imageLoggingEnabled) -- 2.22.0