Commit c391c7c9be8f53c127fb6ba5c5da210c586e4cf2
1 parent
c2b1835e
Add DropFrames transform to skip frames in a video
Showing
1 changed file
with
41 additions
and
0 deletions
openbr/plugins/frames.cpp
| @@ -48,6 +48,47 @@ private: | @@ -48,6 +48,47 @@ private: | ||
| 48 | 48 | ||
| 49 | BR_REGISTER(Transform, AggregateFrames) | 49 | BR_REGISTER(Transform, AggregateFrames) |
| 50 | 50 | ||
| 51 | +/*! | ||
| 52 | + * \ingroup transforms | ||
| 53 | + * \brief Only use one frame every n frames. | ||
| 54 | + * \author Austin Blanton \cite imaus10 | ||
| 55 | + * | ||
| 56 | + * For a video with m frames, DropFrames will pass on m/n frames. | ||
| 57 | + */ | ||
| 58 | +class DropFrames : public TimeVaryingTransform | ||
| 59 | +{ | ||
| 60 | + Q_OBJECT | ||
| 61 | + Q_PROPERTY(int n READ get_n WRITE set_n RESET reset_n STORED false) | ||
| 62 | + BR_PROPERTY(int, n, 1) | ||
| 63 | + | ||
| 64 | +public: | ||
| 65 | + DropFrames() : TimeVaryingTransform(false) {} | ||
| 66 | + | ||
| 67 | +private: | ||
| 68 | + void train(const TemplateList &data) | ||
| 69 | + { | ||
| 70 | + (void) data; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + void projectUpdate(const Template &src, Template &dst) | ||
| 74 | + { | ||
| 75 | + if (src.file.get<int>("FrameNumber") % n != 0) return; | ||
| 76 | + dst = src; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + void store(QDataStream &stream) const | ||
| 80 | + { | ||
| 81 | + (void) stream; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + void load(QDataStream &stream) | ||
| 85 | + { | ||
| 86 | + (void) stream; | ||
| 87 | + } | ||
| 88 | +}; | ||
| 89 | + | ||
| 90 | +BR_REGISTER(Transform, DropFrames) | ||
| 91 | + | ||
| 51 | } // namespace br | 92 | } // namespace br |
| 52 | 93 | ||
| 53 | #include "frames.moc" | 94 | #include "frames.moc" |