Commit d9c60f6e20518d7df4de3b1146296391ce55dc73
Fixed conflicts with master
Showing
3 changed files
with
17 additions
and
5 deletions
openbr/core/core.cpp
| ... | ... | @@ -46,6 +46,7 @@ struct AlgorithmCore |
| 46 | 46 | model.isEmpty() ? "" : qPrintable(" to " + model)); |
| 47 | 47 | |
| 48 | 48 | QScopedPointer<Transform> trainingWrapper(Transform::make("DirectStream([Identity], readMode=DistributeFrames)", NULL)); |
| 49 | + | |
| 49 | 50 | CompositeTransform * downcast = dynamic_cast<CompositeTransform *>(trainingWrapper.data()); |
| 50 | 51 | if (downcast == NULL) |
| 51 | 52 | qFatal("downcast failed?"); | ... | ... |
openbr/plugins/regions.cpp
| ... | ... | @@ -372,7 +372,7 @@ class FaceFromEyesTransform : public UntrainableTransform |
| 372 | 372 | BR_PROPERTY(double, widthPadding, 0.7) |
| 373 | 373 | BR_PROPERTY(double, verticalLocation, 0.25) |
| 374 | 374 | BR_PROPERTY(int, leftEyeIdx, 0) |
| 375 | - BR_PROPERTY(int, rightEyeIdx, 0) | |
| 375 | + BR_PROPERTY(int, rightEyeIdx, 1) | |
| 376 | 376 | |
| 377 | 377 | void project(const Template &src, Template &dst) const |
| 378 | 378 | { |
| ... | ... | @@ -384,8 +384,8 @@ class FaceFromEyesTransform : public UntrainableTransform |
| 384 | 384 | return; |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - QPointF eyeL = src.file.points()[0]; | |
| 388 | - QPointF eyeR = src.file.points()[1]; | |
| 387 | + QPointF eyeL = src.file.points()[leftEyeIdx]; | |
| 388 | + QPointF eyeR = src.file.points()[rightEyeIdx]; | |
| 389 | 389 | QPointF eyeCenter((eyeL.x() + eyeR.x()) / 2, (eyeL.y() + eyeR.y()) / 2); |
| 390 | 390 | float ipd = sqrt(pow(eyeL.x() - eyeR.x(), 2) + pow(eyeL.y() - eyeR.y(), 2)); |
| 391 | 391 | float width = ipd + 2 * widthPadding * ipd; | ... | ... |
openbr/plugins/slidingwindow.cpp
| ... | ... | @@ -46,11 +46,13 @@ class SlidingWindowTransform : public MetaTransform |
| 46 | 46 | Q_PROPERTY(bool takeFirst READ get_takeFirst WRITE set_takeFirst RESET reset_takeFirst STORED false) |
| 47 | 47 | Q_PROPERTY(float threshold READ get_threshold WRITE set_threshold RESET reset_threshold STORED false) |
| 48 | 48 | Q_PROPERTY(float stepFraction READ get_stepFraction WRITE set_stepFraction RESET reset_stepFraction STORED false) |
| 49 | + Q_PROPERTY(int ignoreBorder READ get_ignoreBorder WRITE set_ignoreBorder RESET reset_ignoreBorder STORED false) | |
| 49 | 50 | BR_PROPERTY(br::Transform *, transform, NULL) |
| 50 | 51 | BR_PROPERTY(int, windowWidth, 24) |
| 51 | 52 | BR_PROPERTY(bool, takeFirst, false) |
| 52 | 53 | BR_PROPERTY(float, threshold, 0) |
| 53 | 54 | BR_PROPERTY(float, stepFraction, 0.25) |
| 55 | + BR_PROPERTY(int, ignoreBorder, 0) | |
| 54 | 56 | |
| 55 | 57 | private: |
| 56 | 58 | int windowHeight; |
| ... | ... | @@ -61,8 +63,17 @@ private: |
| 61 | 63 | if (aspectRatio == -1) |
| 62 | 64 | aspectRatio = getAspectRatio(data); |
| 63 | 65 | windowHeight = qRound(windowWidth / aspectRatio); |
| 66 | + | |
| 64 | 67 | if (transform->trainable) { |
| 65 | - transform->train(data); | |
| 68 | + TemplateList dataOut = data; | |
| 69 | + if (ignoreBorder > 0) { | |
| 70 | + for (int i = 0; i < dataOut.size(); i++) { | |
| 71 | + Template t = dataOut[i]; | |
| 72 | + Mat m = t.m(); | |
| 73 | + dataOut.replace(i,Template(t.file, Mat(m,Rect(ignoreBorder,ignoreBorder,m.cols - ignoreBorder * 2, m.rows - ignoreBorder * 2)))); | |
| 74 | + } | |
| 75 | + } | |
| 76 | + transform->train(dataOut); | |
| 66 | 77 | } |
| 67 | 78 | } |
| 68 | 79 | |
| ... | ... | @@ -101,7 +112,7 @@ protected: |
| 101 | 112 | foreach (const Template &t, src) { |
| 102 | 113 | for (float y = 0; y + windowHeight < t.m().rows; y += windowHeight*stepFraction) { |
| 103 | 114 | for (float x = 0; x + windowWidth < t.m().cols; x += windowWidth*stepFraction) { |
| 104 | - Mat windowMat(t.m(), Rect(x, y, windowWidth, windowHeight)); | |
| 115 | + Mat windowMat(t.m(), Rect(x + ignoreBorder, y + ignoreBorder, windowWidth - ignoreBorder * 2, windowHeight - ignoreBorder * 2)); | |
| 105 | 116 | Template detect; |
| 106 | 117 | transform->project(Template(t.file, windowMat), detect); |
| 107 | 118 | ... | ... |