diff --git a/src/uas/PxQuadMAV.cc b/src/uas/PxQuadMAV.cc index be412aa36283c4ba03477f43f82095a5e1ccb9e9..1fee5ee7d01aab520236f92fa30d559a3efdafd2 100644 --- a/src/uas/PxQuadMAV.cc +++ b/src/uas/PxQuadMAV.cc @@ -43,13 +43,15 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) break; case MAVLINK_MSG_ID_PATTERN_DETECTED: { + mavlink_pattern_detected_t detected; + mavlink_msg_pattern_detected_decode(&message, &detected); QByteArray b; b.resize(256); mavlink_msg_pattern_detected_get_file(&message, (int8_t*)b.data()); b.append('\0'); 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); + emit detectionReceived(uasId, path, 0, 0, 0, 0, 0, 0, 0, 0, mavlink_msg_pattern_detected_get_confidence(&message), detected.detected); + emit letterDetected(uasId, path, detected.confidence, detected.detected); } break; case MAVLINK_MSG_ID_WATCHDOG_HEARTBEAT: diff --git a/src/uas/UASInterface.h b/src/uas/UASInterface.h index dc469a1381a1b81a697dd9c1df76a52dc5b3bf95..8148d93094dcf75204d768a09a52726a20ea7ed6 100644 --- a/src/uas/UASInterface.h +++ b/src/uas/UASInterface.h @@ -291,6 +291,7 @@ signals: void autoModeChanged(bool autoMode); 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 letterDetected(int uasId, QString letter, float confidence, bool detected); /** * @brief The battery status has been updated * diff --git a/src/ui/ObjectDetectionView.cc b/src/ui/ObjectDetectionView.cc index 3838acf4753c84da0519dfc060c60e7f04ec6b0e..623843c31a8cde572d39f5c10d38a71d3ed3915b 100644 --- a/src/ui/ObjectDetectionView.cc +++ b/src/ui/ObjectDetectionView.cc @@ -75,9 +75,18 @@ void ObjectDetectionView::setUAS(UASInterface* 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(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) { Q_UNUSED(x1); @@ -88,6 +97,11 @@ void ObjectDetectionView::newDetection(int uasId, QString patternPath, int x1, i Q_UNUSED(y3); Q_UNUSED(x4); Q_UNUSED(y4); + newDetection(uasId, patternPath, confidence, detected); +} + +void ObjectDetectionView::newDetection(int uasId, QString patternPath, float confidence, bool detected) +{ if (detected) { if (patternList.contains(patternPath)) diff --git a/src/ui/ObjectDetectionView.h b/src/ui/ObjectDetectionView.h index 910e748972250ab83575b147e3d63143d0090a08..054249abdbf3fe5179ec1fb25dae6eb2d6bb8102 100644 --- a/src/ui/ObjectDetectionView.h +++ b/src/ui/ObjectDetectionView.h @@ -59,6 +59,8 @@ public slots: void setUAS(UASInterface* uas); /** @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 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 */ void takeAction();