Commit 9cfbe4a6bc2e683ed8be044b5007ddcfcfcfcd23

Authored by Scott Klum
1 parent 819e7a30

Stasm added

sdk/plugins/format.cpp
@@ -44,6 +44,7 @@ class videoFormat : public Format @@ -44,6 +44,7 @@ class videoFormat : public Format
44 public: 44 public:
45 Template read() const 45 Template read() const
46 { 46 {
  47 + //if (file.exists()) {
47 VideoCapture videoSource(file.name.toStdString()); 48 VideoCapture videoSource(file.name.toStdString());
48 videoSource.open(file.name.toStdString() ); 49 videoSource.open(file.name.toStdString() );
49 50
@@ -65,6 +66,7 @@ public: @@ -65,6 +66,7 @@ public:
65 } 66 }
66 67
67 return frames; 68 return frames;
  69 + //}
68 } 70 }
69 71
70 void write(const Template &t) const 72 void write(const Template &t) const
sdk/plugins/pbd.cpp
@@ -34,11 +34,11 @@ class PBDInitializer : public Initializer @@ -34,11 +34,11 @@ class PBDInitializer : public Initializer
34 34
35 void initialize() const 35 void initialize() const
36 { 36 {
37 - Globals->abbreviations.insert("RectFromEyes","RectFromLandmarks([9, 10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 25],10,6.0)");  
38 - Globals->abbreviations.insert("RectFromNose","RectFromLandmarks([0, 1, 2, 3, 4, 5, 6, 7, 8],10)");  
39 - Globals->abbreviations.insert("RectFromBrow","RectFromLandmarks([15, 16, 17, 18, 19, 26, 27, 28, 29, 30],10)");  
40 - Globals->abbreviations.insert("RectFromMouth","RectFromLandmarks([31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],10)");  
41 - Globals->abbreviations.insert("RectFromJaw","RectFromLandmarks([51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67],10)"); 37 + Globals->abbreviations.insert("RectFromPBDEyes","RectFromLandmarks([9, 10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 25],10,6.0)");
  38 + Globals->abbreviations.insert("RectFromPBDNose","RectFromLandmarks([0, 1, 2, 3, 4, 5, 6, 7, 8],10)");
  39 + Globals->abbreviations.insert("RectFromPBDBrow","RectFromLandmarks([15, 16, 17, 18, 19, 26, 27, 28, 29, 30],10)");
  40 + Globals->abbreviations.insert("RectFromPBDMouth","RectFromLandmarks([31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50],10)");
  41 + Globals->abbreviations.insert("RectFromPBDJaw","RectFromLandmarks([51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67],10)");
42 } 42 }
43 43
44 void finalize() const 44 void finalize() const
sdk/plugins/stasm.cpp
  1 +#include <QProcess>
  2 +
  3 +#include <stasm/stasm_dll.hpp>
  4 +
  5 +#include <opencv2/highgui/highgui.hpp>
  6 +
1 #include <openbr_plugin.h> 7 #include <openbr_plugin.h>
2 8
  9 +using namespace cv;
  10 +
3 namespace br 11 namespace br
4 { 12 {
5 13
6 /*! 14 /*!
  15 + * \ingroup initializers
  16 + * \brief Initialize Stasm
  17 + * \author Scott Klum \cite sklum
  18 + */
  19 +class StasmInitializer : public Initializer
  20 +{
  21 + Q_OBJECT
  22 +
  23 + void initialize() const
  24 + {
  25 + Globals->abbreviations.insert("RectFromStasmEyes","RectFromLandmarks([27, 28, 29, 30, 31, 32, 33, 34, 35, 36],10)");
  26 + Globals->abbreviations.insert("RectFromStasmJaw","RectFromLandmarks([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],10)");
  27 + Globals->abbreviations.insert("RectFromStasmBrow","RectFromLandmarks([15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26],10)");
  28 + Globals->abbreviations.insert("RectFromStasmNose","RectFromLandmarks([37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47],10)");
  29 + Globals->abbreviations.insert("RectFromStasmMouth","RectFromLandmarks([48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66],10)");
  30 + }
  31 +
  32 + void finalize() const
  33 + {
  34 +
  35 + }
  36 +};
  37 +
  38 +BR_REGISTER(Initializer, StasmInitializer)
  39 +
  40 +/*!
7 * \ingroup transforms 41 * \ingroup transforms
8 * \brief Wraps STASM key point detector 42 * \brief Wraps STASM key point detector
9 * \author Scott Klum \cite sklum 43 * \author Scott Klum \cite sklum
@@ -20,7 +54,19 @@ class StasmTransform : public UntrainableTransform @@ -20,7 +54,19 @@ class StasmTransform : public UntrainableTransform
20 54
21 void project(const Template &src, Template &dst) const 55 void project(const Template &src, Template &dst) const
22 { 56 {
  57 + int nlandmarks;
  58 + int landmarks[500];
  59 +
  60 + AsmSearchDll(&nlandmarks, landmarks,
  61 + src.file.name.toStdString().c_str(), reinterpret_cast<char*>(src.m().data), src.m().cols, src.m().rows,
  62 + src.m(), (src.m().channels() == 3), NULL, NULL);
  63 +
  64 + if (nlandmarks == 0) qFatal("Unable to detect Stasm landmarks");
  65 +
  66 + for (int i = 0; i < nlandmarks; i++)
  67 + dst.file.appendLandmark(QPointF(landmarks[2 * i], landmarks[2 * i + 1]));
23 68
  69 + dst.m() = src.m().clone();
24 } 70 }
25 }; 71 };
26 72