From 6d24a975528bdd731d4e19319af37a88eb315e1a Mon Sep 17 00:00:00 2001 From: even <philippe.even@loria.fr> Date: Tue, 16 Apr 2019 15:35:04 +0200 Subject: [PATCH] Add detected multisegments output --- Code/FBSD/BSTools/bsdetectionwidget.cpp | 95 ++++++++++++++----------- 1 file changed, 55 insertions(+), 40 deletions(-) diff --git a/Code/FBSD/BSTools/bsdetectionwidget.cpp b/Code/FBSD/BSTools/bsdetectionwidget.cpp index 90136d7..ecf3fa1 100755 --- a/Code/FBSD/BSTools/bsdetectionwidget.cpp +++ b/Code/FBSD/BSTools/bsdetectionwidget.cpp @@ -35,7 +35,8 @@ BSDetectionWidget::BSDetectionWidget (QWidget *parent) strucview = NULL; profileview = NULL; idetview = NULL; - // cannyview = NULL; + cannyview = NULL; + yorkview = NULL; // Sets initial user outputs parameters verbose = false; @@ -70,7 +71,8 @@ BSDetectionWidget::~BSDetectionWidget () if (strucview != NULL) delete strucview; if (profileview != NULL) delete profileview; if (idetview != NULL) delete idetview; - // if (cannyview != NULL) delete cannyview; + if (cannyview != NULL) delete cannyview; + if (yorkview != NULL) delete yorkview; } @@ -838,35 +840,15 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) break; case Qt::Key_Percent : -/* - cout << "CannyLine compares BS" << endl; - detector.detectAll (); if (cannyview == NULL) - { cannyview = new BSCannyView (&loadedImage, &detector); - } - cannyview->testBS (); cannyview->show (); - cannyview->update (); - displayDetectionResult (); - cout << "CannyLine compares BS" << endl; -*/ break; - case Qt::Key_Ugrave : -/* - cout << "CannyLine compares DSS" << endl; - detector.detectAll (); - if (cannyview == NULL) - { - cannyview = new BSCannyView (&loadedImage, &detector); - } - cannyview->testDSS (); - cannyview->show (); - cannyview->update (); - displayDetectionResult (); - cout << "CannyLine compares DSS" << endl; -*/ + case Qt::Key_Semicolon : + if (yorkview == NULL) + yorkview = new BSYorkView (&loadedImage, &detector); + yorkview->show (); break; case Qt::Key_Plus : @@ -990,6 +972,14 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) { if (idetview->processKeyEvent (event)) extract (); } + else if (yorkview != NULL && yorkview->isActiveWindow ()) + { + if (yorkview->processKeyEvent (event)) extract (); + } + else if (cannyview != NULL && cannyview->isActiveWindow ()) + { + if (cannyview->processKeyEvent (event)) extract (); + } } @@ -1145,21 +1135,46 @@ void BSDetectionWidget::writeTest () void BSDetectionWidget::writeDetectionResult () { - BlurredSegment *bs = detector.getBlurredSegment (); - if (bs != NULL) + vector<BlurredSegment *> bss = detector.getBlurredSegments (); + if (bss.empty ()) { - ofstream outf ("seg.txt", ios::out); - outf << "(" << bs->antipodalEdgeStart().x () - << ", " << bs->antipodalEdgeStart().y () - << ") (" << bs->antipodalEdgeEnd().x () - << ", " << bs->antipodalEdgeEnd().y () - << ") (" << bs->antipodalVertex().x () - << ", " << bs->antipodalVertex().y () - << ") (" << bs->getLastLeft().x () - << ", " << bs->getLastLeft().y () - << ") (" << bs->getLastRight().x () - << ", " << bs->getLastRight().y () - << ")" << endl; + BlurredSegment *bs = detector.getBlurredSegment (); + if (bs != NULL) + { + ofstream outf ("seg.txt", ios::out); + outf << "(" << bs->antipodalEdgeStart().x () + << ", " << bs->antipodalEdgeStart().y () + << ") (" << bs->antipodalEdgeEnd().x () + << ", " << bs->antipodalEdgeEnd().y () + << ") (" << bs->antipodalVertex().x () + << ", " << bs->antipodalVertex().y () + << ") (" << bs->getLastLeft().x () + << ", " << bs->getLastLeft().y () + << ") (" << bs->getLastRight().x () + << ", " << bs->getLastRight().y () + << ")" << endl; + outf.close (); + } + } + else + { + ofstream outf ("segs.txt", ios::out); + vector<BlurredSegment *>::iterator it = bss.begin (); + while (it != bss.end ()) + { + outf << "(" << (*it)->antipodalEdgeStart().x () + << ", " << (*it)->antipodalEdgeStart().y () + << ") (" << (*it)->antipodalEdgeEnd().x () + << ", " << (*it)->antipodalEdgeEnd().y () + << ") (" << (*it)->antipodalVertex().x () + << ", " << (*it)->antipodalVertex().y () + << ") (" << (*it)->getLastLeft().x () + << ", " << (*it)->getLastLeft().y () + << ") (" << (*it)->getLastRight().x () + << ", " << (*it)->getLastRight().y () + << ")" << endl; + it++; + } outf.close (); } } -- GitLab