diff --git a/parameters_alpha.txt b/parameters_alpha.txt index e883721affd3a92959b2bbc8dbc9eb08cb8cee0f..e5134d1a89a0885db312ec0a6571daddb04a52c8 100644 --- a/parameters_alpha.txt +++ b/parameters_alpha.txt @@ -23,18 +23,20 @@ 42 200 GYRO_OFFSET_X 29760 42 200 GYRO_OFFSET_Y 29860 42 200 GYRO_OFFSET_Z 29877 -42 200 MIX_OFFSET 1 +42 200 MIX_OFFSET 0 42 200 MIX_POSITION 0 42 200 MIX_POS_YAW 0 -42 200 MIX_REMOTE 1 +42 200 MIX_REMOTE 0 42 200 MIX_Z_POSITION 0 42 200 PID_ATT_AWU 0.3 42 200 PID_ATT_D 30 42 200 PID_ATT_I 60 +42 200 PID_ATT_LIM 100 42 200 PID_ATT_P 90 42 200 PID_POS_AWU 5 42 200 PID_POS_D 2 42 200 PID_POS_I 0.4 +42 200 PID_POS_LIM 0.2 42 200 PID_POS_P 1.8 42 200 PID_POS_Z_AWU 3 42 200 PID_POS_Z_D 0.2 @@ -44,16 +46,18 @@ 42 200 PID_YAWPOS_AWU 1 42 200 PID_YAWPOS_D 1 42 200 PID_YAWPOS_I 0.1 +42 200 PID_YAWPOS_LIM 2 42 200 PID_YAWPOS_P 5 42 200 PID_YAWSPEED_D 0 -42 200 PID_YAWSPEED_I 10 -42 200 PID_YAWSPEED_P 30 +42 200 PID_YAWSPEED_I 5 +42 200 PID_YAWSPEED_P 15 42 200 PID_YAWSPE_AWU 1 +42 200 PID_YAWSPE_LIM 50 42 200 POS_SP_ACCEPT 1 -42 200 POS_SP_X 1.75 -42 200 POS_SP_Y 0.5 -42 200 POS_SP_YAW 0 -42 200 POS_SP_Z 0 +42 200 POS_SP_X 1.09 +42 200 POS_SP_Y 0.527403 +42 200 POS_SP_YAW 1.57763 +42 200 POS_SP_Z -0.7 42 200 POS_TIMEOUT 1e+06 42 200 RC_NICK_CHAN 1 42 200 RC_ROLL_CHAN 2 diff --git a/parameters_bravo.txt b/parameters_bravo.txt index 6f4eceecbff60c474dd2c88bb9e9c76e49b99c85..029850bfeb745ae6573bca01a14704bcc3a74d00 100644 --- a/parameters_bravo.txt +++ b/parameters_bravo.txt @@ -20,21 +20,23 @@ 42 200 DEBUG_4 0 42 200 DEBUG_5 0 42 200 DEBUG_6 0 -42 200 GYRO_OFFSET_X 29830 -42 200 GYRO_OFFSET_Y 29990 -42 200 GYRO_OFFSET_Z 29440 -42 200 MIX_OFFSET 1 +42 200 GYRO_OFFSET_X 29884 +42 200 GYRO_OFFSET_Y 29943 +42 200 GYRO_OFFSET_Z 29479 +42 200 MIX_OFFSET 0 42 200 MIX_POSITION 0 42 200 MIX_POS_YAW 0 -42 200 MIX_REMOTE 1 +42 200 MIX_REMOTE 0 42 200 MIX_Z_POSITION 0 42 200 PID_ATT_AWU 0.3 42 200 PID_ATT_D 10 -42 200 PID_ATT_I 10 -42 200 PID_ATT_P 40 +42 200 PID_ATT_I 20 +42 200 PID_ATT_LIM 100 +42 200 PID_ATT_P 55 42 200 PID_POS_AWU 5 42 200 PID_POS_D 2 42 200 PID_POS_I 0.25 +42 200 PID_POS_LIM 0.2 42 200 PID_POS_P 1.7 42 200 PID_POS_Z_AWU 3 42 200 PID_POS_Z_D 0.2 @@ -44,16 +46,18 @@ 42 200 PID_YAWPOS_AWU 1 42 200 PID_YAWPOS_D 1 42 200 PID_YAWPOS_I 0.1 +42 200 PID_YAWPOS_LIM 2 42 200 PID_YAWPOS_P 5 42 200 PID_YAWSPEED_D 0 -42 200 PID_YAWSPEED_I 10 -42 200 PID_YAWSPEED_P 30 +42 200 PID_YAWSPEED_I 5 +42 200 PID_YAWSPEED_P 15 42 200 PID_YAWSPE_AWU 1 +42 200 PID_YAWSPE_LIM 50 42 200 POS_SP_ACCEPT 1 -42 200 POS_SP_X 1.75 -42 200 POS_SP_Y 0.5 +42 200 POS_SP_X 1.1 +42 200 POS_SP_Y 1.1 42 200 POS_SP_YAW 0 -42 200 POS_SP_Z -0.7 +42 200 POS_SP_Z -0.8 42 200 POS_TIMEOUT 1e+06 42 200 RC_NICK_CHAN 1 42 200 RC_ROLL_CHAN 2 diff --git a/patterns/0.bmp b/patterns/0.bmp new file mode 100644 index 0000000000000000000000000000000000000000..af7ec103e5a2f9a7dee7a4fed32f180059ab7efc Binary files /dev/null and b/patterns/0.bmp differ diff --git a/patterns/1.bmp b/patterns/1.bmp new file mode 100644 index 0000000000000000000000000000000000000000..bd3dc2979f023de302243bb748ed637f6bf2e30a Binary files /dev/null and b/patterns/1.bmp differ diff --git a/patterns/2.bmp b/patterns/2.bmp new file mode 100644 index 0000000000000000000000000000000000000000..118916b05af732f9354dc6a7f5102bd25d7c1172 Binary files /dev/null and b/patterns/2.bmp differ diff --git a/patterns/3.bmp b/patterns/3.bmp new file mode 100644 index 0000000000000000000000000000000000000000..0ea614070d93f7758fd39daaadc4f4ae9a1c0ac1 Binary files /dev/null and b/patterns/3.bmp differ diff --git a/patterns/4.bmp b/patterns/4.bmp new file mode 100644 index 0000000000000000000000000000000000000000..51b08af29bac7623a12daede5769a3bf543d1bea Binary files /dev/null and b/patterns/4.bmp differ diff --git a/patterns/5.bmp b/patterns/5.bmp new file mode 100644 index 0000000000000000000000000000000000000000..b4100321735c4165edefb4d14a6ece8ed52ab8fd Binary files /dev/null and b/patterns/5.bmp differ diff --git a/patterns/6.bmp b/patterns/6.bmp new file mode 100644 index 0000000000000000000000000000000000000000..dfe7800227aecf3b5771e3eb13799a48ea8cccd0 Binary files /dev/null and b/patterns/6.bmp differ diff --git a/patterns/7.bmp b/patterns/7.bmp new file mode 100644 index 0000000000000000000000000000000000000000..c4732cdbe1efd22eeed77b4189c5c2839274d666 Binary files /dev/null and b/patterns/7.bmp differ diff --git a/patterns/8.bmp b/patterns/8.bmp new file mode 100644 index 0000000000000000000000000000000000000000..cbeca178d07ee4d9aafb9ab847b655c3a4f5c5af Binary files /dev/null and b/patterns/8.bmp differ diff --git a/patterns/9.bmp b/patterns/9.bmp new file mode 100644 index 0000000000000000000000000000000000000000..6c55fefa1b6f18818cf188d87a6197a323bcd8db Binary files /dev/null and b/patterns/9.bmp differ diff --git a/patterns/a.bmp b/patterns/a.bmp index 34a902cd2b1f907b86e3f1a863e9ef9f66bc8d67..c4399d8f13f78d3b4b194685a9a2e0df7e0f487b 100644 Binary files a/patterns/a.bmp and b/patterns/a.bmp differ diff --git a/patterns/b.bmp b/patterns/b.bmp new file mode 100644 index 0000000000000000000000000000000000000000..9c24ae01990f1f6df35567a84c4fb05cbee449a4 Binary files /dev/null and b/patterns/b.bmp differ diff --git a/patterns/c.bmp b/patterns/c.bmp new file mode 100644 index 0000000000000000000000000000000000000000..83ffd265683649cf8f567a7ae1d71cbbf77e94ca Binary files /dev/null and b/patterns/c.bmp differ diff --git a/patterns/d.bmp b/patterns/d.bmp new file mode 100644 index 0000000000000000000000000000000000000000..c161db29f3b6f88e1ad41a8687bb9d0f33baebf2 Binary files /dev/null and b/patterns/d.bmp differ diff --git a/patterns/e.bmp b/patterns/e.bmp new file mode 100644 index 0000000000000000000000000000000000000000..5a0a925c7357734146a60090ff90031a94d5aa5e Binary files /dev/null and b/patterns/e.bmp differ diff --git a/patterns/f.bmp b/patterns/f.bmp new file mode 100644 index 0000000000000000000000000000000000000000..a969b2e93363d137c4acc824d6df160c170f18e2 Binary files /dev/null and b/patterns/f.bmp differ diff --git a/patterns/g.bmp b/patterns/g.bmp new file mode 100644 index 0000000000000000000000000000000000000000..4e909f3225a99cdec90f337a66e076dbbb2f808c Binary files /dev/null and b/patterns/g.bmp differ diff --git a/patterns/h.bmp b/patterns/h.bmp new file mode 100644 index 0000000000000000000000000000000000000000..aeb23eaf8edf12e47455383cf3466d4fec09b606 Binary files /dev/null and b/patterns/h.bmp differ diff --git a/patterns/i.bmp b/patterns/i.bmp new file mode 100644 index 0000000000000000000000000000000000000000..a5966070f9b3001debdf221830dfeb1ce51784f1 Binary files /dev/null and b/patterns/i.bmp differ diff --git a/patterns/j.bmp b/patterns/j.bmp new file mode 100644 index 0000000000000000000000000000000000000000..686106f6bcbfb6c1412ca812f3cac719c18be144 Binary files /dev/null and b/patterns/j.bmp differ diff --git a/patterns/k.bmp b/patterns/k.bmp new file mode 100644 index 0000000000000000000000000000000000000000..8e5ffcf9afe0fb7438892f7ffda73915090f2f21 Binary files /dev/null and b/patterns/k.bmp differ diff --git a/patterns/l.bmp b/patterns/l.bmp new file mode 100644 index 0000000000000000000000000000000000000000..941f2bdb81a39683cc0e5490c3fde94d49f71eb6 Binary files /dev/null and b/patterns/l.bmp differ diff --git a/patterns/m.bmp b/patterns/m.bmp new file mode 100644 index 0000000000000000000000000000000000000000..ce85d160d34e5f98b61f4b7813fb581492a74bda Binary files /dev/null and b/patterns/m.bmp differ diff --git a/patterns/n.bmp b/patterns/n.bmp new file mode 100644 index 0000000000000000000000000000000000000000..78175d9f6d9b4aff26d7e6303b37c0fa86237ca8 Binary files /dev/null and b/patterns/n.bmp differ diff --git a/patterns/o.bmp b/patterns/o.bmp new file mode 100644 index 0000000000000000000000000000000000000000..47cb32a7af37e3b099dd898813a840e043d3beda Binary files /dev/null and b/patterns/o.bmp differ diff --git a/patterns/p.bmp b/patterns/p.bmp new file mode 100644 index 0000000000000000000000000000000000000000..abf0fd32a540687167f7e503dc17412c8506ba8c Binary files /dev/null and b/patterns/p.bmp differ diff --git a/patterns/q.bmp b/patterns/q.bmp new file mode 100644 index 0000000000000000000000000000000000000000..8973a550cbc71e9c9048a93bcf2074afef1aa24c Binary files /dev/null and b/patterns/q.bmp differ diff --git a/patterns/r.bmp b/patterns/r.bmp new file mode 100644 index 0000000000000000000000000000000000000000..324fd82e666f867429173d4687660f7cf5242111 Binary files /dev/null and b/patterns/r.bmp differ diff --git a/patterns/s.bmp b/patterns/s.bmp new file mode 100644 index 0000000000000000000000000000000000000000..e8bde5ca755bd199123109c0bfe694b6a2cce05b Binary files /dev/null and b/patterns/s.bmp differ diff --git a/patterns/t.bmp b/patterns/t.bmp new file mode 100644 index 0000000000000000000000000000000000000000..2057a316a096cd39177e6aebd7ffeda180033d66 Binary files /dev/null and b/patterns/t.bmp differ diff --git a/patterns/u.bmp b/patterns/u.bmp new file mode 100644 index 0000000000000000000000000000000000000000..ef19a67aa0c9084cd9b604300581390df4f8364f Binary files /dev/null and b/patterns/u.bmp differ diff --git a/patterns/v.bmp b/patterns/v.bmp new file mode 100644 index 0000000000000000000000000000000000000000..7dc84125ad8103210514407b27db3c4b63d2f43c Binary files /dev/null and b/patterns/v.bmp differ diff --git a/patterns/w.bmp b/patterns/w.bmp new file mode 100644 index 0000000000000000000000000000000000000000..5bb89a42cbd495bd454dd0d0fab37013816421f8 Binary files /dev/null and b/patterns/w.bmp differ diff --git a/patterns/x.bmp b/patterns/x.bmp new file mode 100644 index 0000000000000000000000000000000000000000..3a88357a0b441ab218652a39709efd8fc15e9da1 Binary files /dev/null and b/patterns/x.bmp differ diff --git a/patterns/y.bmp b/patterns/y.bmp new file mode 100644 index 0000000000000000000000000000000000000000..1ce7ea9e53fae1d0ba59e6f288b3ec012f3939d0 Binary files /dev/null and b/patterns/y.bmp differ diff --git a/patterns/z.bmp b/patterns/z.bmp new file mode 100644 index 0000000000000000000000000000000000000000..3d86f55c8e991441ee0bb9e2c10c94dc600ffedc Binary files /dev/null and b/patterns/z.bmp differ diff --git a/src/uas/PxQuadMAV.cc b/src/uas/PxQuadMAV.cc index be2348b9fe1d17a10300ea8a9e0704f13faad295..695561b08cc444096bd9b0e12f43f63abf283e02 100644 --- a/src/uas/PxQuadMAV.cc +++ b/src/uas/PxQuadMAV.cc @@ -49,9 +49,11 @@ void PxQuadMAV::receiveMessage(LinkInterface* link, mavlink_message_t message) b.resize(256); mavlink_msg_pattern_detected_get_file(&message, (int8_t*)b.data()); b.append('\0'); - QString path = QString(b); - 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); + QString name = QString(b); + if (detected.type == 0) + emit patternDetected(uasId, name, detected.confidence, detected.detected); + else if (detected.type == 1) + emit letterDetected(uasId, name, detected.confidence, detected.detected); } break; case MAVLINK_MSG_ID_WATCHDOG_HEARTBEAT: diff --git a/src/uas/UASInterface.h b/src/uas/UASInterface.h index 8148d93094dcf75204d768a09a52726a20ea7ed6..0846b89b15a69b37a3e667ac4023731363ed17d2 100644 --- a/src/uas/UASInterface.h +++ b/src/uas/UASInterface.h @@ -290,7 +290,7 @@ signals: void waypointReached(UASInterface* uas, int id); 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 patternDetected(int uasId, QString patternPath, float 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 623843c31a8cde572d39f5c10d38a71d3ed3915b..884c7b70f40d894db7365b4bb9cdca55797eb42c 100644 --- a/src/ui/ObjectDetectionView.cc +++ b/src/ui/ObjectDetectionView.cc @@ -26,6 +26,7 @@ This file is part of the PIXHAWK project * @brief List of detected objects * @author Benjamin Knecht * @author Lorenz Meier + * @author Fabian Landau * */ @@ -37,13 +38,15 @@ This file is part of the PIXHAWK project #include "GAudioOutput.h" #include +#include #include "MG.h" ObjectDetectionView::ObjectDetectionView(QString folder, QWidget *parent) : QWidget(parent), patternList(), - patternCount(), + letterList(), + letterTimer(), uas(NULL), patternFolder(folder), separator(" "), @@ -51,6 +54,8 @@ ObjectDetectionView::ObjectDetectionView(QString folder, QWidget *parent) : { m_ui->setupUi(this); connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(setUAS(UASInterface*))); + letterTimer.start(1000); + connect(&letterTimer, SIGNAL(timeout()), this, SLOT(decreaseLetterTime())); } ObjectDetectionView::~ObjectDetectionView() @@ -74,91 +79,108 @@ void ObjectDetectionView::setUAS(UASInterface* uas) //if (this->uas == NULL && uas != NULL) //{ 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))); + connect(uas, SIGNAL(patternDetected(int, QString, float, bool)), this, SLOT(newPattern(int, QString, float, 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) +void ObjectDetectionView::newPattern(int uasId, QString patternPath, 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); -} + if (detected) + { + if (!patternList.contains(patternPath)) + { + // Emit audio message on detection + if (detected) GAudioOutput::instance()->say("System " + QString::number(uasId) + " detected pattern " + QString(patternPath.split("/").last()).split(".").first()); -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(y1); - Q_UNUSED(x2); - Q_UNUSED(y2); - Q_UNUSED(x3); - Q_UNUSED(y3); - Q_UNUSED(x4); - Q_UNUSED(y4); - newDetection(uasId, patternPath, confidence, detected); + patternList.insert(patternPath, Pattern(patternPath, confidence)); + } + else + { + Pattern pattern = patternList.value(patternPath); + if (confidence > pattern.confidence) + pattern.confidence = confidence; + ++pattern.count; + patternList.insert(patternPath, pattern); + } + + // set list items + QList templist; + foreach (Pattern pattern, patternList) + templist.push_back(pattern); + qSort(templist); + m_ui->listWidget->clear(); + foreach (Pattern pattern, templist) + m_ui->listWidget->addItem(pattern.name + separator + "(" + QString::number(pattern.count) + ")" + separator + QString::number(pattern.confidence)); + + // load image + QString filePath = MG::DIR::getSupportFilesDirectory() + "/" + patternFolder + "/" + patternPath.split("/").last(); + QPixmap image = QPixmap(filePath); + if (image.width() > image.height()) + image = image.scaledToWidth(m_ui->imageLabel->width()); + else + image = image.scaledToHeight(m_ui->imageLabel->height()); + m_ui->imageLabel->setPixmap(image); + + // set textlabel + QString patternName = patternPath.split("/").last(); // Remove preceding folder names + patternName = patternName.split(".").first(); // Remove file ending + m_ui->nameLabel->setText("Pattern: " + patternName); + } } -void ObjectDetectionView::newDetection(int uasId, QString patternPath, float confidence, bool detected) +void ObjectDetectionView::newLetter(int uasId, QString letter, float confidence, bool detected) { + Q_UNUSED(confidence); + if (detected) { - if (patternList.contains(patternPath)) + if (!letterList.contains(letter)) { - //qDebug() << "REDETECTED"; - - QList actions = m_ui->listWidget->actions(); - // Find action and update it - foreach (QAction* act, actions) - { - qDebug() << "ACTION"; - if (act->text().trimmed().split(separator).first() == patternPath) - { - int count = patternCount.value(patternPath); - patternCount.insert(patternPath, count); - act->setText(patternPath + separator + "(#" + QString::number(count) + ")" + separator + QString::number(confidence)); - } - } - QString filePath = MG::DIR::getSupportFilesDirectory() + "/" + patternFolder + "/" + patternPath.split("/").last(); - qDebug() << "Loading:" << filePath; - QPixmap image = QPixmap(filePath); - image = image.scaledToWidth(m_ui->imageLabel->width()); - m_ui->imageLabel->setPixmap(image); - QString patternName = patternPath.split("//").last(); // Remove preceding folder names - patternName = patternName.split(".").first(); // Remove file ending + // Emit audio message on detection + if (detected) GAudioOutput::instance()->say("System " + QString::number(uasId) + " detected letter " + letter); - // Set name and label - m_ui->nameLabel->setText(patternName); + letterList.insert(letter, Pattern(letter, 0)); } else { - // Emit audio message on detection - if (detected) GAudioOutput::instance()->say("System " + QString::number(uasId) + " detected pattern " + QString(patternPath.split("/").last()).split(".").first()); + Pattern pattern = letterList.value(letter); + pattern.confidence = 0; + ++pattern.count; + letterList.insert(letter, pattern); + } - patternList.insert(patternPath, confidence); - patternCount.insert(patternPath, 1); + updateLetterList(); - QString filePath = MG::DIR::getSupportFilesDirectory() + "/" + patternFolder + "/" + patternPath.split("/").last(); + // display letter + m_ui->letterLabel->setText(letter); - qDebug() << "Loading:" << filePath; - QPixmap image = QPixmap(filePath); - QIcon ico(image); - QAction* act = new QAction(ico, patternPath + separator + "(#" + QString::number(1) + ")" + separator + QString::number(confidence), this); - connect(act, SIGNAL(triggered()), this, SLOT(takeAction())); - //m_ui->listWidget->addAction(act); - m_ui->listWidget->addItem(patternPath + separator + "(#" + QString::number(1) + ")" + separator + QString::number(confidence)); - //m_ui->listWidget->addItem(patternPath + " " + QString::number(confidence)); - image = image.scaledToWidth(m_ui->imageLabel->width()); - m_ui->imageLabel->setPixmap(image); - QString patternName = patternPath.split("//").last(); // Remove preceding folder names - patternName = patternName.split(".").first(); // Remove file ending + // set textlabel + m_ui->nameLabel->setText("Letter: " + letter); + } +} - // Set name and label - m_ui->nameLabel->setText(patternName); - qDebug() << "IMAGE SET" << patternFolder + "/" + patternPath; - } +void ObjectDetectionView::decreaseLetterTime() +{ + foreach (Pattern pattern, letterList) + { + pattern.confidence -= 1; + letterList.insert(pattern.name, pattern); } + + updateLetterList(); +} + +void ObjectDetectionView::updateLetterList() +{ + // set list items + QList templist; + foreach (Pattern pattern, letterList) + templist.push_back(pattern); + qSort(templist); + m_ui->letterListWidget->clear(); + foreach (Pattern pattern, templist) + m_ui->letterListWidget->addItem(pattern.name + separator + "(" + QString::number(pattern.count) + ")" + separator + QString::number(pattern.confidence)); } void ObjectDetectionView::takeAction() diff --git a/src/ui/ObjectDetectionView.h b/src/ui/ObjectDetectionView.h index 054249abdbf3fe5179ec1fb25dae6eb2d6bb8102..574c8fb2648ae090ff51849a68de63a1b95fe3d6 100644 --- a/src/ui/ObjectDetectionView.h +++ b/src/ui/ObjectDetectionView.h @@ -26,6 +26,7 @@ This file is part of the PIXHAWK project * @brief List of detected objects * @author Benjamin Knecht * @author Lorenz Meier + * @author Fabian Landau * */ @@ -47,8 +48,21 @@ namespace Ui { class ObjectDetectionView : public QWidget { Q_OBJECT Q_DISABLE_COPY(ObjectDetectionView) - public: - explicit ObjectDetectionView(QString folder="patterns", QWidget *parent = 0); + + struct Pattern + { + Pattern() : name(QString()), confidence(0.0f), count(0) {} + Pattern(QString name, float confidence) : name(name), confidence(confidence), count(1) {} + + bool operator<(const Pattern& other) const { return this->confidence > other.confidence; } // this comparison is intentionally wrong to sort the QList from highest confidence to lowest + + QString name; + float confidence; + unsigned int count; + }; + +public: + explicit ObjectDetectionView(QString folder="patterns", QWidget *parent = 0); virtual ~ObjectDetectionView(); /** @brief Resize widget contents */ @@ -58,17 +72,19 @@ public slots: /** @brief Set the UAS this view is currently associated to */ 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 newPattern(int uasId, QString patternPath, float confidence, bool detected); void newLetter(int uasId, QString letter, float confidence, bool detected); - void newDetection(int uasId, QString patternPath, float confidence, bool detected); + void decreaseLetterTime(); + void updateLetterList(); /** @brief Accept an internal action, update name and preview image label */ void takeAction(); protected: virtual void changeEvent(QEvent *e); - QMap patternList; ///< The detected patterns - QMap patternCount; ///< Number of detections per pattern - UASInterface* uas; ///< The monitored UAS + QMap patternList; ///< The detected patterns with their confidence and detection count + QMap letterList; ///< The detected letters with their confidence and detection count + QTimer letterTimer; ///< A timer to "forget" old letters + UASInterface* uas; ///< The monitored UAS QString patternFolder; ///< The base folder where pattern images are stored in const QString separator; diff --git a/src/ui/ObjectDetectionView.ui b/src/ui/ObjectDetectionView.ui index a115f53a957a14eab4ecd147319fafc32ce9348f..5630b1ee6221f02067887b987b648191cef77faf 100644 --- a/src/ui/ObjectDetectionView.ui +++ b/src/ui/ObjectDetectionView.ui @@ -7,17 +7,20 @@ 0 0 246 - 396 + 403 Form - - + + - + + + + @@ -36,7 +39,39 @@ - + + + + + 10 + 10 + + + + + 2 + 2 + + + + + 10 + 10 + + + + font: 72pt; +color: white; + + + + + + Qt::AlignCenter + + + + No objects recognized diff --git a/waypoints-final-pole-racing.txt b/waypoints-final-pole-racing.txt new file mode 100644 index 0000000000000000000000000000000000000000..6a4b4ba550021b4f5bf796eea555be2d5ef69fe6 --- /dev/null +++ b/waypoints-final-pole-racing.txt @@ -0,0 +1,9 @@ + 0 1.60066 0.497923 -0.7 -0.156858 1 1 0.15 2000 + 1 0.973377 0.691139 -0.7 -0.0664193 1 0 0.15 2000 + 2 0.646637 1.57225 -0.7 6.26573 1 0 0.15 2000 + 3 0.659852 2.39951 -0.7 -0.0549587 1 0 0.15 2000 + 4 1.41441 2.8804 -0.7 -0.0258336 1 0 0.15 2000 + 5 2.33563 2.90308 -0.7 -0.0621037 1 0 0.15 2000 + 6 2.76383 2.04368 -0.7 -0.0381553 1 0 0.15 2000 + 7 2.73091 1.05595 -0.7 -0.0520457 1 0 0.15 2000 + 8 1.73409 0.599043 0 6.26573 1 0 0.15 2000 diff --git a/waypoints_A0_circlev2.txt b/waypoints_A0_circlev2.txt index 1d366e188d11deeec176b5e3cdd17b08785ae7b8..e2e684c3ab462e83229b8b38ea21677fd02492d9 100644 --- a/waypoints_A0_circlev2.txt +++ b/waypoints_A0_circlev2.txt @@ -1,10 +1,10 @@ - 0 1.75 0.5 -0.7 0 1 1 0.3 10000 - 1 0.95 0.5 -0.7 0 1 0 0.3 2000 - 2 0.5 1.5 -0.7 0 1 0 0.3 2000 - 3 0.5 2.8 -0.7 0 1 0 0.3 2000 - 4 1.75 2.8 -0.7 0 1 0 0.3 2000 - 5 2.8 2.8 -0.7 0 1 0 0.3 2000 - 6 2.8 1.75 -0.7 0 1 0 0.3 2000 - 7 2.8 0.7 -0.7 0 1 0 0.3 2000 - 8 1.75 0.5 -0.7 0 1 0 0.3 2000 - 9 1.75 0.5 0 0 0 0 0.3 2000 + 0 1.75 0.5 -0.7 0 1 1 0.15 10000 + 1 0.95 0.5 -0.7 0 1 0 0.15 2000 + 2 0.5 1.5 -0.7 0 1 0 0.15 2000 + 3 0.5 2.8 -0.7 0 1 0 0.15 2000 + 4 1.75 2.8 -0.7 0 1 0 0.15 2000 + 5 2.8 2.8 -0.7 0 1 0 0.15 2000 + 6 2.8 1.75 -0.7 0 1 0 0.15 2000 + 7 2.8 0.7 -0.7 0 1 0 0.15 2000 + 8 1.75 0.5 -0.7 0 1 0 0.15 2000 + 9 1.75 0.5 0 0 0 0 0.15 2000