diff --git a/Code/FBSD/BSTools/bsdetectionwidget.cpp b/Code/FBSD/BSTools/bsdetectionwidget.cpp index abc5244607a12090e5a2afaabb7a07c2ba065e36..be62ee7c0dfe34cd96de781ef3e0bf844d2f8867 100755 --- a/Code/FBSD/BSTools/bsdetectionwidget.cpp +++ b/Code/FBSD/BSTools/bsdetectionwidget.cpp @@ -941,6 +941,11 @@ void BSDetectionWidget::keyPressEvent (QKeyEvent *event) displayDetectionResult (); break; + case Qt::Key_Semicolon : + // Stores blurred segments features + writeBStraverse (); + break; + case Qt::Key_Plus : if (zoom > 1) { @@ -1268,6 +1273,73 @@ void BSDetectionWidget::writeDetectionResult () } +void BSDetectionWidget::writeBStraverse () +{ + int xlls = 1939000; + int ylls = 13548000; + int travel = 24; + vector<BlurredSegment *> bss = detector.getBlurredSegments (); + if (bss.empty ()) + { + BlurredSegment *bs = detector.getBlurredSegment (); + if (bs != NULL) + { + ofstream outf ("strokes.txt", ios::out); + DigitalStraightSegment *dss = bs->getSegment (); + AbsRat x1r, y1r, x2r, y2r; + dss->naiveLine (x1r, y1r, x2r, y2r); + float x1 = x1r.num () / (float) x1r.den (); + float y1 = y1r.num () / (float) y1r.den (); + float x2 = x2r.num () / (float) x2r.den (); + float y2 = y2r.num () / (float) y2r.den (); + float ln = (float) sqrt ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); + float dx = (x2 - x1) / ln; + float dy = (y2 - y1) / ln; + for (float pos = 0.0f; pos <= ln; pos += travel) + { + outf << xlls + (int) (x1 + pos * dx - travel * dy + 0.5f) << " " + << ylls + (int) (y1 + pos * dy + travel * dx + 0.5f) << " " + << xlls + (int) (x1 + pos * dx + travel * dy + 0.5f) << " " + << ylls + (int) (y1 + pos * dy - travel * dx + 0.5f) << endl; + } + outf.close (); + } + } + else + { + DigitalStraightSegment *dss = NULL; + AbsRat x1r, y1r, x2r, y2r; + float x1, y1, x2, y2, ln, dx, dy; + ofstream outf ("strokes.txt", ios::out); + vector<BlurredSegment *>::iterator it = bss.begin (); + while (it != bss.end ()) + { + if (*it != NULL) + { + dss = (*it)->getSegment (); + dss->naiveLine (x1r, y1r, x2r, y2r); + x1 = x1r.num () / (float) x1r.den (); + y1 = y1r.num () / (float) y1r.den (); + x2 = x2r.num () / (float) x2r.den (); + y2 = y2r.num () / (float) y2r.den (); + ln = (float) sqrt ((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)); + dx = (x2 - x1) / ln; + dy = (y2 - y1) / ln; + for (float pos = 0.0f; pos <= ln; pos += travel) + { + outf << xlls + (int) (x1 + pos * dx - travel * dy + 0.5f) << " " + << ylls + (int) (y1 + pos * dy + travel * dx + 0.5f) << " " + << xlls + (int) (x1 + pos * dx + travel * dy + 0.5f) << " " + << ylls + (int) (y1 + pos * dy - travel * dx + 0.5f) << endl; + } + } + it ++; + } + outf.close (); + } +} + + void BSDetectionWidget::displayDetectionResult () { if (background == BACK_BLACK) augmentedImage.fill (qRgb (0, 0, 0)); diff --git a/Code/FBSD/BSTools/bsdetectionwidget.h b/Code/FBSD/BSTools/bsdetectionwidget.h index 9f973debbb21f15a113d2cd889ae331c24afc2ba..e1c4487a6087611e70190853e4fc8e3416bfb597 100755 --- a/Code/FBSD/BSTools/bsdetectionwidget.h +++ b/Code/FBSD/BSTools/bsdetectionwidget.h @@ -410,6 +410,11 @@ private: */ void writeDetectionResult (); + /** + * \brief Computes seeds for ASD (strokes.txt). + */ + void writeBStraverse (); + /** * \brief Displays the result of the last detection. */