Commit 260c0ce4 authored by pixhawk's avatar pixhawk

show detected letters

parent cac8880f
...@@ -43,13 +43,15 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) ...@@ -43,13 +43,15 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message)
break; break;
case MAVLINK_MSG_ID_PATTERN_DETECTED: case MAVLINK_MSG_ID_PATTERN_DETECTED:
{ {
mavlink_pattern_detected_t detected;
mavlink_msg_pattern_detected_decode(&message, &detected);
QByteArray b; QByteArray b;
b.resize(256); b.resize(256);
mavlink_msg_pattern_detected_get_file(&message, (int8_t*)b.data()); mavlink_msg_pattern_detected_get_file(&message, (int8_t*)b.data());
b.append('\0'); b.append('\0');
QString path = QString(b); QString path = QString(b);
bool detected (mavlink_msg_pattern_detected_get_detected(&message) == 1 ? true : false ); emit detectionReceived(uasId, path, 0, 0, 0, 0, 0, 0, 0, 0, mavlink_msg_pattern_detected_get_confidence(&message), detected.detected);
emit detectionReceived(uasId, path, 0, 0, 0, 0, 0, 0, 0, 0, mavlink_msg_pattern_detected_get_confidence(&message), detected); emit letterDetected(uasId, path, detected.confidence, detected.detected);
} }
break; break;
case MAVLINK_MSG_ID_WATCHDOG_HEARTBEAT: case MAVLINK_MSG_ID_WATCHDOG_HEARTBEAT:
......
...@@ -291,6 +291,7 @@ signals: ...@@ -291,6 +291,7 @@ signals:
void autoModeChanged(bool autoMode); void autoModeChanged(bool autoMode);
void parameterChanged(int uas, int component, QString parameterName, float value); void parameterChanged(int uas, int component, QString parameterName, float value);
void detectionReceived(int uasId, QString patternPath, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, double confidence, bool detected); void detectionReceived(int uasId, QString patternPath, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, double confidence, bool detected);
void letterDetected(int uasId, QString letter, float confidence, bool detected);
/** /**
* @brief The battery status has been updated * @brief The battery status has been updated
* *
......
...@@ -75,9 +75,18 @@ void ObjectDetectionView::setUAS(UASInterface* uas) ...@@ -75,9 +75,18 @@ void ObjectDetectionView::setUAS(UASInterface* uas)
//{ //{
this->uas = uas; this->uas = uas;
connect(uas, SIGNAL(detectionReceived(int, QString, int, int, int, int, int, int, int, int, double, bool)), this, SLOT(newDetection(int,QString,int,int,int,int,int,int,int,int,double,bool))); connect(uas, SIGNAL(detectionReceived(int, QString, int, int, int, int, int, int, int, int, double, bool)), this, SLOT(newDetection(int,QString,int,int,int,int,int,int,int,int,double,bool)));
connect(uas, SIGNAL(letterDetected(int,QString,float,bool)), this, SLOT(newLetter(int,QString,float,bool)));
//} //}
} }
void ObjectDetectionView::newLetter(int uasId, QString letter, float confidence, bool detected)
{
// Emit audio message on detection
if (detected) GAudioOutput::instance()->say("System " + QString::number(uasId) + " detected letter " + letter);
m_ui->nameLabel->setText(letter);
m_ui->imageLabel->setText(letter);
}
void ObjectDetectionView::newDetection(int uasId, QString patternPath, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, double confidence, bool detected) void ObjectDetectionView::newDetection(int uasId, QString patternPath, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, double confidence, bool detected)
{ {
Q_UNUSED(x1); Q_UNUSED(x1);
...@@ -88,6 +97,11 @@ void ObjectDetectionView::newDetection(int uasId, QString patternPath, int x1, i ...@@ -88,6 +97,11 @@ void ObjectDetectionView::newDetection(int uasId, QString patternPath, int x1, i
Q_UNUSED(y3); Q_UNUSED(y3);
Q_UNUSED(x4); Q_UNUSED(x4);
Q_UNUSED(y4); Q_UNUSED(y4);
newDetection(uasId, patternPath, confidence, detected);
}
void ObjectDetectionView::newDetection(int uasId, QString patternPath, float confidence, bool detected)
{
if (detected) if (detected)
{ {
if (patternList.contains(patternPath)) if (patternList.contains(patternPath))
......
...@@ -59,6 +59,8 @@ public slots: ...@@ -59,6 +59,8 @@ public slots:
void setUAS(UASInterface* uas); void setUAS(UASInterface* uas);
/** @brief Report new detection */ /** @brief Report new detection */
void newDetection(int uasId, QString patternPath, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, double confidence, bool detected); void newDetection(int uasId, QString patternPath, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, double confidence, bool detected);
void newLetter(int uasId, QString letter, float confidence, bool detected);
void newDetection(int uasId, QString patternPath, float confidence, bool detected);
/** @brief Accept an internal action, update name and preview image label */ /** @brief Accept an internal action, update name and preview image label */
void takeAction(); void takeAction();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment