Commit 4569eb798c3745735d4c9621bca1520cb19760d2
1 parent
5f550074
STASM update with register.cpp changes
Showing
3 changed files
with
27 additions
and
7 deletions
openbr/core/core.cpp
| ... | ... | @@ -167,6 +167,7 @@ struct AlgorithmCore |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | const float speed = 1000 * Globals->totalSteps / Globals->startTime.elapsed() / std::max(1, abs(Globals->parallelism)); |
| 170 | + qDebug() << Globals->startTime.elapsed(); | |
| 170 | 171 | if (!Globals->quiet && (Globals->totalSteps > 1)) |
| 171 | 172 | fprintf(stderr, "\rSPEED=%.1e SIZE=%.4g FAILURES=%d/%d \n", |
| 172 | 173 | speed, totalBytes/totalCount, failureCount, totalCount); | ... | ... |
openbr/plugins/register.cpp
| ... | ... | @@ -86,12 +86,16 @@ class AffineTransform : public UntrainableTransform |
| 86 | 86 | |
| 87 | 87 | dst.file.set("Affine_0", OpenCVUtils::fromPoint(landmarks[0])); |
| 88 | 88 | dst.file.set("Affine_1", OpenCVUtils::fromPoint(landmarks[1])); |
| 89 | + | |
| 89 | 90 | if (!twoPoints) dst.file.set("Affine_2", OpenCVUtils::fromPoint(landmarks[2])); |
| 90 | 91 | } |
| 91 | 92 | } |
| 92 | 93 | if (twoPoints) srcPoints[2] = getThirdAffinePoint(srcPoints[0], srcPoints[1]); |
| 93 | 94 | |
| 94 | 95 | warpAffine(src, dst, getAffineTransform(srcPoints, dstPoints), Size(width, height)); |
| 96 | + | |
| 97 | + dst.file.set("Affine_0", OpenCVUtils::fromPoint(dstPoints[0])); | |
| 98 | + dst.file.set("Affine_1", OpenCVUtils::fromPoint(dstPoints[1])); | |
| 95 | 99 | } |
| 96 | 100 | }; |
| 97 | 101 | ... | ... |
openbr/plugins/stasm.cpp
| 1 | 1 | #include <stasm_dll.hpp> |
| 2 | +#include <stasm.hpp> | |
| 2 | 3 | #include <opencv2/highgui/highgui.hpp> |
| 3 | 4 | #include "openbr_internal.h" |
| 4 | 5 | |
| ... | ... | @@ -18,11 +19,11 @@ class StasmInitializer : public Initializer |
| 18 | 19 | |
| 19 | 20 | void initialize() const |
| 20 | 21 | { |
| 21 | - Globals->abbreviations.insert("RectFromStasmEyes","RectFromPoints([27, 28, 29, 30, 31, 32, 33, 34, 35, 36],0.125,6.0)+Resize(44,164)"); // | |
| 22 | + Globals->abbreviations.insert("RectFromStasmEyes","RectFromPoints([27, 28, 29, 30, 31, 32, 33, 34, 35, 36],0.125,6.0)+Resize(44,164)"); | |
| 22 | 23 | Globals->abbreviations.insert("RectFromStasmJaw","RectFromPoints([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],10)"); |
| 23 | - Globals->abbreviations.insert("RectFromStasmBrow","RectFromPoints([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],0.25,6.5)+Resize(44,230)"); | |
| 24 | + Globals->abbreviations.insert("RectFromStasmBrow","RectFromPoints([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],0.15,6)+Resize(28,132)"); | |
| 24 | 25 | Globals->abbreviations.insert("RectFromStasmNose","RectFromPoints([38, 39, 40, 41, 42, 43, 44, 67],0.15,1.25)+Resize(44,44)"); |
| 25 | - 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)"); | |
| 26 | + 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)"); | |
| 26 | 27 | } |
| 27 | 28 | }; |
| 28 | 29 | |
| ... | ... | @@ -37,20 +38,34 @@ class StasmTransform : public UntrainableTransform |
| 37 | 38 | { |
| 38 | 39 | Q_OBJECT |
| 39 | 40 | |
| 41 | + QList<ASM_MODEL> models; | |
| 42 | + //mutable QMutex mutex; | |
| 43 | + | |
| 40 | 44 | void init() |
| 41 | 45 | { |
| 42 | - // Load models | |
| 46 | + models = nInitAsmModels(qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/mu-68-1d.conf"), qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/mu-76-2d.conf")); | |
| 43 | 47 | } |
| 44 | 48 | |
| 45 | 49 | void project(const Template &src, Template &dst) const |
| 46 | 50 | { |
| 47 | - static QMutex mutex; | |
| 48 | - QMutexLocker locker(&mutex); | |
| 51 | + //QMutexLocker locker(&mutex); | |
| 52 | + | |
| 53 | + //qDebug() << "PittPatt X: " << src.file.get<QPoint>("Affine_0").x() - src.m().cols/2 << src.file.get<QPoint>("Affine_1").x() - src.m().cols/2; | |
| 54 | + //qDebug() << "PittPatt Y: " << src.m().rows/2 - src.file.get<QPoint>("Affine_0").y() << src.m().rows/2 - src.file.get<QPoint>("Affine_1").y(); | |
| 49 | 55 | |
| 50 | 56 | int numLandmarks; |
| 51 | 57 | int landmarks[500]; |
| 52 | 58 | |
| 53 | - AsmSearchDll(numLandmarks, landmarks, qPrintable(src.file.name), reinterpret_cast<char*>(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/")); | |
| 59 | + DET_PARAMS parameters; | |
| 60 | + parameters.lex = src.file.get<QPoint>("Affine_0").x() - src.m().cols/2; | |
| 61 | + parameters.ley = src.m().rows/2 - src.file.get<QPoint>("Affine_0").y(); | |
| 62 | + parameters.rex = src.file.get<QPoint>("Affine_1").x() - src.m().cols/2; | |
| 63 | + parameters.rey = src.m().rows/2 - src.file.get<QPoint>("Affine_1").y(); | |
| 64 | + | |
| 65 | + AsmSearchDll(numLandmarks, landmarks, qPrintable(src.file.name), | |
| 66 | + reinterpret_cast<char*>(src.m().data), src.m(), models, | |
| 67 | + qPrintable(Globals->sdkPath + "/share/openbr/models/stasm/"), | |
| 68 | + parameters); | |
| 54 | 69 | |
| 55 | 70 | if (numLandmarks == 0) { |
| 56 | 71 | qWarning("Unable to detect Stasm landmarks for %s", qPrintable(src.file.fileName())); | ... | ... |