From 1112eedd5cb91ca6d9457298b05ed30dd2673e0c Mon Sep 17 00:00:00 2001 From: even <philippe.even@loria.fr> Date: Wed, 8 May 2019 16:43:17 +0200 Subject: [PATCH] Controls re-organized --- Code/FBSD/BSTools/bsdetectionwidget.cpp | 353 ++++++++++++------------ Code/FBSD/BSTools/bsdetectionwidget.h | 63 ++--- Code/FBSD/BSTools/bswindow.cpp | 9 +- Code/FBSD/BlurredSegment/bsdetector.h | 8 +- Code/FBSD/IPOLdemo/mainIPOL.cpp | 33 ++- Code/FBSD/ImageTools/vmap.h | 4 +- Code/FBSD/main.cpp | 4 +- Methode/ctrl.tex | 29 +- Methode/evals.tex | 24 ++ 9 files changed, 287 insertions(+), 240 deletions(-) diff --git a/Code/FBSD/BSTools/bsdetectionwidget.cpp b/Code/FBSD/BSTools/bsdetectionwidget.cpp index ff442b5..1fb54a2 100755 --- a/Code/FBSD/BSTools/bsdetectionwidget.cpp +++ b/Code/FBSD/BSTools/bsdetectionwidget.cpp @@ -44,22 +44,21 @@ BSDetectionWidget::BSDetectionWidget (QWidget *parent) verbose = false; statsOn = false; background = BACK_IMAGE; - bsBoundsVisible = false; blevel = 0; // Sets display parameters - darkHighlightOn = false; - bscolorset = 0; + bsDisplay = 1; + arlequin = 0; + bsColor = 2; + bsHighColor[0] = Qt::black; + bsLowColor[0] = Qt::gray; + bsHighColor[1] = Qt::blue; + bsLowColor[1] = Qt::magenta; + bsHighColor[2] = Qt::yellow; + bsLowColor[2] = Qt::red; + bsHighColor[3] = Qt::white; + bsLowColor[3] = Qt::gray; selectionColor = Qt::red; - bsColor = Qt::blue; - bsHighColor = Qt::yellow; - bsColor2 = Qt::green; - bsHighColor2 = Qt::black; - bsPointsVisible = true; - boundColor = Qt::green; - boundHighColor = Qt::magenta; - boundColor2 = Qt::green; - boundHighColor2 = Qt::black; maxWidth = 768; maxHeight = 512; @@ -253,6 +252,17 @@ void BSDetectionWidget::closeIdetAnalyzer () } +void BSDetectionWidget::closeGroundtruthAnalyzer () +{ + if (gtview != NULL) + { + gtview->close (); + delete gtview; + gtview = NULL; + } +} + + /* void BSDetectionWidget::switchAccuAnalyzer () { @@ -322,29 +332,33 @@ void BSDetectionWidget::switchIdetAnalyzer () idetview->show (); } } -// DEV OUT -void BSDetectionWidget::switchHighlightColors () +void BSDetectionWidget::switchGroundtruthAnalyzer () { - darkHighlightOn = ! darkHighlightOn; - if (darkHighlightOn) + if (gtview != NULL) { - bsHighColor = Qt::black; - boundHighColor = Qt::blue; + gtview->close (); + delete gtview; + gtview = NULL; } else { - bsHighColor = Qt::yellow; - boundHighColor = Qt::magenta; + gtview = new BSGroundtruthView (&loadedImage, &detector); + gtview->show (); + idetview->show (); } } +// DEV OUT -void BSDetectionWidget::switchArlequin () +void BSDetectionWidget::switchColorSet (bool back) { - bscolorset ++; - if (bscolorset == 3) bscolorset = 0; + if (back) + { + if (--bsColor < 0) bsColor = 3; + } + else if (++ bsColor > 3) bsColor = 0; } @@ -467,39 +481,52 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) } else { - // Tunes the gradient resolution for gradient local max filtering - detector.incGradientResolution ( - (event->modifiers () & Qt::ShiftModifier ? -1 : 1)); - cout << "Gradient resolution = " - << detector.getGradientResolution () << endl; - extract (); + // Tunes the background image black level + incBlackLevel ((event->modifiers () & Qt::ShiftModifier) ? -1 : 1); + cout << "Background black level = " << getBlackLevel () << endl; + displayDetectionResult (); } break; case Qt::Key_C : - // Clears the registered blurred segments - cout << "Withdraws registered segments" << endl; - clearSavedSegments (); + // Toggles blurred segment color set + switchColorSet (event->modifiers () & Qt::ShiftModifier); + displayDetectionResult (); break; -// DEV IN case Qt::Key_D : +// DEV IN if (event->modifiers () & Qt::ControlModifier) { - // Switches sparsity test at initial step - detector.switchInitialSparsityTest (); - cout << "Initial sparsity test : " - << (detector.isInitialSparsityTestOn () ? "on" : "off") << endl; + // Switches opposite edges detection in multi-detection mode + detector.switchSingleOrDoubleMultiDetection (); + cout << "Multi-detection of " + << (detector.isSingleMultiOn () ? "single edges" : "double edges") + << endl; extract (); } - break; + else // DEV OUT + { + // Toggles blurred segment display style + toggleBlurredSegmentDisplay (event->modifiers () & Qt::ShiftModifier); + if (bsDisplay == 0) + cout << "Blurred segment display : unvisible" << endl; + else if (bsDisplay == 1) + cout << "Blurred segment display : points" << endl; + else if (bsDisplay == 2) + cout << "Blurred segment display : bounds" << endl; + else if (bsDisplay == 3) + cout << "Blurred segment display : bounds and points" << endl; + displayDetectionResult (); + } + break; case Qt::Key_E : { - // Handles single or double edge detection if (event->modifiers () & Qt::ControlModifier) { + // Handles single or double edge detection detector.switchSingleOrDoubleEdge (); if (detector.isSingleEdgeModeOn ()) cout << "Single edge detection set (" @@ -508,9 +535,9 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) else cout << "Double edge detection set" << endl; extract (); } - // Handles gradient orientation direction for the detection else { + // Handles gradient orientation direction for the detection if (detector.switchOppositeGradient ()) { cout << "Single edge detection set (" @@ -535,11 +562,24 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) break; case Qt::Key_G : - // Tunes the gradient threshold for maximal value detection - detector.incSensitivity ( - (event->modifiers () & Qt::ShiftModifier ? -1 : 1)); - cout << "Sensitivity = " << detector.getSensitivity () << endl; - extract (); +// DEV IN + if (event->modifiers () & Qt::ControlModifier) + { + // Switches the scan directionality + detector.switchOrthoScans (); + cout << (detector.orthoScansOn () ? + "Orthographic scans" : "Directional scans") << endl; + extract (); + } + else +// DEV OUT + { + // Tunes the gradient threshold for maximal value detection + detector.incSensitivity ( + (event->modifiers () & Qt::ShiftModifier ? -1 : 1)); + cout << "Sensitivity = " << detector.getSensitivity () << endl; + extract (); + } break; case Qt::Key_H : @@ -598,13 +638,14 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) } break; +// DEV IN case Qt::Key_L : if (event->modifiers () & Qt::ControlModifier) { - // Switches sparsity test at final step - detector.switchFinalSparsityTest (); - cout << "Final sparsity test : " - << (detector.isFinalSparsityTestOn () ? "on" : "off") << endl; + // Switches sparsity test at initial step + detector.switchInitialSparsityTest (); + cout << "Initial sparsity test : " + << (detector.isInitialSparsityTestOn () ? "on" : "off") << endl; extract (); } else @@ -617,6 +658,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) extract (); } break; +// DEV OUT case Qt::Key_M : if (event->modifiers () & Qt::ControlModifier) @@ -660,19 +702,16 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) break; case Qt::Key_O : -// DEV IN if (event->modifiers () & Qt::ControlModifier) { - // Switches the scan directionality - detector.switchOrthoScans (); - cout << (detector.orthoScansOn () ? - "Orthographic scans" : "Directional scans") << endl; - extract (); + // Switches measured values display + switchStats (); + cout << "Stats display " << (isStatsOn () ? "on" : "off") << endl; + displayDetectionResult (); } else -// DEV OUT { - // Outputs the detected segment + // Outputs the detected segment(s) cout << "Outputs detection result" << endl; writeDetectionResult (); } @@ -698,6 +737,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) break; case Qt::Key_Q : +// DEV IN if (event->modifiers () & Qt::ControlModifier) { // Switches the scan flexibility @@ -707,6 +747,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) extract (); } else +// DEV OUT { // Displays registered blurred segments cout << "Displays all registered segments" << endl; @@ -776,15 +817,17 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) break; case Qt::Key_U : +// DEV IN if (event->modifiers () & Qt::ControlModifier) { - // Switches the display of the detected blurred segment bounds - bsBoundsVisible = ! bsBoundsVisible; - cout << "Enclosing segments " - << (bsBoundsVisible ? "visible" : "hidden") << endl; + // Switches the crosswise segment detection + detector.switchTrackCrosswise (); extract (); + cout << "Crosswise segment detection " + << (detector.trackCrosswiseOn () ? "on" : "off") << endl; } else +// DEV OUT { // Replays last extraction cerr << "p1 update: " << p1.x () << " " << p1.y () << endl; @@ -799,8 +842,8 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) switchVerbose (); break; -// DEV IN case Qt::Key_W : +// DEV IN if (event->modifiers () & Qt::ControlModifier) { // Switches the scan centering on the detected segment @@ -809,12 +852,22 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) "detected segment" : "initial scan") << endl; extract (); } - break; + else // DEV OUT + { + // Tunes the assigned thickness to detector + detector.setAssignedThickness (detector.assignedThickness () + + (event->modifiers () & Qt::ShiftModifier ? -1 : 1)); + cout << "Assigned thickness = " + << detector.assignedThickness () << endl; + extract (); + } + break; case Qt::Key_X : if (event->modifiers () & Qt::ControlModifier) { + // Switches the static detection modality detector.setStaticDetector (! (detector.staticDetectorOn ())); cout << (detector.staticDetectorOn () ? "Static (without ADS and ATC) detector set" : @@ -823,33 +876,36 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) } else { - // Tunes the assigned thickness to detector - detector.setAssignedThickness (detector.assignedThickness () + - (event->modifiers () & Qt::ShiftModifier ? -1 : 1)); - cout << "Assigned thickness = " - << detector.assignedThickness () << endl; - extract (); + // Clears the registered blurred segments + cout << "Withdraws registered segments" << endl; + clearSavedSegments (); + displaySavedSegments (); } break; case Qt::Key_Y : if (event->modifiers () & Qt::ControlModifier) { - // Switches the display of the detected blurred segment pixels - bsPointsVisible = ! bsPointsVisible; - cout << "Blurred segment " - << (bsPointsVisible ? "visible" : "hidden") << endl; - displayDetectionResult (); + // Switches sparsity test at final step + detector.switchFinalSparsityTest (); + cout << "Final sparsity test : " + << (detector.isFinalSparsityTestOn () ? "on" : "off") << endl; + extract (); } +// DEV IN else { - // Tunes the background image black level - incBlackLevel ((event->modifiers () & Qt::ShiftModifier) ? -1 : 1); - cout << "Background black level = " << getBlackLevel () << endl; - displayDetectionResult (); + // Tunes the gradient resolution for gradient local max filtering + detector.incLocalMaxGradientResolution ( + (event->modifiers () & Qt::ShiftModifier ? -1 : 1)); + cout << "Gradient resolution = " + << detector.getLocalMaxGradientResolution () << endl; + extract (); } +// DEV OUT break; +// DEV IN case Qt::Key_Z : if (event->modifiers () & Qt::ControlModifier) { @@ -871,51 +927,20 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) extract (); } break; +// DEV OUT case Qt::Key_Exclam : - switchHighlightColors (); - cout << "Highlight colors " - << (isHighlightColorsOn () ? "on" : "off") << endl; + // Displays segments with dark random colors + arlequin = 1; displayDetectionResult (); break; - case Qt::Key_Equal : - switchArlequin (); - if (activeColorSet () == 0) - cout << "Random color blurred segments" << endl; - else if (activeColorSet () == 1) - cout << "Stylized color blurred segments" << endl; - else cout << "Neutral color blurred segments" << endl; + case Qt::Key_Colon : + // Displays segments with light random colors + arlequin = -1; displayDetectionResult (); break; - case Qt::Key_Asterisk : - switchStats (); - cout << "Stats display " << (isStatsOn () ? "on" : "off") << endl; - displayDetectionResult (); - break; - - case Qt::Key_Dollar : - writeTest (); - cout << "Selection stroke saved" << endl; - break; - -// DEV IN - case Qt::Key_Semicolon : - if (gtview == NULL) - gtview = new BSGroundtruthView (&loadedImage, &detector); - gtview->show (); - break; - - case Qt::Key_Question : - detector.switchSingleOrDoubleMultiDetection (); - cout << "Multi-detection of " - << (detector.isSingleMultiOn () ? "single edges" : "double edges") - << endl; - extract (); - break; -// DEV OUT - case Qt::Key_Plus : if (zoom > 1) { @@ -992,11 +1017,7 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) break; case Qt::Key_5 : - // Switches the crosswise segment detection - detector.switchTrackCrosswise (); - extract (); - cout << "Crosswise segment detection " - << (detector.trackCrosswiseOn () ? "on" : "off") << endl; + switchGroundtruthAnalyzer (); break; // DEV OUT @@ -1045,6 +1066,17 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) } +void BSDetectionWidget::toggleBlurredSegmentDisplay (bool getBack) +{ + if (getBack) + { + if (--bsDisplay < 0) bsDisplay = 3; + } + else if (++bsDisplay > 3) bsDisplay = 0; +} + + + void BSDetectionWidget::drawPoints (QPainter &painter, vector<Pt2i> pts, QColor color) { @@ -1097,12 +1129,12 @@ void BSDetectionWidget::drawSelection (QPainter &painter, } -void BSDetectionWidget::drawBlurredSegment (QPainter &painter, bool style, +void BSDetectionWidget::drawBlurredSegment (QPainter &painter, BlurredSegment *bs, bool high) { if (bs != NULL) { - if (bsBoundsVisible) + if (bsDisplay >= 2) // Bounds { vector<Pt2i> bnd; DigitalStraightSegment *dss = bs->getSegment (); @@ -1110,14 +1142,13 @@ void BSDetectionWidget::drawBlurredSegment (QPainter &painter, bool style, { dss->getBounds (bnd, 0, 0, width, height); drawPoints (painter, bnd, - high ? (style ? boundHighColor : boundHighColor2) - : (style ? boundColor : boundColor2)); + (high && bsDisplay == 2 ? bsHighColor[bsColor] + : bsLowColor[bsColor])); } } - if (bsPointsVisible) + if (bsDisplay % 2 == 1) // Points drawPoints (painter, bs->getAllPoints (), - high ? (style ? bsHighColor : bsHighColor2) - : (style ? bsColor : bsColor2)); + high ? bsHighColor[bsColor] : bsLowColor[bsColor]); } } @@ -1125,32 +1156,33 @@ void BSDetectionWidget::drawBlurredSegment (QPainter &painter, bool style, void BSDetectionWidget::drawArlequinSegment (QPainter &painter, BlurredSegment *bs) { + bool nok = true; + int red, green, blue; + while (nok) + { + red = rand () % 256; + green = rand () % 256; + blue = rand () % 256; + nok = (arlequin == 1 && (red + green + blue) > 300) + || (arlequin == -1 && (red + green + blue) < 300); + } if (bs != NULL) { - if (bsBoundsVisible) + if (bsDisplay >= 2) // Bounds { vector<Pt2i> bnd; DigitalStraightSegment *dss = bs->getSegment (); if (dss != NULL) { dss->getBounds (bnd, 0, 0, width, height); - drawPoints (painter, bnd, boundHighColor); + if (bsDisplay == 3) + drawPoints (painter, bnd, (arlequin == 1 ? Qt::black : Qt::white)); + else + drawPoints (painter, bnd, QColor (red, green, blue)); } } - if (bsPointsVisible) - { - bool nok = true; - int red, green, blue; - while (nok) - { - red = rand () % 256; - green = rand () % 256; - blue = rand () % 256; - nok = (darkHighlightOn && (red + green + blue) > 300) - || (! darkHighlightOn && (red + green + blue) < 300); - } + if (bsDisplay % 2 == 1) // Points drawPoints (painter, bs->getAllPoints (), QColor (red, green, blue)); - } } } @@ -1189,16 +1221,6 @@ void BSDetectionWidget::displayBackground () } -void BSDetectionWidget::writeTest () -{ - ofstream outf ("test.txt", ios::out); - outf << p1.x() << " " << p1.y () << endl; - outf << p2.x() << " " << p2.y () << endl; - outf.close (); - cout << "Selection saved in test.txt" << endl; -} - - void BSDetectionWidget::writeDetectionResult () { vector<BlurredSegment *> bss = detector.getBlurredSegments (); @@ -1257,35 +1279,20 @@ void BSDetectionWidget::displayDetectionResult () vector<BlurredSegment *> bss = detector.getBlurredSegments (); if (! bss.empty ()) { -// cout << bss.size () << " blurred segments detected" << endl; -// double bsw = 0.; -// int bsc = 0; - if (bscolorset == 0 && detector.getMaxDetections () == 0) - srand (time (NULL)); + if (arlequin != 0) srand (time (NULL)); vector<BlurredSegment *>::const_iterator it = bss.begin (); while (it != bss.end ()) { -// if ((*it) != NULL) -// { -// DigitalStraightSegment *dss = (*it)->getSegment (); -// bsc++; -// if (dss == NULL) cout << "DSS null" << endl; -// else bsw += dss->width () / (double) dss->period (); -// } - if (bscolorset == 0 && detector.getMaxDetections () == 0) - drawArlequinSegment (painter, *it); + if (arlequin != 0) drawArlequinSegment (painter, *it); else - drawBlurredSegment (painter, bscolorset == 1, *it, + drawBlurredSegment (painter, *it, detector.getMaxDetections () == 0 || *it == bss.back ()); it++; } -// cout << bsc << " effective blurred segments" << endl; -// if (bsc != 0) cout << "Mean width is " << bsw / bsc << endl; } - else - drawBlurredSegment (painter, bscolorset <= 1, - detector.getBlurredSegment ()); + else drawBlurredSegment (painter, detector.getBlurredSegment ()); if (udef) drawSelection (painter, p1, p2); + arlequin = 0; update (QRect (QPoint (0, 0), QPoint (width, height))); // Update auxiliary view if not dragging @@ -1324,7 +1331,7 @@ void BSDetectionWidget::displaySavedSegments () vector<ExtractedSegment>::iterator it = extractedSegments.begin (); while (it != extractedSegments.end ()) { - drawBlurredSegment (painter, bscolorset <= 1, it->bs); + drawBlurredSegment (painter, it->bs); drawSelection (painter, it->p1, it->p2); it ++; } diff --git a/Code/FBSD/BSTools/bsdetectionwidget.h b/Code/FBSD/BSTools/bsdetectionwidget.h index 5e1abe0..9f973de 100755 --- a/Code/FBSD/BSTools/bsdetectionwidget.h +++ b/Code/FBSD/BSTools/bsdetectionwidget.h @@ -98,6 +98,11 @@ public: */ void closeIdetAnalyzer (); + /** + * \brief Requires the groundtruth test window closure. + */ + void closeGroundtruthAnalyzer (); + /** * \brief Switches the pixel display window on or off. */ @@ -119,24 +124,26 @@ public: void switchIdetAnalyzer (); /** - * \brief Return whether the blurred segment highlight colors are set. + * \brief Switches the groundtruth test window on or off. */ - inline bool isHighlightColorsOn () const { return darkHighlightOn; } + void switchGroundtruthAnalyzer (); /** - * \brief Switches the blurred segment highlight colors. + * \brief Toggles the blurred segment display style. + * @param back Toggles backwards if true, frontwards otherwise. */ - void switchHighlightColors (); + void toggleBlurredSegmentDisplay (bool back); /** - * \brief Returns the blurred segment color style for display. + * \brief Return whether the blurred segment highlight colors are set. */ - inline int activeColorSet () const { return bscolorset; } + inline bool isHighlightColorsOn () const { return darkHighlightOn; } /** - * \brief Switches the random color display modality. + * \brief Toggles the blurred segment color set. + * @param back Toggle direction. */ - void switchArlequin (); + void switchColorSet (bool back); /** * \brief Returns whether extraction stats are displayed. */ @@ -241,32 +248,20 @@ private: /** Saved user definition flag. */ bool oldudef; + /** Blurred segment display style. */ + int bsDisplay; + /** Blurred segment color index. */ + int bsColor; + /** Highlighted blurred segment colors. */ + QColor bsHighColor[4]; + /** Lowlighted blurred segment colors. */ + QColor bsLowColor[4]; + /** Blurred segment random color display. */ + int arlequin; /** Kind of highlight colors. */ bool darkHighlightOn; - /** Color style to display blurred segments. */ - int bscolorset; /** Color of user selections. */ QColor selectionColor; - /** Stylized color of blurred segments. */ - QColor bsColor; - /** Stylized color of highlighted blurred segments. */ - QColor bsHighColor; - /** Neutral color of blurred segments. */ - QColor bsColor2; - /** Neutral color of highlighted blurred segments. */ - QColor bsHighColor2; - /** Flag indicating whether blurred segments points are visible. */ - bool bsPointsVisible; - /** Stylized color of blurred segments bounds. */ - QColor boundColor; - /** Stylized color of highlighted blurred segments bounds. */ - QColor boundHighColor; - /** Neutral color of blurred segments bounds. */ - QColor boundColor2; - /** Neutral color of highlighted blurred segments bounds. */ - QColor boundHighColor2; - /** Flag indicating whether blurred segments bounds are visible. */ - bool bsBoundsVisible; /** Background type. * BACK_BLACK, BACK_WHITE, BACK_IMAGE, BACK_GRAD, BACK_GRADX, BACK_GRADY. */ int background; @@ -370,11 +365,10 @@ private: /** * \brief Draws a blurred segment. * @param painter Drawing device. - * @param style Flag indicating if specific drawing style is set. * @param bs Reference to the blurred segment to be drawn. * @param high Flag indicated whether the blurred segment is highlighted. */ - void drawBlurredSegment (QPainter &painter, bool style, + void drawBlurredSegment (QPainter &painter, BlurredSegment *bs, bool high = true); /** @@ -411,11 +405,6 @@ private: */ void writeStats (); - /** - * \brief Writes the selection stroke in test.txt. - */ - void writeTest (); - /** * \brief Writes the result of the last detection in a file. */ diff --git a/Code/FBSD/BSTools/bswindow.cpp b/Code/FBSD/BSTools/bswindow.cpp index cf609d2..47a4825 100755 --- a/Code/FBSD/BSTools/bswindow.cpp +++ b/Code/FBSD/BSTools/bswindow.cpp @@ -64,10 +64,11 @@ void BSWindow::runTest () void BSWindow::closeEvent (QCloseEvent *event) { - detectionWidget->closeIdetAnalyzer (); // DEV - detectionWidget->closeProfileAnalyzer (); // DEV - // detectionWidget->closeAccuAnalyzer (); // DEV - detectionWidget->closePixelAnalyzer (); // DEV + detectionWidget->closeGroundtruthAnalyzer (); // DEV + detectionWidget->closeIdetAnalyzer (); // DEV + detectionWidget->closeProfileAnalyzer (); // DEV + // detectionWidget->closeAccuAnalyzer (); // DEV + detectionWidget->closePixelAnalyzer (); // DEV event->accept (); } diff --git a/Code/FBSD/BlurredSegment/bsdetector.h b/Code/FBSD/BlurredSegment/bsdetector.h index 9952068..4340fb1 100755 --- a/Code/FBSD/BlurredSegment/bsdetector.h +++ b/Code/FBSD/BlurredSegment/bsdetector.h @@ -205,15 +205,15 @@ public: /** * \brief Returns the gradient threshold used for local max filtering. */ - inline int getGradientResolution () const { - return (gMap->getGradientResolution ()); } + inline int getLocalMaxGradientResolution () const { + return (gMap->getLocalMaxGradientResolution ()); } /** * \brief Increments the gradient threshold used for local maximal filtering. * @param inc Increment value. */ - inline void incGradientResolution (int inc) { - return (gMap->incGradientResolution (inc)); } + inline void incLocalMaxGradientResolution (int inc) { + return (gMap->incLocalMaxGradientResolution (inc)); } /** * \brief Returns the stroke sweeping step value for automatic detections. diff --git a/Code/FBSD/IPOLdemo/mainIPOL.cpp b/Code/FBSD/IPOLdemo/mainIPOL.cpp index c34e1e7..492d5fa 100755 --- a/Code/FBSD/IPOLdemo/mainIPOL.cpp +++ b/Code/FBSD/IPOLdemo/mainIPOL.cpp @@ -113,7 +113,7 @@ int main (int argc, char *argv[]) vector<BlurredSegment *> bss; BSDetector detector; detector.setGradientMap (gMap); - detector.setFineTracksMaxWidth (widthBS); + detector.setAssignedThickness (widthBS); if (with_points) { @@ -134,14 +134,30 @@ int main (int argc, char *argv[]) nbseg ++; } } + +/* +AbsRat x1, y1, x2, y2; +vector<BlurredSegment *> bss = detector.getBlurredSegments (); +vector<BlurredSegment *>::const_iterator it = bss.begin (); +while (it != bss.end ()) +{ + DigitalStraightSegment *dss = (*it)->getSegment (); + dss->naiveLine (x1, y1, x2, y2); +*/ + vector<BlurredSegment *>::const_iterator it = bss.begin (); while (it != bss.end ()) { // Affichage du premier point vector<Pt2i> points = (*it)->getAllPoints (); - fout << points.front().x() << " " << points.front().y() << " " - << points.back().x() << " " << points.back().y() << std::endl; + AbsRat x1, y1, x2, y2; + DigitalStraightSegment *dss = (*it)->getSegment (); + dss->naiveLine (x1, y1, x2, y2); + fout << (x1.num () / (double) x1.den ()) << " " + << (y1.num () / (double) y1.den ()) << " " + << (x2.num () / (double) x2.den ()) << " " + << (y2.num () / (double) y2.den ()) << std::endl; // Export pour l'affichage de tous les points d'un segments for(auto &p : points) { @@ -187,9 +203,14 @@ int main (int argc, char *argv[]) { // Affichage du premier point vector<Pt2i> points = (*it)->getAllPoints (); - - fout << points.front().x() << " " << points.front().y() << " " - << points.back().x() << " " << points.back().y() << std::endl; + + AbsRat x1, y1, x2, y2; + DigitalStraightSegment *dss = (*it)->getSegment (); + dss->naiveLine (x1, y1, x2, y2); + fout << (x1.num () / (double) x1.den ()) << " " + << (y1.num () / (double) y1.den ()) << " " + << (x2.num () / (double) x2.den ()) << " " + << (y2.num () / (double) y2.den ()) << std::endl; // Export pour l'affichage de tous les points d'un segments for(auto &p : points) diff --git a/Code/FBSD/ImageTools/vmap.h b/Code/FBSD/ImageTools/vmap.h index 027977d..aa733e7 100755 --- a/Code/FBSD/ImageTools/vmap.h +++ b/Code/FBSD/ImageTools/vmap.h @@ -225,12 +225,12 @@ public: /** * \brief Returns the gradient resolution value used for maxima filtering. */ - inline int getGradientResolution () const { return (gradres); } + inline int getLocalMaxGradientResolution () const { return (gradres); } /** * \brief Increments the gradient resolution value used for maxima filtering. */ - inline void incGradientResolution (int inc) { + inline void incLocalMaxGradientResolution (int inc) { gradres += inc * 5; if (gradres < 0) gradres = 0; } diff --git a/Code/FBSD/main.cpp b/Code/FBSD/main.cpp index 867c417..29b38fa 100755 --- a/Code/FBSD/main.cpp +++ b/Code/FBSD/main.cpp @@ -61,9 +61,9 @@ int main (int argc, char *argv[]) else if (string(argv[i]) == string ("-idet")) window.toggleIdetWindow (); // Test command : time ./Seg -test ../Images/couloir.jpg + else if (string(argv[i]) == string ("-oud")) { out = true; xt = true; } // DEV OUT else if (string(argv[i]) == string ("-out")) out = true; - else if (string(argv[i]) == string ("-oud")) { out = true; xt = true; } else if (string(argv[i]) == string ("-sobel3x3")) window.useGradient (VMap::TYPE_SOBEL_3X3); else if (string(argv[i]) == string ("-sobel5x5")) @@ -127,7 +127,7 @@ int main (int argc, char *argv[]) if (gMap != NULL) delete gMap; gMap = new VMap (width, height, tabImage, VMap::TYPE_SOBEL_5X5); detector.setGradientMap (gMap); - if (xt) detector.setStaticDetector (true); + if (xt) detector.setStaticDetector (true); // DEV // buildGradientImage (0); detector.detectAll (); ofstream outf ("naivelines.txt", ios::out); diff --git a/Methode/ctrl.tex b/Methode/ctrl.tex index dbcf967..e7891b8 100755 --- a/Methode/ctrl.tex +++ b/Methode/ctrl.tex @@ -23,10 +23,12 @@ \begin{tabular}{|rcl|} \hline \multicolumn{3}{|l|}{Contr\^ole de l'extraction :} \\ -a/q/c &\spa & Enregistre / Affiche / Supprime les segments \\ -b && Ajuste la r\'esolution du gradient pour le filtrage des max locaux \\ +a/q/x &\spa & Enregistre / Affiche / Supprime les segments \\ +b && Ajuste le contraste de l'image \\ +c && Commute le jeu de couleurs d'affichage des segments flous \\ +d && Commute le style d'affichage des segments flous \\ e && Inverse la direction de r\'ef\'erence (autre bord) \\ -g && Ajuste le seuil du gradient \\ +g && Ajuste la sensibilit\'e du d\'etecteur (seuil du gradient) \\ j && Ajuste le seuil de voisinage pour les suivis rapides \\ k && Ajuste la taille minimale des fragments \\ l && Ajuste la taille minimale du segment initial \\ @@ -38,39 +40,41 @@ r && Ajuste la r\'esolution de la grille de d\'etection automatique \\ s && Ajuste la taille minimale des segments flous d\'etect\'es \\ t && Ajuste la longueur tol\'er\'ee pour les sauts de d\'etection \\ u && Relance la d\'etection sur la derni\`ere s\'election (update) \\ -x && Ajuste la marge de consigne d'\'epaisseur du segment flou pour le suivi rapide \\ -y && Ajuste le contraste de l'image \\ +w && Ajuste la consigne initiale d'\'epaisseur \\ +y && Ajuste la r\'esolution du gradient pour le filtrage des max locaux \\ z && Ajuste le d\'elai de d\'eclenchement du contr\^ole de la consigne d'\'epaisseur \\ +:! && Affiche les segments avec des couleurs al\'eatoires \\ Ctrl-b && Commute le fond d'\'ecran de la fen\^etre principale \\ -Ctrl-d && Commute le test initial de densit\'e \\ +Ctrl-d && Commute la d\'etection des bords oppos\'es en multi-d\'etection \\ Ctrl-e && Commute la prise en compte de la direction du bord (trait / contour) \\ Ctrl-f && Commute le pr\'e-filtrage (segment initial) \\ +Ctrl-g && Commute la directionnalit\'e (ortho) des scans \\ Ctrl-h && Commute le filtrage du segment final \\ Ctrl-j && Commute la contrainte de voisinage pour les suivis rapides \\ Ctrl-k && Commute le test de fragmentation \\ -Ctrl-l && Commute le test de densit\'e final \\ +Ctrl-l && Commute le test initial de densit\'e \\ Ctrl-m && Commute la d\'etection multiple \\ Ctrl-n && Commute la limitation de l'extension de la d\'etection initiale \\ -Ctrl-o && Commute la directionnalit\'e des scans \\ +Ctrl-o && Commute l'affichage des mesures des segments d\'etect\'es \\ Ctrl-p && Commute la d\'etection pr\'eliminaire \\ Ctrl-q && Commute le contr\^ole dynamique des scans \\ Ctrl-r && Commute la dilatation du masque d'occupation \\ Ctrl-s && Commute le test final de taille minimale des segments flous \\ Ctrl-t && Commute la gestion des reprises sur interruption (1 / longueur absence) \\ -Ctrl-u && Commute l'affichage des bords des segments flous. \\ +Ctrl-u && Commute la d\'etection des segments en travers \\ Ctrl-v && Commute l'affichage du r\'esultat de la d\'etection en console (verbose) \\ Ctrl-w && Commute le recentrage du scan sur le segment d\'etect\'e \\ Ctrl-x && Commute l'ancien (sans ADS et ATC) et le nouveau d\'etecteur \\ -Ctrl-y && Commute l'affichage des pixels des segments flous \\ +Ctrl-y && Commute le test de densit\'e final \\ Ctrl-z && Commute le contr\^ole de la consigne d'\'epaisseur \\ -Ctrl-! && Commute la couleur de s\'election des segments flous \\ $<>$ && D\'ecale horizontalement l'affichage sur une grosse image \\ -$\wedge$v && D\'ecale verticalement l'affichage sur une grosse image \\ +$\wedge\vee$ && D\'ecale verticalement l'affichage sur une grosse image \\ +- && Zoom (ou d\'ezoome) sur une grosse image \\ 1 && Commute la visu des segments (pixels) \\ 2 && Commute la visu de l'accumulateur \\ 3 && Commute la visu des profils \\ 4 && Commute la visu de la d\'etection initiale \\ +5 && Commute la visu des tests sur v\'erit\'e de terrain \\ 7 && Enregistre la barre initiale dans test.txt \\ 9 && Teste la performance sur la derni\`ere barre trac\'ee \\ 0 && Teste avec la derni\`ere barre enregistr\'ee (test.txt) \\ @@ -112,6 +116,7 @@ $< \wedge > \vee$ && D\'ecalage de l'observation \\ \multicolumn{3}{|l|}{Param\`etres d'ex\'ecution :} \\ {\tt -out} && Sort les lignes d'une d\'etection auto sur l'image fournie dans {\tt naivelines.txt}. \\ +{\tt -random} && Lance un test de perfomance sur images synth\'etiques. \\ \hline \end{tabular} diff --git a/Methode/evals.tex b/Methode/evals.tex index 73ea3f9..83788bf 100755 --- a/Methode/evals.tex +++ b/Methode/evals.tex @@ -259,4 +259,28 @@ segment ({\tt new\_map.png} et {\tt old\_map.png}). Le vert (vrais positifs) doit dominer. Le bleu correspond aux vrais n\'egatifs (portions de segments non d\'etect\'es) et le rouge aux faux positifs (d\'etections en dehors). +\section{Tests sur une image r\'eelle} + +On ne compare que l'\'evolution entre le d\'etecteur de la publi IWCIA'09 +(sans ADS et ATC) et le nouveau d\'etecteur (avec ADS et ATC). \\ + +{\bf Mesure des temps d'ex\'ecution} \\ +Placer l'image dans {\tt FBSD/test.jpg}. \\ +Lancer {\tt FBSD -yt} et r\'ecup\'erer le r\'esultat dans {\tt fbsdperf.txt}. +Attention, c'est le temps en secondes pour 100 d\'etections avec la version +avec ADS et ATC. \\ +Lancer {\tt FBSD -xt} et r\'ecup\'erer le r\'esultat dans {\tt fbsdperf.txt}. +Attention, c'est le temps en secondes pour 100 d\'etections avec la version +sans ADS et ATC. \\ + +{\bf Mesure des longueurs et largeurs} \\ +Lancer {\tt FBSD -oud <image>} et r\'ecup\'erer les lignes sans +ADS et ATC dans {\tt naivelines.txt}. \\ +Renommer {\tt naivelines.txt} en {\tt naiveold.txt}. \\ +Lancer {\tt FBSD -out <image>} et r\'ecup\'erer les lignes avec +ADS et ATC dans {\tt naivelines.txt}. \\ +Renommer {\tt naivelines.txt} en {\tt naivenew.txt}. \\ +Lancer {\tt Expes/OwnUrbanDB/Scripts/meanlth} et r\'ecup\'erer le r\'esultat +dans {\tt meanlth.txt}. \\ + \end{document} -- GitLab