Skip to content

Commit de2a7d6

Browse files
committed
feat: text
New Input: Text. Takes a string, a color, a size, a thickness. Generate some text in the video. Missing custom font.
1 parent 45149d5 commit de2a7d6

File tree

23 files changed

+217
-34
lines changed

23 files changed

+217
-34
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ SRC_COMPILER = src/compiler/generateVideo.cpp \
9090
SRC_INPUT = src/input/concrete/ABCConcreteInput.cpp \
9191
src/input/concrete/media/Image.cpp \
9292
src/input/concrete/media/Video.cpp \
93+
src/input/concrete/text/Text.cpp \
9394
src/input/composite/Slice.cpp \
9495

9596

@@ -106,6 +107,7 @@ SRC_TSF_COLOR = src/transformation/color/fade.cpp \
106107

107108

108109
SRC_TSF_OTHER = src/transformation/other/overlay.cpp \
110+
src/transformation/other/repeat.cpp \
109111

110112

111113
OBJ = $(SRC:.cpp=.o)

README.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,26 @@ Below is an example of the last feature added (code) and the result (video).
1515
```py
1616
from videocode.VideoCode import *
1717

18-
19-
v1 = video("video/v.mp4")
20-
21-
22-
v1[0:40].apply(move(200, 0))
23-
v1[0:20].apply(fadeIn()).add()
24-
v1[20:40].apply(fadeOut()).add()
18+
x = 700
19+
y = 100
20+
21+
# text: Video-Code
22+
t = text("Video-Code", 3).apply(translate(x, y), repeat(40))
23+
t[:20].apply(fadeIn())
24+
t[20:].apply(fadeOut())
25+
t.add()
26+
27+
# text: Made by:
28+
t = text("made by", 3).apply(translate(x, y), repeat(40))
29+
t[:20].apply(fadeIn())
30+
t[20:].apply(fadeOut())
31+
t.add()
32+
33+
34+
# Me
35+
v = video("video/v.mp4").apply(translate(x, y + 100))
36+
v[0:20].apply(fadeIn()).add()
37+
v[20:40].apply(fadeOut()).add()
2538
```
2639

2740
<img src="docs/readme/example.gif" style="width: 50%;">
@@ -31,25 +44,26 @@ To create a video with Video-Code, you need to write some simple code in Python.
3144

3245
The flow of the Video comes from the __Inputs__ that you, first import or create, then modify with __Transformations__ and finally add to the __timeline__.
3346

34-
To import or create an __Input__, you need to create a __video__ or __image__ instance (soon text and shapes).<br>
47+
To import or create an __Input__, you need to create a __video__, __image__ or a __text__ instance (soon shapes).<br>
3548
To modify it, you need to use __Transformations__ like __translate__ or __fade__.<br>
3649
To add the frames of the __Input__ to the timeline, use the __\<Input\>.add()__ function.
3750

3851
## Patch Notes
3952

4053

41-
<details open>
54+
<details>
4255
<summary><code>Inputs</code></summary>
4356
<br>
4457

4558
- `image`
4659
- `video`
60+
- `text`
4761

4862
</details>
4963

5064
<br>
5165

52-
<details open>
66+
<details>
5367
<summary><code>Transformations</code></summary>
5468
<br>
5569

@@ -63,15 +77,18 @@ To add the frames of the __Input__ to the timeline, use the __\<Input\>.add()__
6377
<br>
6478

6579
- `overlay`
80+
- `repeat`
6681

6782
</details>
6883

6984
<br>
7085

71-
<details open>
86+
<details>
7287
<summary><code>Patchs</code></summary>
7388
<br>
7489

90+
- `transformation`: repeat (03/03/25)
91+
- `input`: text (03/03/25)
7592
- `rework`: position of the frames (02/03/25)
7693
- `transformation`: move (02/03/25)
7794

