Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
MPAI-Private
MPAI-CAE
arp
Video Analyzer
Commits
97f6b447
Commit
97f6b447
authored
Jun 08, 2023
by
Matteo
Browse files
update unit tests
parent
c3b747c0
Changes
6
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
97f6b447
...
...
@@ -5,15 +5,15 @@ SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
"
)
SET
(
CMAKE_CXX_STANDARD 20
)
#
include(FetchContent)
#
FetchContent_Declare(
#
googletest
#
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
#
)
include
(
FetchContent
)
FetchContent_Declare
(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
#
# For Windows: Prevent overriding the parent project's compiler/linker settings
#
SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
#
FetchContent_MakeAvailable(googletest)
# For Windows: Prevent overriding the parent project's compiler/linker settings
SET
(
gtest_force_shared_crt ON CACHE BOOL
""
FORCE
)
FetchContent_MakeAvailable
(
googletest
)
LINK_DIRECTORIES
(
/usr/local/lib
)
...
...
@@ -63,22 +63,23 @@ TARGET_LINK_LIBRARIES(video_analyser
analyser_lib
)
#
enable_testing()
enable_testing
()
# ADD_EXECUTABLE(
# test_suite
# tests/irregularity_test.cpp
# tests/enums_test.cpp
# )
ADD_EXECUTABLE
(
test_suite
tests/irregularity_test.cpp
tests/enums_test.cpp
tests/core_test.cpp
)
#
TARGET_LINK_LIBRARIES(
#
test_suite
#
GTest::gtest_main
#
analyser_lib
#
${OpenCV_LIBRARIES}
#
${Boost_PROGRAM_OPTIONS_LIBRARY}
#
nlohmann_json::nlohmann_json
#
)
TARGET_LINK_LIBRARIES
(
test_suite
GTest::gtest_main
analyser_lib
${
OpenCV_LIBRARIES
}
${
Boost_PROGRAM_OPTIONS_LIBRARY
}
nlohmann_json::nlohmann_json
)
#
include(GoogleTest)
#
gtest_discover_tests(test_suite)
include
(
GoogleTest
)
gtest_discover_tests
(
test_suite
)
Makefile
View file @
97f6b447
...
...
@@ -21,7 +21,7 @@ build:
cmake
--build
build
test
:
cd
build
&&
ctest
./bin/test_suite
clean
:
rm
-rf
build
...
...
tests/core_test.cpp
0 → 100644
View file @
97f6b447
#include
"../src/lib/core.hpp"
#include
<gtest/gtest.h>
#include
<filesystem>
#include
<opencv2/core/core.hpp>
using
namespace
videoanalyser
;
using
namespace
cv
;
TEST
(
Core
,
Frame
)
{
core
::
Frame
f
=
core
::
Frame
(
cv
::
imread
(
"tests/images/test_scene_01.jpg"
));
EXPECT_EQ
(
f
.
size
().
width
,
720
);
EXPECT_EQ
(
f
.
size
().
height
,
576
);
EXPECT_EQ
(
f
.
channels
(),
3
);
}
TEST
(
Core
,
FrameClone
)
{
core
::
Frame
f
=
core
::
Frame
(
cv
::
imread
(
"tests/images/test_scene_01.jpg"
));
core
::
Frame
f2
=
f
.
clone
();
EXPECT_EQ
(
f
.
size
().
width
,
f2
.
size
().
width
);
EXPECT_EQ
(
f
.
size
().
height
,
f2
.
size
().
height
);
}
TEST
(
Core
,
FrameDownsample
)
{
core
::
Frame
f
=
core
::
Frame
(
cv
::
imread
(
"tests/images/test_scene_01.jpg"
));
core
::
Frame
f2
=
f
.
clone
();
f2
.
downsample
(
2
);
EXPECT_EQ
(
f
.
size
().
width
/
2
,
f2
.
size
().
width
);
EXPECT_EQ
(
f
.
size
().
height
/
2
,
f2
.
size
().
height
);
}
TEST
(
Core
,
FrameConvertColor
)
{
core
::
Frame
f
=
core
::
Frame
(
cv
::
imread
(
"tests/images/test_scene_01.jpg"
));
core
::
Frame
f2
=
f
.
clone
();
f2
.
convert_color
(
cv
::
COLOR_BGR2GRAY
);
EXPECT_EQ
(
f
.
size
().
width
,
f2
.
size
().
width
);
EXPECT_EQ
(
f
.
size
().
height
,
f2
.
size
().
height
);
EXPECT_EQ
(
f2
.
channels
(),
1
);
}
TEST
(
Core
,
FrameCrop
)
{
core
::
Frame
f
=
core
::
Frame
(
cv
::
imread
(
"tests/images/test_scene_01.jpg"
));
core
::
Frame
f2
=
f
.
clone
();
f2
.
crop
(
cv
::
Size
(
100
,
100
),
cv
::
Point2f
(
100
,
100
));
EXPECT_EQ
(
f2
.
size
().
width
,
100
);
EXPECT_EQ
(
f2
.
size
().
height
,
100
);
}
TEST
(
Core
,
FrameWarp
)
{
core
::
Frame
f
=
core
::
Frame
(
cv
::
imread
(
"tests/images/test_scene_01.jpg"
));
core
::
Frame
f2
=
f
.
clone
();
cv
::
Mat
rotationMatrix
=
cv
::
getRotationMatrix2D
(
cv
::
Point2f
(
f
.
size
().
width
/
2
,
f
.
size
().
height
/
2
),
45
,
1
);
f2
.
warp
(
rotationMatrix
);
EXPECT_EQ
(
f2
.
size
().
width
,
f
.
size
().
width
);
EXPECT_EQ
(
f2
.
size
().
height
,
f
.
size
().
height
);
}
TEST
(
Core
,
FrameDeinterlace
)
{
core
::
Frame
f
=
core
::
Frame
(
cv
::
imread
(
"tests/images/test_scene_01.jpg"
));
std
::
pair
<
core
::
Frame
,
core
::
Frame
>
f2
=
f
.
deinterlace
();
EXPECT_EQ
(
f2
.
first
.
size
().
width
,
f2
.
second
.
size
().
width
);
EXPECT_EQ
(
f2
.
first
.
size
().
height
,
f2
.
second
.
size
().
height
);
EXPECT_EQ
(
f2
.
first
.
size
().
width
,
f
.
size
().
width
);
EXPECT_EQ
(
f2
.
first
.
size
().
height
,
f
.
size
().
height
/
2
);
}
tests/enums_test.cpp
View file @
97f6b447
#include
"../src/lib/enums.h"
#include
"../src/lib/enums.h
pp
"
#include
<gtest/gtest.h>
...
...
tests/images/test_scene_01.jpg
0 → 100644
View file @
97f6b447
133 KB
tests/irregularity_test.cpp
View file @
97f6b447
#include
"../src/lib/Irregularity.h"
#include
"../src/lib/Irregularity.h
pp
"
#include
<gtest/gtest.h>
...
...
@@ -6,15 +6,16 @@
#include
<boost/uuid/uuid_generators.hpp>
TEST
(
Irregularity
,
Init
)
{
Irregularity
irreg
=
Irregularity
(
Source
::
Video
,
"00:00:00.000"
,
IrregularityType
::
WOW_AND_FLUTTER
,
"https://example.com/image.png"
);
Irregularity
irreg
=
Irregularity
(
Source
::
Video
,
"00:00:00.000"
,
IrregularityType
::
WOW_AND_FLUTTER
)
.
set_image_URI
(
"https://example.com/image.png"
);
Irregularity
irreg2
=
Irregularity
(
Source
::
Video
,
"00:00:00.000"
,
IrregularityType
::
WOW_AND_FLUTTER
,
"https://example.com/image.png"
);
Irregularity
irreg2
=
Irregularity
(
Source
::
Video
,
"00:00:00.000"
,
IrregularityType
::
WOW_AND_FLUTTER
)
.
set_image_URI
(
"https://example.com/image.png"
);
EXPECT_NE
(
irreg
.
id
,
irreg2
.
id
);
EXPECT_EQ
(
irreg
.
source
,
irreg2
.
source
);
EXPECT_EQ
(
irreg
.
time_label
,
irreg2
.
time_label
);
EXPECT_EQ
(
irreg
.
type
,
irreg2
.
type
);
EXPECT_EQ
(
irreg
.
image_URI
,
irreg2
.
image_URI
);
EXPECT_NE
(
irreg
.
get_id
(),
irreg2
.
get_id
());
EXPECT_EQ
(
irreg
.
get_source
(),
irreg2
.
get_source
());
EXPECT_EQ
(
irreg
.
get_time_label
(),
irreg2
.
get_time_label
());
EXPECT_EQ
(
irreg
.
get_type
(),
irreg2
.
get_type
());
EXPECT_EQ
(
irreg
.
get_image_URI
(),
irreg2
.
get_image_URI
());
EXPECT_EQ
(
irreg
.
get_audio_URI
(),
irreg2
.
get_audio_URI
());
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment