From 0bf06f9c6a34eef42966106cd0ed6438d999813c Mon Sep 17 00:00:00 2001 From: even <philippe.even@loria.fr> Date: Sun, 25 Nov 2018 13:09:48 +0100 Subject: [PATCH] User input storage --- Code/Seg/BSTools/bsdetectionwidget.cpp | 44 +++++++++++++++++++++++--- Code/Seg/BSTools/bsdetectionwidget.h | 7 +++- Code/Seg/ImageTools/pt2i.cpp | 1 - Methode/ctrl.tex | 15 +++++---- 4 files changed, 53 insertions(+), 14 deletions(-) diff --git a/Code/Seg/BSTools/bsdetectionwidget.cpp b/Code/Seg/BSTools/bsdetectionwidget.cpp index 5bf088f..d2f8a6e 100755 --- a/Code/Seg/BSTools/bsdetectionwidget.cpp +++ b/Code/Seg/BSTools/bsdetectionwidget.cpp @@ -654,6 +654,10 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) switchIdetAnalyzer (); break; + case Qt::Key_7 : + storeUserInput (); + break; + case Qt::Key_8 : alternateTest (); break; @@ -1013,13 +1017,43 @@ void BSDetectionWidget::performanceTest () } -void BSDetectionWidget::localTest () +void BSDetectionWidget::storeUserInput () { - cout << "Run test" << endl; + if (udef && ! p1.equals (p2)) + { + ofstream output ("test.txt", ios::out); + output << p1.x () << " " << p1.y () << endl; + output << p2.x () << " " << p2.y () << endl; + cout << "New test.txt created" << endl; + } + else cout << "Unable to create test.txt : no user input" << endl; +} - udef = true; - p1 = Pt2i (175, 40); - p2 = Pt2i (246, 79); + +void BSDetectionWidget::localTest () +{ + int val[4], i = 0; + ifstream input ("test.txt", ios::in); + bool reading = true; + if (input) + { + while (reading) + { + input >> val[i]; + if (input.eof ()) reading = false; + else if (++i == 4) reading = false; + } + if (i == 4) + { + udef = true; + p1 = Pt2i (val[0], val[1]); + p2 = Pt2i (val[2], val[3]); + cout << "Run test on (" << val[0] << ", " << val[1] + << ") (" << val[2] << ", " << val[3] << ")" << endl; + } + else cout << "Test file damaged" << endl; + } + else cout << "Run autotest" << endl; extract (); cout << "Test run" << endl; diff --git a/Code/Seg/BSTools/bsdetectionwidget.h b/Code/Seg/BSTools/bsdetectionwidget.h index 1401d9f..a8b1608 100755 --- a/Code/Seg/BSTools/bsdetectionwidget.h +++ b/Code/Seg/BSTools/bsdetectionwidget.h @@ -129,7 +129,7 @@ public: void performanceTest (); /** - * \brief Runs a local test (to be adapted). + * \brief Runs a local test (reads test.txt). */ void localTest (); @@ -352,5 +352,10 @@ private: */ void extract (); + /** + * \brief Stores the user input in test.txt. + */ + void storeUserInput (); + }; #endif diff --git a/Code/Seg/ImageTools/pt2i.cpp b/Code/Seg/ImageTools/pt2i.cpp index 06fbb41..0d60fe4 100755 --- a/Code/Seg/ImageTools/pt2i.cpp +++ b/Code/Seg/ImageTools/pt2i.cpp @@ -1,5 +1,4 @@ #include "pt2i.h" -// #include <cmath> Pt2i::Pt2i () diff --git a/Methode/ctrl.tex b/Methode/ctrl.tex index f50a6f3..8194be6 100755 --- a/Methode/ctrl.tex +++ b/Methode/ctrl.tex @@ -60,32 +60,33 @@ Ctrl-y && Commute l'affichage des pixels des segments flous. \\ 2 && Commute la visu de l'accumulateur \\ 3 && Commute la visu des profils \\ 4 && Commute la visu de la d\'etection initiale \\ -0 && Test avec $P_1$ et $P_2$ impos\'es \\ -9 && Test de performance sur la derni\`ere barre trac\'ee \\ -8 && Tests comparatifs sur diff\'erents contextes de d\'etection \\ +0 && Teste avec la derni\`ere barre enregistr\'ee (test.txt) \\ +9 && Teste la performance sur la derni\`ere barre trac\'ee \\ +8 && Teste comparativement sur diff\'erents contextes de d\'etection \\ +7 && Enregistre la barre initiale dans test.txt \\ \hline \hline \multicolumn{3}{|l|}{Fen\^etres d'analyse :} \\ i && Changement d'info \\ v && Commute l'affichage du texte \\ -\hline \hline +\hline \multicolumn{3}{|l|}{Analyse des segments flous extraits :} \\ Ctrl-i && Commute le type d'affichage des scans \\ Ctrl-b && Commute le fond d'\'ecran de la fen\^etre principale. \\ + -- && Zoom \\ $< \wedge > \vee$ && D\'ecalage de l'observation \\ -\hline \hline +\hline \multicolumn{3}{|l|}{Analyse des accumulateurs :} \\ s && Taille de l'accumulateur (nombre de cellules) \\ r && R\'esolution (espace couvert par une cellule) \\ p && Sub-pixelisation (pour le vote) \\ f && S\'electivit\'e du filtre \\ -\hline \hline +\hline \multicolumn{3}{|l|}{Analyse des profils :} \\ w && Largeur de correlation \\ t && Epaisseur de correlation \\ r && Taux de correlation \\ $\wedge \vee$ && Parcours des bandes \\ -\hline \hline +\hline \multicolumn{3}{|l|}{Analyse de la d\'etection initiale :} \\ $< \wedge > \vee$ && D\'ecalage de l'observation \\ \hline -- GitLab