docs/readme/02_code.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,24 @@
22
```py
33
from videocode.VideoCode import *
44

5+
x = 700
6+
y = 100
57

6-
v1 = video("video/v.mp4")
8+
# text: Video-Code
9+
t = text("Video-Code", 3).apply(translate(x, y), repeat(40))
10+
t[:20].apply(fadeIn())
11+
t[20:].apply(fadeOut())
12+
t.add()
713

14+
# text: Made by:
15+
t = text("made by", 3).apply(translate(x, y), repeat(40))
16+
t[:20].apply(fadeIn())
17+
t[20:].apply(fadeOut())
18+
t.add()
819

9-
v1[0:40].apply(move(200, 0))
10-
v1[0:20].apply(fadeIn()).add()
11-
v1[20:40].apply(fadeOut()).add()
20+
21+
# Me
22+
v = video("video/v.mp4").apply(translate(x, y + 100))
23+
v[0:20].apply(fadeIn()).add()
24+
v[20:40].apply(fadeOut()).add()
1225
```

docs/readme/04_getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ To create a video with Video-Code, you need to write some simple code in Python.
33

44
The flow of the Video comes from the __Inputs__ that you, first import or create, then modify with __Transformations__ and finally add to the __timeline__.
55

6-
To import or create an __Input__, you need to create a __video__ or __image__ instance (soon text and shapes).<br>
6+
To import or create an __Input__, you need to create a __video__, __image__ or a __text__ instance (soon shapes).<br>
77
To modify it, you need to use __Transformations__ like __translate__ or __fade__.<br>
88
To add the frames of the __Input__ to the timeline, use the __\<Input\>.add()__ function.

docs/readme/05_patch_notes.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
## Patch Notes
22

33

4-
<details open>
4+
<details>
55
<summary><code>Inputs</code></summary>
66
<br>
77

88
- `image`
99
- `video`
10+
- `text`
1011

1112
</details>
1213

1314
<br>
1415

15-
<details open>
16+
<details>
1617
<summary><code>Transformations</code></summary>
1718
<br>
1819

@@ -26,15 +27,18 @@
2627
<br>
2728

2829
- `overlay`
30+
- `repeat`
2931

3032
</details>
3133

3234
<br>
3335

34-
<details open>
36+
<details>
3537
<summary><code>Patchs</code></summary>
3638
<br>
3739

40+
- `transformation`: repeat (03/03/25)
41+
- `input`: text (03/03/25)
3842
- `rework`: position of the frames (02/03/25)
3943
- `transformation`: move (02/03/25)
4044

docs/readme/example.gif

-123 KB
Loading

include/input/IInput.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class IInput
2525
virtual std::vector<Frame>::iterator begin() = 0;
2626
virtual std::vector<Frame>::iterator end() = 0;
2727

28+
///< Repeat
29+
virtual void repeat(size_t n) = 0;
30+
2831
///< Size
2932
virtual size_t size() = 0;
3033
};

include/input/composite/Slice.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ class Slice final : public ABCCompositeInput
2222
IInput* copy();
2323

2424
///< Iteration
25-
virtual std::vector<Frame>::iterator begin();
26-
virtual std::vector<Frame>::iterator end();
25+
std::vector<Frame>::iterator begin();
26+
std::vector<Frame>::iterator end();
27+
28+
///< Repeat
29+
void repeat(size_t n);
2730

2831
///< Size
29-
virtual size_t size();
32+
size_t size();
3033

3134
private:
3235

include/input/concrete/ABCConcreteInput.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ class ABCConcreteInput : public IInput
2727
std::vector<Frame>::iterator begin() final;
2828
std::vector<Frame>::iterator end() final;
2929

30+
///< Repeat
31+
void repeat(size_t n) final;
32+
3033
///< Size
3134
size_t size() final;
3235

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
** EPITECH PROJECT, 2025
3+
** video-code
4+
** File description:
5+
** Text
6+
*/
7+
8+
#pragma once
9+
10+
#include <string>
11+
12+
#include "input/concrete/ABCConcreteInput.hpp"
13+
#include "opencv2/imgproc.hpp"
14+
15+
class Text final : public ABCConcreteInput
16+
{
17+
public:
18+
19+
Text(const std::string &text, double fontSize, int fontThickness, const std::vector<int> &color, int font = cv::FONT_HERSHEY_SIMPLEX);
20+
~Text() = default;
21+
};

0 commit comments

Comments
 (0)