Commit 4bf6568291a7bb6d382d42a0becd03db8839b94f

Authored by Scott Klum
2 parents a166fe5d 29e81b41

Merge branch 'master' of https://github.com/biometrics/openbr

Showing 1 changed file with 44 additions and 0 deletions
openbr/plugins/frames.cpp
@@ -29,6 +29,9 @@ private: @@ -29,6 +29,9 @@ private:
29 29
30 void projectUpdate(const Template &src, Template &dst) 30 void projectUpdate(const Template &src, Template &dst)
31 { 31 {
  32 + // DropFrames will pass on empty Templates
  33 + // but we only want to use non-dropped frames
  34 + if (src.empty()) return;
32 buffer.append(src); 35 buffer.append(src);
33 if (buffer.size() < n) return; 36 if (buffer.size() < n) return;
34 foreach (const Template &t, buffer) dst.append(t); 37 foreach (const Template &t, buffer) dst.append(t);
@@ -48,6 +51,47 @@ private: @@ -48,6 +51,47 @@ private:
48 51
49 BR_REGISTER(Transform, AggregateFrames) 52 BR_REGISTER(Transform, AggregateFrames)
50 53
  54 +/*!
  55 + * \ingroup transforms
  56 + * \brief Only use one frame every n frames.
  57 + * \author Austin Blanton \cite imaus10
  58 + *
  59 + * For a video with m frames, DropFrames will pass on m/n frames.
  60 + */
  61 +class DropFrames : public TimeVaryingTransform
  62 +{
  63 + Q_OBJECT
  64 + Q_PROPERTY(int n READ get_n WRITE set_n RESET reset_n STORED false)
  65 + BR_PROPERTY(int, n, 1)
  66 +
  67 +public:
  68 + DropFrames() : TimeVaryingTransform(false) {}
  69 +
  70 +private:
  71 + void train(const TemplateList &data)
  72 + {
  73 + (void) data;
  74 + }
  75 +
  76 + void projectUpdate(const Template &src, Template &dst)
  77 + {
  78 + if (src.file.get<int>("FrameNumber") % n != 0) return;
  79 + dst = src;
  80 + }
  81 +
  82 + void store(QDataStream &stream) const
  83 + {
  84 + (void) stream;
  85 + }
  86 +
  87 + void load(QDataStream &stream)
  88 + {
  89 + (void) stream;
  90 + }
  91 +};
  92 +
  93 +BR_REGISTER(Transform, DropFrames)
  94 +
51 } // namespace br 95 } // namespace br
52 96
53 #include "frames.moc" 97 #include "frames.moc"