Skip to content

Commit 3eaff7f

Browse files
committed
feat: add scale transformation and update CMake configuration
1 parent dc8d0c7 commit 3eaff7f

File tree

7 files changed

+45
-6
lines changed

7 files changed

+45
-6
lines changed

CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++20 -Wall -Wextra -Wno-deprecated
99

1010
set_property(GLOBAL PROPERTY CXX_STANDARD 20)
1111

12-
if (UNIX AND NOT APPLE AND NOT DEFINED CMAKE_CXX_COMPILER)
12+
if (UNIX AND NOT APPLE)
13+
message(STATUS "Setting C++ compiler to g++-13")
1314
set(CMAKE_CXX_COMPILER "g++-13")
1415
endif()
1516

@@ -36,7 +37,7 @@ if (NOT DEFINED ENV{Qt6_DIR})
3637
set(Qt6_DIR "/usr/include/qt6/6.8.2/gcc_64/lib/cmake/Qt6")
3738
endif()
3839

39-
if (CI_BUILD)
40+
if (CI_BUILD EQUAL 1)
4041
message(STATUS "CI_BUILD is defined")
4142
include(FetchContent)
4243
FetchContent_Declare(
@@ -55,7 +56,7 @@ endif()
5556
find_package(OpenCV REQUIRED)
5657
find_package(Python3 3.12 REQUIRED COMPONENTS Development Development.Module Development.Embed)
5758
find_package(Qt6 REQUIRED COMPONENTS Widgets Core Gui)
58-
if (NOT CI_BUILD)
59+
if (NOT CI_BUILD EQUAL 1)
5960
find_package(nlohmann_json CONFIG REQUIRED)
6061
set(argparse_DIR "${VCPKG_ROOT}/installed/${VCPKG_TARGET_TRIPLET}/share/argparse")
6162
find_package(argparse CONFIG REQUIRED)
@@ -86,6 +87,7 @@ set(SOURCES
8687
src/transformation/other/overlay.cpp
8788
src/transformation/other/repeat.cpp
8889
src/transformation/other/zoom.cpp
90+
src/transformation/other/scale.cpp
8991
)
9092

9193
add_executable(${PROJECT_NAME} ${SOURCES})

include/transformation/transformation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ namespace transformation
3030
// Other
3131
transformation(repeat);
3232
transformation(zoom);
33+
transformation(scale);
3334

3435
/***
3536
TODO: transformation(concat);
@@ -46,5 +47,6 @@ namespace transformation
4647
// Other
4748
{"repeat", repeat},
4849
{"zoom", zoom},
50+
{"scale", scale},
4951
};
5052
}

src/transformation/other/scale.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
** EPITECH PROJECT, 2025
3+
** eip [WSL: Ubuntu]
4+
** File description:
5+
** scale
6+
*/
7+
8+
#include "transformation/transformation.hpp"
9+
10+
void transformation::scale(IterableInput input, const json::object_t &args)
11+
{
12+
const float startFactor = args.at("factor")[0];
13+
const float endFactor = args.at("factor")[1];
14+
15+
const float scaleIncr = (endFactor - startFactor) / (input._nbFrames - 1);
16+
float scaleAcc = startFactor - scaleIncr;
17+
18+
for (auto &[frame, _] : input) {
19+
scaleAcc += scaleIncr;
20+
cv::resize(frame, frame, cv::Size(), scaleAcc, scaleAcc);
21+
}
22+
}

video.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
t.add()
1010

1111
v = video("video/v.mp4").apply(translate(x, y + 175))
12-
v.apply(zoom(factor=(1, 3)), endTime=1)
13-
v.apply(zoom(factor=(3, 1)), startTime=1)
12+
v.apply(scale(factor=(1, 0.2)))
1413
v.add()
1514
v.keep()

videocode/transformation/_AllTransformation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
from videocode.transformation.other.Overlay import *
2222
from videocode.transformation.other.Repeat import *
2323
from videocode.transformation.other.Zoom import *
24+
from videocode.transformation.other.Scale import *
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env python3
2+
3+
from videocode.transformation.Transformation import Transformation
4+
5+
class scale(Transformation):
6+
"""
7+
`Scale` an `Input` keeping the pixels outside the dimension of the `Input` unlike `Zoom`.
8+
"""
9+
10+
def __init__(self, *, factor: float | int | tuple[float, float] = 2) -> None:
11+
if isinstance(factor, tuple):
12+
self.factor = factor
13+
else:
14+
self.factor = (factor, factor)

videocode/transformation/other/Zoom.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python3
22

3-
from typing import Generator, Iterator
43
from videocode.transformation.Transformation import Transformation
54

65
from videocode.Constant import *

0 commit comments

Comments
 (0)