Skip to content

Commit 07775a4

Browse files
authored
Merge pull request #42 from anpawo/slice
feat: Slices
2 parents f104cfe + 99c6fbd commit 07775a4

File tree

31 files changed

+256
-161
lines changed

31 files changed

+256
-161
lines changed

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ LFLAGS = -O1 -Wl,-rpath-link,/usr/lib64
7272
SRC = $(SRC_MAIN) \
7373
$(SRC_VM) \
7474
$(SRC_INPUT) \
75-
$(SRC_TRANSFORM) \
75+
$(SRC_TSF) \
7676
$(SRC_COMPILER) \
7777

7878

@@ -87,12 +87,13 @@ SRC_VM = src/vm/VideoCode.cpp \
8787
SRC_COMPILER = src/compiler/generateVideo.cpp \
8888

8989

90-
SRC_INPUT = src/input/ABCInput.cpp \
91-
src/input/Image.cpp \
92-
src/input/Video.cpp \
90+
SRC_INPUT = src/input/concrete/ABCConcreteInput.cpp \
91+
src/input/concrete/media/Image.cpp \
92+
src/input/concrete/media/Video.cpp \
93+
src/input/composite/Slice.cpp \
9394

9495

95-
SRC_TRANSFORM = $(SRC_TSF_POS) \
96+
SRC_TSF = $(SRC_TSF_POS) \
9697
$(SRC_TSF_COLOR) \
9798
$(SRC_TSF_OTHER) \
9899

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ Below is an example of the last feature added (code) and the result (video).
77
from frontend.VideoCode import *
88

99

10-
v1 = video("video/v.mp4").apply(fade()).add()
10+
v1 = video("video/v.mp4")
11+
12+
v1[:20].apply(fadeIn())
13+
v1[-20:].apply(fadeOut())
14+
15+
v1.add()
1116
```
1217

1318
<img src="docs/readme/example.gif" style="width: 50%;">

docs/readme/02_code.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
from frontend.VideoCode import *
44

55

6-
v1 = video("video/v.mp4").apply(fade()).add()
6+
v1 = video("video/v.mp4")
7+
8+
v1[:20].apply(fadeIn())
9+
v1[-20:].apply(fadeOut())
10+
11+
v1.add()
712
```

docs/readme/example.gif

1.02 MB
Loading

frontend/Constant.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
DL = DOWN + LEFT
2525
DR = DOWN + RIGHT
2626

27-
2827
# index
2928
START = 0
3029
END = -1

frontend/input/Input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __getitem__(self, i: int | slice[int | None, int | None, None]) -> Slice:
9393
9494
"""
9595
if isinstance(i, int):
96-
s = slice(i, i)
96+
s = slice(i, i + 1) # stop is excluded
9797
else:
9898
s = slice(i.start or 0, i.stop or -1)
9999

frontend/transformation/color/Fade.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class fade(Transformation):
99
def __init__(self, sides: list[side] = ALL, startOpacity: uint = 0, endOpacity: uint = 255) -> None:
1010
"""
11-
`Fade` from `side`.
11+
`Fade` from `sides`.
1212
1313
Modify `opacity` for a `Fade in` or a `Fade out`.
1414
@@ -17,3 +17,22 @@ def __init__(self, sides: list[side] = ALL, startOpacity: uint = 0, endOpacity:
1717
self.sides = sides
1818
self.startOpacity = startOpacity
1919
self.endOpacity = endOpacity
20+
21+
22+
class fadeIn:
23+
def __new__(cls, sides: list[side] = ALL) -> fade:
24+
"""
25+
`Fade in` from `sides`.
26+
"""
27+
return fade(sides, startOpacity=0, endOpacity=255)
28+
29+
30+
class fadeOut:
31+
def __new__(cls, sides: list[side] = ALL) -> fade:
32+
"""
33+
`Fade out` from `sides`.
34+
"""
35+
return fade(sides, startOpacity=255, endOpacity=0)
36+
37+
38+
# fadeFromLeft etc...

include/input/IInput.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class IInput
2121
///< Deep copy of `_frames`
2222
virtual IInput* copy() = 0;
2323

24-
///< Get the frames
25-
virtual std::vector<cv::Mat>& getFrames() = 0;
24+
///< Iteration
25+
virtual std::vector<cv::Mat>::iterator begin() = 0;
26+
virtual std::vector<cv::Mat>::iterator end() = 0;
27+
28+
///< Size
29+
virtual size_t size() = 0;
2630
};

include/input/slice/Slice.hpp renamed to include/input/composite/ABCCompositeInput.hpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,13 @@
22
** EPITECH PROJECT, 2025
33
** video-code
44
** File description:
5-
** Slice
5+
** Input
66
*/
77

88
#pragma once
99

10-
class Slice
11-
{
12-
public:
13-
14-
Slice();
15-
~Slice();
10+
#include "input/IInput.hpp"
1611

17-
protected:
18-
private:
12+
class ABCCompositeInput : public IInput
13+
{
1914
};

include/input/composite/Group.hpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
** EPITECH PROJECT, 2025
3+
** video-code
4+
** File description:
5+
** Slice
6+
*/
7+
8+
#pragma once
9+
10+
class Slice
11+
{
12+
public:
13+
14+
Slice() = default;
15+
virtual ~Slice() = 0;
16+
17+
///< Deep copy of `this`
18+
IInput* copy() = 0;
19+
20+
///< Iteration
21+
virtual std::vector<cv::Mat>::iterator begin() = 0;
22+
virtual std::vector<cv::Mat>::iterator end() = 0;
23+
24+
///< Size
25+
virtual size_t size() = 0;
26+
27+
protected:
28+
private:
29+
};

0 commit comments

Comments
 (0)