Skip to content

Commit cb89fcd

Browse files
committed
feat(text), rework(stack), feat(keeping)
Text Input, display string on the video. Only one stack instead of Input/Transformation. Can keep last frame of an Input if asked to.
1 parent f2878bc commit cb89fcd

File tree

28 files changed

+208
-113
lines changed

28 files changed

+208
-113
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ x = 700
1919
y = 10
2020

2121
# text: Video-Code
22-
t = text("Video-Code", 3).apply(translate(x, y), repeat(40))
23-
t[:20].apply(fadeIn())
22+
t = text("Video-Code", 3).apply(translate(x, y), repeat(24 * 4))
23+
t[: 24 * 3].apply(fadeIn(LEFT))
2424
t.add()
2525
t.keep()
2626

2727
# text: Made by
28-
t = text("made by", 3).apply(translate(x, y + 80), repeat(40))
29-
t[:20].apply(fadeIn())
28+
t = text("made by", 3).apply(translate(x, y + 80), repeat(24 * 4))
29+
t[: 24 * 3].apply(fadeIn(LEFT))
3030
t.add()
3131
t.keep()
3232

docs/readme/02_code.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ x = 700
66
y = 10
77

88
# text: Video-Code
9-
t = text("Video-Code", 3).apply(translate(x, y), repeat(40))
10-
t[:20].apply(fadeIn())
9+
t = text("Video-Code", 3).apply(translate(x, y), repeat(24 * 4))
10+
t[: 24 * 3].apply(fadeIn(LEFT))
1111
t.add()
1212
t.keep()
1313

1414
# text: Made by
15-
t = text("made by", 3).apply(translate(x, y + 80), repeat(40))
16-
t[:20].apply(fadeIn())
15+
t = text("made by", 3).apply(translate(x, y + 80), repeat(24 * 4))
16+
t[: 24 * 3].apply(fadeIn(LEFT))
1717
t.add()
1818
t.keep()
1919

docs/readme/example.gif

131 KB
Loading

include/input/IInput.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class IInput
2424
///< Iteration
2525
virtual std::vector<Frame>::iterator begin() = 0;
2626
virtual std::vector<Frame>::iterator end() = 0;
27+
virtual Frame& back() = 0;
2728

2829
///< Repeat
2930
virtual void repeat(size_t n) = 0;

include/input/composite/Slice.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Slice final : public ABCCompositeInput
2424
///< Iteration
2525
std::vector<Frame>::iterator begin();
2626
std::vector<Frame>::iterator end();
27+
Frame& back();
2728

2829
///< Repeat
2930
void repeat(size_t n);

include/input/concrete/ABCConcreteInput.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ABCConcreteInput : public IInput
2626
///< Iteration
2727
std::vector<Frame>::iterator begin() final;
2828
std::vector<Frame>::iterator end() final;
29+
Frame& back() final;
2930

3031
///< Repeat
3132
void repeat(size_t n) final;

include/input/concrete/text/Text.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ class Text final : public ABCConcreteInput
1818

1919
Text(const std::string &text, double fontSize, int fontThickness, const std::vector<int> &color, int font = cv::FONT_HERSHEY_SIMPLEX);
2020
~Text() = default;
21+
22+
private:
23+
24+
const std::string _text;
2125
};

include/vm/Register.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,20 @@ class Register
2929
Register() = default;
3030
~Register() = default;
3131

32-
///< Update instructions
33-
void updateInstructions(json::array_t &&newInstructions);
34-
35-
///< Run the first instruction not done
36-
void runNextInstruction();
32+
///< Create a new `Input`
33+
void newInput(const std::string &type, const json::object_t &args);
3734

3835
///< Access _inputs at `index`
3936
std::shared_ptr<IInput> operator[](size_t index);
4037

38+
///< Remove old `Inputs`
39+
void clear();
40+
4141
private:
4242

4343
///< Variables representing the Inputs currently used in the program
4444
std::vector<std::shared_ptr<IInput>> _inputs{};
4545

46-
///< Instructions to create new Inputs: [[instructionName, {instructionArgs}]]
47-
json::array_t _instructions{};
48-
4946
///< Each instruction
5047
const std::map<std::string, std::function<void(const json::object_t &)>> _inputFactory{
5148
{"Image", [this](const json::object_t &args) { _inputs.push_back(std::make_shared<Image>(args.at("filepath"))); }},

include/vm/VideoCode.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class VideoCode
5151
void removeLabel(const std::string &index);
5252

5353
///< Add a frame to the timeline
54-
void addFrame(const cv::Mat &mat, const Metadata &meta);
54+
void addFrame(const Frame &frame);
5555
void addFrames(const std::shared_ptr<IInput> input);
5656

5757
///< Events >///
@@ -111,7 +111,7 @@ class VideoCode
111111
// clang-format on
112112

113113
///< Timeline paused
114-
bool _paused{true};
114+
bool _paused{false};
115115

116116
///< Timeline running
117117
bool _running{true};
@@ -120,11 +120,14 @@ class VideoCode
120120
Register _register{};
121121

122122
///< Stack containing the transformations to apply to the Inputs
123-
json::array_t _actionStack{};
123+
json::array_t _stack{};
124124

125125
///< Window to modify the video in real time
126126
std::unique_ptr<AppWindow> _app{nullptr};
127127

128128
///< Output File for the generation
129129
std::string _outputFile;
130+
131+
///< Kept Entities (Prevent them from disappearing)
132+
std::vector<int> _keptInputs;
130133
};

src/input/composite/Slice.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "input/composite/Slice.hpp"
99

10+
#include <iterator>
1011
#include <memory>
1112

1213
#include "input/IInput.hpp"
@@ -38,6 +39,12 @@ std::vector<Frame>::iterator Slice::end()
3839
return _endIt;
3940
}
4041

42+
Frame& Slice::back()
43+
{
44+
///< TODO: not sure
45+
return *std::prev(_endIt);
46+
}
47+
4148
void Slice::repeat([[maybe_unused]] size_t n)
4249
{
4350
/// TODO: maybe add std::vector<Frame&> instead of iterators so we can duplicate the ref

0 commit comments

Comments
 (0)