diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index 5f97d70..383ce07 100644 --- a/openbr/core/core.cpp +++ b/openbr/core/core.cpp @@ -167,6 +167,7 @@ struct AlgorithmCore } const float speed = 1000 * Globals->totalSteps / Globals->startTime.elapsed() / std::max(1, abs(Globals->parallelism)); + qDebug() << Globals->startTime.elapsed(); if (!Globals->quiet && (Globals->totalSteps > 1)) fprintf(stderr, "\rSPEED=%.1e SIZE=%.4g FAILURES=%d/%d \n", speed, totalBytes/totalCount, failureCount, totalCount); diff --git a/openbr/plugins/register.cpp b/openbr/plugins/register.cpp index 0536780..e32d126 100644 --- a/openbr/plugins/register.cpp +++ b/openbr/plugins/register.cpp @@ -86,12 +86,16 @@ class AffineTransform : public UntrainableTransform dst.file.set("Affine_0", OpenCVUtils::fromPoint(landmarks[0])); dst.file.set("Affine_1", OpenCVUtils::fromPoint(landmarks[1])); + if (!twoPoints) dst.file.set("Affine_2", OpenCVUtils::fromPoint(landmarks[2])); } } if (twoPoints) srcPoints[2] = getThirdAffinePoint(srcPoints[0], srcPoints[1]); warpAffine(src, dst, getAffineTransform(srcPoints, dstPoints), Size(width, height)); + + dst.file.set("Affine_0", OpenCVUtils::fromPoint(dstPoints[0])); + dst.file.set("Affine_1", OpenCVUtils::fromPoint(dstPoints[1])); } }; diff --git a/openbr/plugins/stasm.cpp b/openbr/plugins/stasm.cpp index 1e3ca2a..8682438 100644 --- a/openbr/plugins/stasm.cpp +++ b/openbr/plugins/stasm.cpp @@ -1,4 +1,5 @@ #include +#include #include #include "openbr_internal.h" @@ -18,11 +19,11 @@ class StasmInitializer : public Initializer void initialize() const { - Globals->abbreviations.insert("RectFromStasmEyes","RectFromPoints([27, 28, 29, 30, 31, 32, 33, 34, 35, 36],0.125,6.0)+Resize(44,164)"); // + Globals->abbreviations.insert("RectFromStasmEyes","RectFromPoints([27, 28, 29, 30, 31, 32, 33, 34, 35, 36],0.125,6.0)+Resize(44,164)"); Globals->abbreviations.insert("RectFromStasmJaw","RectFromPoints([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],10)"); - Globals->abbreviations.insert("RectFromStasmBrow","RectFromPoints([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],0.25,6.5)+Resize(44,230)"); + Globals->abbreviations.insert("RectFromStasmBrow","RectFromPoints([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],0.15,6)+Resize(28,132)"); Globals->abbreviations.insert("RectFromStasmNose","RectFromPoints([38, 39, 40, 41, 42, 43, 44, 67],0.15,1.25)+Resize(44,44)"); - Globals->abbreviations.insert("RectFromStasmMouth","RectFromPoints([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66],0.3,3.0)+Resize(26,68)"); + Globals->abbreviations.insert("RectFromStasmMouth","RectFromPoints([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66],0.3,3.0)+Resize(28,68)"); } }; @@ -37,20 +38,34 @@ class StasmTransform : public UntrainableTransform { Q_OBJECT + QList models; + //mutable QMutex mutex; + void init() { - // Load models + models = nInitAsmModels(qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/mu-68-1d.conf"), qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/mu-76-2d.conf")); } void project(const Template &src, Template &dst) const { - static QMutex mutex; - QMutexLocker locker(&mutex); + //QMutexLocker locker(&mutex); + + //qDebug() << "PittPatt X: " << src.file.get("Affine_0").x() - src.m().cols/2 << src.file.get("Affine_1").x() - src.m().cols/2; + //qDebug() << "PittPatt Y: " << src.m().rows/2 - src.file.get("Affine_0").y() << src.m().rows/2 - src.file.get("Affine_1").y(); int numLandmarks; int landmarks[500]; - AsmSearchDll(numLandmarks, landmarks, qPrintable(src.file.name), reinterpret_cast(src.m().data), src.m(), qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/mu-68-1d.conf"), qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/mu-76-2d.conf"), qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/")); + DET_PARAMS parameters; + parameters.lex = src.file.get("Affine_0").x() - src.m().cols/2; + parameters.ley = src.m().rows/2 - src.file.get("Affine_0").y(); + parameters.rex = src.file.get("Affine_1").x() - src.m().cols/2; + parameters.rey = src.m().rows/2 - src.file.get("Affine_1").y(); + + AsmSearchDll(numLandmarks, landmarks, qPrintable(src.file.name), + reinterpret_cast(src.m().data), src.m(), models, + qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/"), + parameters); if (numLandmarks == 0) { qWarning("Unable to detect Stasm landmarks for %s", qPrintable(src.file.fileName()));