Commit 0f9a27402116b8f501571aa2fb60a6c75673949a

Authored by bhklein
1 parent 160baa2e

wider crop and drop normalized error plot from plotLandmarking

openbr/core/eval.cpp
... ... @@ -906,7 +906,7 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle
906 906 // Get best and worst performing examples
907 907 QList< QPair<float,int> > exampleIndices = Common::Sort(imageErrors,true);
908 908  
909   - QScopedPointer<Transform> t(Transform::make("Open+Draw(rects=false)+CropFromLandmarks+Resize(128,method=Area)",NULL));
  909 + QScopedPointer<Transform> t(Transform::make("Open+CropFromLandmarks(paddingHorizontal=.3,paddingVertical=.3,shiftPoints=true)+Resize(128,method=Area)+Draw(rects=false,pointRadius=2)",NULL));
910 910  
911 911 for (int i=0; i<totalExamples; i++) {
912 912 QString filePath = "landmarking_examples_truth/"+truth[exampleIndices[i].second].file.fileName();
... ...
openbr/core/plot.cpp
... ... @@ -330,9 +330,6 @@ bool PlotLandmarking(const QStringList &amp;files, const File &amp;destination, bool sho
330 330 p.file.write(qPrintable(QString("ggplot(Box, aes(factor(X), Y%1%2))").arg(p.major.size > 1 ? QString(", colour=%1").arg(p.major.header) : QString(), p.minor.size > 1 ? QString(", linetype=%1").arg(p.minor.header) : QString()) +
331 331 QString("+ annotation_logticks(sides=\"l\") + geom_boxplot(alpha=0.5) + geom_jitter(size=1, alpha=0.5) + scale_x_discrete(\"Landmark\") + scale_y_log10(\"Normalized Error\", breaks=c(0.001,0.01,0.1,1,10)) + theme_minimal()\n\n")));
332 332  
333   - p.file.write(qPrintable(QString("ggplot(Box, aes(factor(X), Y%1%2))").arg(p.major.size > 1 ? QString(", colour=%1").arg(p.major.header) : QString(), p.minor.size > 1 ? QString(", linetype=%1").arg(p.minor.header) : QString()) +
334   - QString("+ annotation_logticks(sides=\"l\") + geom_violin(alpha=0.5) + scale_x_discrete(\"Landmark\") + scale_y_log10(\"Normalized Error\", breaks=c(0.001,0.01,0.1,1,10))\n\n")));
335   -
336 333 return p.finalize(show);
337 334 }
338 335  
... ...
openbr/plugins/gui/draw.cpp
... ... @@ -38,6 +38,7 @@ class DrawTransform : public UntrainableTransform
38 38 Q_PROPERTY(bool rects READ get_rects WRITE set_rects RESET reset_rects STORED false)
39 39 Q_PROPERTY(bool inPlace READ get_inPlace WRITE set_inPlace RESET reset_inPlace STORED false)
40 40 Q_PROPERTY(int lineThickness READ get_lineThickness WRITE set_lineThickness RESET reset_lineThickness STORED false)
  41 + Q_PROPERTY(int pointRadius READ get_pointRadius WRITE set_pointRadius RESET reset_pointRadius STORED false)
41 42 Q_PROPERTY(bool named READ get_named WRITE set_named RESET reset_named STORED false)
42 43 Q_PROPERTY(bool location READ get_location WRITE set_location RESET reset_location STORED false)
43 44 BR_PROPERTY(bool, verbose, false)
... ... @@ -45,6 +46,7 @@ class DrawTransform : public UntrainableTransform
45 46 BR_PROPERTY(bool, rects, true)
46 47 BR_PROPERTY(bool, inPlace, false)
47 48 BR_PROPERTY(int, lineThickness, 1)
  49 + BR_PROPERTY(int, pointRadius, 3)
48 50 BR_PROPERTY(bool, named, true)
49 51 BR_PROPERTY(bool, location, true)
50 52  
... ... @@ -58,7 +60,7 @@ class DrawTransform : public UntrainableTransform
58 60 const QList<Point2f> pointsList = (named) ? OpenCVUtils::toPoints(src.file.points()+src.file.namedPoints()) : OpenCVUtils::toPoints(src.file.points());
59 61 for (int i=0; i<pointsList.size(); i++) {
60 62 const Point2f &point = pointsList[i];
61   - circle(dst, point, 3, color, -1);
  63 + circle(dst, point, pointRadius, color, -1);
62 64 QString label = (location) ? QString("%1,(%2,%3)").arg(QString::number(i),QString::number(point.x),QString::number(point.y)) : QString("%1").arg(QString::number(i));
63 65 if (verbose) putText(dst, label.toStdString(), point, FONT_HERSHEY_SIMPLEX, 0.5, verboseColor, 1);
64 66 }
... ...
openbr/plugins/imgproc/cropfromlandmarks.cpp
... ... @@ -19,9 +19,11 @@ class CropFromLandmarksTransform : public UntrainableTransform
19 19 Q_PROPERTY(QList<int> indices READ get_indices WRITE set_indices RESET reset_indices STORED false)
20 20 Q_PROPERTY(float paddingHorizontal READ get_paddingHorizontal WRITE set_paddingHorizontal RESET reset_paddingHorizontal STORED false)
21 21 Q_PROPERTY(float paddingVertical READ get_paddingVertical WRITE set_paddingVertical RESET reset_paddingVertical STORED false)
  22 + Q_PROPERTY(bool shiftPoints READ get_shiftPoints WRITE set_shiftPoints RESET reset_shiftPoints STORED false)
22 23 BR_PROPERTY(QList<int>, indices, QList<int>())
23 24 BR_PROPERTY(float, paddingHorizontal, .1)
24 25 BR_PROPERTY(float, paddingVertical, .1)
  26 + BR_PROPERTY(bool, shiftPoints, false)
25 27  
26 28 void project(const Template &src, Template &dst) const
27 29 {
... ... @@ -55,6 +57,13 @@ class CropFromLandmarksTransform : public UntrainableTransform
55 57 if (rect.x() + rect.width() > src.m().cols) rect.setWidth(src.m().cols - rect.x());
56 58 if (rect.y() + rect.width() > src.m().rows) rect.setHeight(src.m().rows - rect.y());
57 59  
  60 + if (shiftPoints) {
  61 + QList<QPointF> points = src.file.points();
  62 + for (int i=0; i<points.size(); i++)
  63 + points[i] -= rect.topLeft();
  64 + dst.file.setPoints(points);
  65 + }
  66 +
58 67 dst = Mat(src, OpenCVUtils::toRect(rect));
59 68 }
60 69 };
... ...
openbr/plugins/imgproc/resize.cpp
... ... @@ -65,7 +65,7 @@ private:
65 65 if (!preserveAspect) {
66 66 resize(src, dst, Size((columns == -1) ? src.m().cols*rows/src.m().rows : columns, rows), 0, 0, method);
67 67 const float rowScaleFactor = (float)rows/src.m().rows;
68   - const float colScaleFactor = (float)columns/src.m().cols;
  68 + const float colScaleFactor = (columns == -1) ? rowScaleFactor : (float)columns/src.m().cols;
69 69 QList<QPointF> points = src.file.points();
70 70 for (int i=0; i<points.size(); i++)
71 71 points[i] = QPointF(points[i].x() * colScaleFactor,points[i].y() * rowScaleFactor);
... ...