Commit 681cd399664102105c1333a9804aa5a767bc76cc
1 parent
89f83838
crop and resize landmark examples
Showing
2 changed files
with
16 additions
and
11 deletions
openbr/core/eval.cpp
| @@ -898,7 +898,7 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | @@ -898,7 +898,7 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | ||
| 898 | { | 898 | { |
| 899 | QScopedPointer<Transform> t(Transform::make("Open+Draw(verbose,rects=false,location=false)",NULL)); | 899 | QScopedPointer<Transform> t(Transform::make("Open+Draw(verbose,rects=false,location=false)",NULL)); |
| 900 | 900 | ||
| 901 | - QString filePath = "landmarking_examples_truth/"+truth[sampleIndex].file.fileName(); | 901 | + QString filePath = "landmarking_examples_truth/sample.jpg"; |
| 902 | projectAndWrite(t.data(), truth[sampleIndex],filePath); | 902 | projectAndWrite(t.data(), truth[sampleIndex],filePath); |
| 903 | lines.append("Sample,"+filePath+","+QString::number(truth[sampleIndex].file.points().size())); | 903 | lines.append("Sample,"+filePath+","+QString::number(truth[sampleIndex].file.points().size())); |
| 904 | } | 904 | } |
| @@ -906,7 +906,7 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | @@ -906,7 +906,7 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | ||
| 906 | // Get best and worst performing examples | 906 | // Get best and worst performing examples |
| 907 | QList< QPair<float,int> > exampleIndices = Common::Sort(imageErrors,true); | 907 | QList< QPair<float,int> > exampleIndices = Common::Sort(imageErrors,true); |
| 908 | 908 | ||
| 909 | - QScopedPointer<Transform> t(Transform::make("Open+Draw(rects=false)",NULL)); | 909 | + QScopedPointer<Transform> t(Transform::make("Open+Draw(rects=false)+CropFromLandmarks+Resize(128,method=Area)",NULL)); |
| 910 | 910 | ||
| 911 | for (int i=0; i<totalExamples; i++) { | 911 | for (int i=0; i<totalExamples; i++) { |
| 912 | QString filePath = "landmarking_examples_truth/"+truth[exampleIndices[i].second].file.fileName(); | 912 | QString filePath = "landmarking_examples_truth/"+truth[exampleIndices[i].second].file.fileName(); |
openbr/plugins/imgproc/cropfromlandmarks.cpp
| @@ -25,20 +25,25 @@ class CropFromLandmarksTransform : public UntrainableTransform | @@ -25,20 +25,25 @@ class CropFromLandmarksTransform : public UntrainableTransform | ||
| 25 | 25 | ||
| 26 | void project(const Template &src, Template &dst) const | 26 | void project(const Template &src, Template &dst) const |
| 27 | { | 27 | { |
| 28 | + QList<int> cropIndices = indices; | ||
| 29 | + if (cropIndices.isEmpty() && !src.file.points().isEmpty()) | ||
| 30 | + for (int i=0; i<src.file.points().size(); i++) | ||
| 31 | + cropIndices.append(i); | ||
| 32 | + | ||
| 28 | int minX = src.m().cols - 1, | 33 | int minX = src.m().cols - 1, |
| 29 | maxX = 1, | 34 | maxX = 1, |
| 30 | minY = src.m().rows - 1, | 35 | minY = src.m().rows - 1, |
| 31 | maxY = 1; | 36 | maxY = 1; |
| 32 | 37 | ||
| 33 | - for (int i = 0; i <indices.size(); i++) { | ||
| 34 | - if (minX > src.file.points()[indices[i]].x()) | ||
| 35 | - minX = src.file.points()[indices[i]].x(); | ||
| 36 | - if (minY > src.file.points()[indices[i]].y()) | ||
| 37 | - minY = src.file.points()[indices[i]].y(); | ||
| 38 | - if (maxX < src.file.points()[indices[i]].x()) | ||
| 39 | - maxX = src.file.points()[indices[i]].x(); | ||
| 40 | - if (maxY < src.file.points()[indices[i]].y()) | ||
| 41 | - maxY = src.file.points()[indices[i]].y(); | 38 | + for (int i = 0; i <cropIndices.size(); i++) { |
| 39 | + if (minX > src.file.points()[cropIndices[i]].x()) | ||
| 40 | + minX = src.file.points()[cropIndices[i]].x(); | ||
| 41 | + if (minY > src.file.points()[cropIndices[i]].y()) | ||
| 42 | + minY = src.file.points()[cropIndices[i]].y(); | ||
| 43 | + if (maxX < src.file.points()[cropIndices[i]].x()) | ||
| 44 | + maxX = src.file.points()[cropIndices[i]].x(); | ||
| 45 | + if (maxY < src.file.points()[cropIndices[i]].y()) | ||
| 46 | + maxY = src.file.points()[cropIndices[i]].y(); | ||
| 42 | } | 47 | } |
| 43 | 48 | ||
| 44 | int padW = qRound((maxX - minX) * (paddingHorizontal / 2)); | 49 | int padW = qRound((maxX - minX) * (paddingHorizontal / 2)); |