From f9adb23cf372aefeed1f556c1e3cbaa29e83001b Mon Sep 17 00:00:00 2001 From: Charles Otto Date: Mon, 12 Aug 2013 14:45:00 -0700 Subject: [PATCH] Add a bool option to StasmTransform allowing output in the stasm3 points format --- openbr/plugins/stasm4.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/openbr/plugins/stasm4.cpp b/openbr/plugins/stasm4.cpp index fa7f271..c8195b1 100644 --- a/openbr/plugins/stasm4.cpp +++ b/openbr/plugins/stasm4.cpp @@ -54,6 +54,9 @@ class StasmTransform : public UntrainableTransform { Q_OBJECT + Q_PROPERTY(bool stasm3Format READ get_stasm3Format WRITE set_stasm3Format RESET reset_stasm3Format STORED false) + BR_PROPERTY(bool, stasm3Format, false) + Resource stasmCascadeResource; void init() @@ -69,14 +72,20 @@ class StasmTransform : public UntrainableTransform StasmCascadeClassifier *stasmCascade = stasmCascadeResource.acquire(); int foundface; + int nLandmarks = stasm_NLANDMARKS; float landmarks[2 * stasm_NLANDMARKS]; stasm_search_single(&foundface, landmarks, reinterpret_cast(src.m().data), src.m().cols, src.m().rows, *stasmCascade, NULL, NULL); + if (stasm3Format) { + nLandmarks = 76; + stasm_convert_shape(landmarks, nLandmarks); + } + stasmCascadeResource.release(stasmCascade); if (!foundface) qWarning("No face found in %s", qPrintable(src.file.fileName())); else { - for (int i = 0; i < stasm_NLANDMARKS; i++) + for (int i = 0; i < nLandmarks; i++) dst.file.appendPoint(QPointF(landmarks[2 * i], landmarks[2 * i + 1])); } -- libgit2 0.21.4