diff --git a/Code/Seg/mainIPOL.cpp b/Code/Seg/mainIPOL.cpp new file mode 100755 index 0000000000000000000000000000000000000000..377e4352d301aa57e73e8591f10caac63d2651d4 --- /dev/null +++ b/Code/Seg/mainIPOL.cpp @@ -0,0 +1,60 @@ +#include <QImage> +#include <QString> +#include <QColor> +#include "bsdetector.h" +#include "vmap.h" + + +int main (int argc, char *argv[]) +{ + // Calcul de la carte de gradient (utilise qt) + QImage image; + image.load (QString ("../couloir.gif")); + int width = image.width (); + int height = image.height (); + int **tabImage = new int*[height]; + for (int i = 0; i < height; i++) + { + tabImage[i] = new int[width]; + for(int j = 0; j < width; j++) + { + QColor c = QColor (image.pixel (j, height - i - 1)); + tabImage[i][j] = c.value (); + } + } + VMap *gMap = new VMap (width, height, tabImage, VMap::TYPE_SOBEL_5X5); + + // Detection + BSDetector detector; + detector.setGradientMap (gMap); + detector.setMaxTrials (-1); + detector.detectAll (); + + // Affichage + vector<BlurredSegment *> bss = detector.getBlurredSegments (); + if (! bss.empty ()) + { + vector<BlurredSegment *>::const_iterator it = bss.begin (); + while (it != bss.end ()) + { + // Affichage du premier point + vector<Pt2i> points = (*it)->getAllPoints (); + cout << "BS starts from (" << points.front().x() + << "," << points.front().y() << ")" << endl; + + // Affichage du DSS englobant + vector<Pt2i> bnd; + DigitalStraightSegment *dss = (*it)->getSegment (); + if (dss != NULL) + { + dss->getBounds (bnd, 0, 0, width, height); + cout << "DSS starts from (" << bnd.front().x() + << "," << bnd.front().y() << ")" << endl; + } + + it++; + } + } + + return (0); +}