Skip to content

Commit a0c05c4

Browse files
committed
Update
Fix issue with setting incorrect fps from video Add transition tracker by time Add frame resize for faster video processing Fix issue with pattern detection when having thin strips
1 parent 6adb17e commit a0c05c4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1658
-341
lines changed

CMakeLists.txt

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ option(BUILD_EXAMPLE_APP "Build Iris example console application" OFF)
1616
option(EXPORT_IRIS "Export and install library" ON)
1717
option(BUILD_SHARED_LIBS "Build iris as a shared library" OFF)
1818
option(BUILD_COVERAGE "Builds code coverage target" OFF)
19+
option(PROFILER "Enable profiling" OFF)
1920

20-
if (NOT UNIX)
21+
if (BUILD_COVERAGE AND NOT UNIX)
2122
set(BUILD_COVERAGE OFF)
2223
message("Code coverage can only be built in Linux systems")
2324
endif()
@@ -32,6 +33,7 @@ set(PUBLIC_HEADERS
3233
"include/iris/Log.h"
3334
"include/iris/Result.h"
3435
"include/iris/TotalFlashIncidents.h"
36+
"include/iris/ScopeProfiler.h"
3537
)
3638

3739
source_group("Public header files" FILES ${PUBLIC_HEADERS})
@@ -44,14 +46,12 @@ set(SOURCE_FILES
4446
"src/RedSaturation.h"
4547
"src/RedSaturation.cpp"
4648
"src/CDLuminance.cpp"
47-
"src/TransitionEvaluator.cpp"
4849
"src/Configuration.cpp"
4950
"src/ConfigurationParams.h"
5051
"src/Flash.h"
5152
"src/RelativeLuminance.h"
5253
"src/CDLuminance.h"
53-
"src/FrameRgbConverter.h"
54-
"src/TransitionEvaluator.h"
54+
"src/FrameRgbConverter.h"
5555
"src/FrameData.h"
5656
"src/FlashDetection.h"
5757
"src/FlashDetection.cpp"
@@ -60,12 +60,19 @@ set(SOURCE_FILES
6060
"src/PatternDetection.h"
6161
"src/PatternDetection.cpp"
6262
"src/PhotosensitivityDetector.h"
63+
"src/TransitionTracker.h"
64+
"src/TransitionTrackerByFPS.h"
65+
"src/TransitionTrackerByTime.h"
66+
"src/TransitionTrackerByFPS.cpp"
67+
"src/TransitionTrackerByTime.cpp"
68+
"src/ScopeProfiler.cpp"
6369
)
6470

6571
source_group("Source files" FILES ${SOURCE_FILES})
6672

6773
# Dependencies
6874
find_package(OpenCV CONFIG REQUIRED)
75+
find_package(FFMPEG REQUIRED)
6976
add_subdirectory ("utils")
7077

7178
if(BUILD_SHARED_LIBS)
@@ -115,6 +122,7 @@ target_link_libraries(${PROJECT_NAME}
115122
PUBLIC
116123
utils
117124
${OpenCV_LIBS}
125+
${FFMPEG_LIBRARIES}
118126
)
119127

120128
# ---------------------------------------------------------------------------------------
@@ -136,6 +144,14 @@ if(BUILD_TESTS)
136144
add_subdirectory("test/AddressSanitizer.Tests")
137145
endif()
138146

147+
# ---------------------------------------------------------------------------------------
148+
# Profiler
149+
# ---------------------------------------------------------------------------------------
150+
if(PROFILER)
151+
message("Profiler enabled")
152+
target_compile_definitions(${PROJECT_NAME} PUBLIC -DPROFILING)
153+
endif()
154+
139155
# ---------------------------------------------------------------------------------------
140156
# Install
141157
# ---------------------------------------------------------------------------------------
@@ -192,4 +208,4 @@ export(EXPORT "${PROJECT_NAME}Targets"
192208
NAMESPACE ${namespace}::
193209
)
194210

195-
endif()
211+
endif()

config/appsettings.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,12 @@
287287
"MaxDataStored": 10 //max stored frame data in memory until persistence
288288
},
289289

290-
"TransitionEvaluator": {
290+
"TransitionTracker": {
291291
"MaxTransitions": 6, //max allowed transitions and max transitions to count for extended fail
292292
"MinTransitions": 4, //amount of min transitions to add to extended fail count
293293
"ExtendedFailSeconds": 4, //max seconds until the start of extended failure
294-
"ExtendedFailWindow": 5 //seconds in extended fail count window
294+
"ExtendedFailWindow": 5, //seconds in extended fail count window
295+
"AnalyseByTime": false
295296
},
296297

297298
"FlashDetection": {
@@ -559,7 +560,9 @@
559560

560561
"VideoAnalyser": {
561562
"LuminanceType": "RELATIVE", //CD || RELATIVE
562-
"PatternDetectionEnabled": false
563+
"PatternDetectionEnabled": false,
564+
"FrameResizeEnabled": false,
565+
"ResizeFrameProportion": 0.2
563566
},
564567

565568
"Logging": {

example/CMakeLists.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,31 @@ target_include_directories(${PROJECT_NAME} PUBLIC
2020
# Copy needed dll files into executable when building iris as dll
2121
if(BUILD_SHARED_LIBS)
2222
message("Copy dynamic libraries into IrisApp directory")
23-
file(GLOB_RECURSE DLL_FILES ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/*.dll)
24-
file(COPY ${DLL_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
25-
set(IRIS_DLL iris.dll)
2623

2724
if (CMAKE_BUILD_TYPE STREQUAL "Debug") # set DEBUG_POSTFIX
2825
set(IRIS_DLL irisd.dll)
26+
set(UTILS_DLL utilsd.dll)
27+
file(GLOB_RECURSE DLL_DEBUG_FILES ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin/*.dll)
28+
file(COPY ${DLL_DEBUG_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
29+
30+
else()
31+
file(GLOB_RECURSE DLL_FILES ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/*.dll)
32+
file(COPY ${DLL_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
33+
set(IRIS_DLL iris.dll)
34+
set(UTILS_DLL utils.dll)
2935
endif()
3036

3137
add_custom_command(TARGET ${PROJECT_NAME}
3238
POST_BUILD
3339
COMMAND ${CMAKE_COMMAND} -E copy
3440
${CMAKE_BINARY_DIR}/${IRIS_DLL}
3541
${CMAKE_CURRENT_BINARY_DIR}
36-
COMMENT "Copying Iris DLL to build directory"
42+
COMMAND ${CMAKE_COMMAND} -E copy
43+
${CMAKE_BINARY_DIR}/utils/${UTILS_DLL}
44+
${CMAKE_CURRENT_BINARY_DIR}
45+
46+
COMMENT "Copying Iris and utils DLL to build directory"
3747
)
48+
49+
3850
endif()

example/appsettings.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,12 @@
286286
"MaxDataStored": 10 //max stored frame data in memory until persistence
287287
},
288288

289-
"TransitionEvaluator": {
289+
"TransitionTracker": {
290290
"MaxTransitions": 6, //max allowed transitions and max transitions to count for extended fail
291291
"MinTransitions": 4, //amount of min transitions to add to extended fail count
292292
"ExtendedFailSeconds": 4, //max seconds until the start of extended failure
293-
"ExtendedFailWindow": 5 //seconds in extended fail count window
293+
"ExtendedFailWindow": 5, //seconds in extended fail count window
294+
"AnalyseByTime": false
294295
},
295296

296297
"FlashDetection": {
@@ -558,7 +559,9 @@
558559

559560
"VideoAnalyser": {
560561
"LuminanceType": "RELATIVE", //CD || RELATIVE
561-
"PatternDetectionEnabled": false
562+
"PatternDetectionEnabled": false,
563+
"FrameResizeEnabled": false,
564+
"ResizeFrameProportion": 0.2
562565
},
563566

564567
"Logging": {

example/main.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,18 @@ int main(int argc, char* argv[])
116116
configuration.SetPatternDetectionStatus(false);
117117
}
118118
}
119+
if (cmdOptionExists(argv, argv + argc, "-r"))
120+
{
121+
std::string resize = getCmdOption(argv, argv + argc, "-r");
122+
if (resize == "true" || resize == "1")
123+
{
124+
configuration.SetFrameResizeEnabled(true);
125+
}
126+
else if (resize == "false" || resize == "0")
127+
{
128+
configuration.SetFrameResizeEnabled(false);
129+
}
130+
}
119131

120132
if (cmdOptionExists(argv, argv + argc, "-a"))
121133
{
@@ -126,7 +138,6 @@ int main(int argc, char* argv[])
126138
//Run video analysis
127139
CreateResultsDir(configuration);
128140

129-
130141
if (sourceVideo != nullptr) //Run specific video
131142
{
132143
iris::VideoAnalyser vA(&configuration);

include/iris/Configuration.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace EA::EACC::Utils
1111
namespace iris
1212
{
1313
struct FlashParams;
14-
struct TransitionEvaluatorParams;
14+
struct TransitionTrackerParams;
1515
struct PatternDetectionParams;
1616
struct PatternAnalyserParams;
1717
struct StraightLineDetectorParams;
@@ -42,11 +42,17 @@ namespace iris
4242
inline FlashParams* GetRedSaturationFlashParams() { return m_redSaturationFlashParams; }
4343
inline EA::EACC::Utils::FrameConverterParams* GetFrameSrgbConverterParams() { return m_frameSrgbConverterParams; }
4444
inline EA::EACC::Utils::FrameConverterParams* GetFrameCDLuminanceConverterParams() { return m_frameCDLuminanceConverterParams; }
45-
inline TransitionEvaluatorParams* GetTransitionEvaluatorParams() { return m_transitionEvaluatorParams; }
45+
inline TransitionTrackerParams* GetTransitionTrackerParams() { return m_transitionTrackerParams; }
4646
inline PatternDetectionParams* GetPatternDetectionParams() { return m_patternDetectionParams; }
4747

4848
inline bool PatternDetectionEnabled() { return m_patternDetectionEnabled; }
4949
inline void SetPatternDetectionStatus(bool status) { m_patternDetectionEnabled = status; }
50+
51+
inline bool FrameResizeEnabled() { return m_frameResizeEnabled; }
52+
inline void SetFrameResizeEnabled(bool status) { m_frameResizeEnabled = status; }
53+
54+
inline float GetFrameResizeProportion() { return m_frameResizeProportion; }
55+
inline void SetFrameResizeProportion(float proportion) { m_frameResizeProportion = proportion; }
5056

5157
void SetSafeArea(float areaProportion);
5258

@@ -58,11 +64,15 @@ namespace iris
5864
FlashParams* m_redSaturationFlashParams = nullptr;
5965
EA::EACC::Utils::FrameConverterParams* m_frameSrgbConverterParams = nullptr;
6066
EA::EACC::Utils::FrameConverterParams* m_frameCDLuminanceConverterParams = nullptr;
61-
TransitionEvaluatorParams* m_transitionEvaluatorParams = nullptr;
67+
TransitionTrackerParams* m_transitionTrackerParams = nullptr;
6268
PatternDetectionParams* m_patternDetectionParams = nullptr;
6369

6470
LuminanceType m_luminanceType = LuminanceType::UN_SET;
6571
bool m_patternDetectionEnabled = true;
72+
bool m_frameResizeEnabled = true;
73+
74+
float m_frameResizeProportion = 1;
75+
6676
std::string m_resultsPath;
6777
};
68-
}
78+
}

include/iris/FrameData.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace iris
2626
public:
2727

2828
FrameData() {};
29-
FrameData(int frame, long timeMs) : Frame(frame)
29+
FrameData(unsigned int frame, unsigned long timeMs) : Frame(frame)
3030
{
3131
TimeStampMs = msToTimeSpan(timeMs);
3232
};
@@ -108,7 +108,7 @@ namespace iris
108108
/// <summary>
109109
/// Frame index
110110
/// </summary>
111-
int Frame = 0;
111+
unsigned int Frame = 0;
112112

113113
/// <summary>
114114
/// frame timestamp in milliseconds
@@ -123,10 +123,10 @@ namespace iris
123123
float AverageRedDiff = 0;
124124
float AverageRedDiffAcc = 0;
125125
float PatternRisk = 0;
126-
int LuminanceTransitions = 0;
127-
int RedTransitions = 0;
128-
int LuminanceExtendedFailCount = 0;
129-
int RedExtendedFailCount = 0;
126+
unsigned int LuminanceTransitions = 0;
127+
unsigned int RedTransitions = 0;
128+
unsigned int LuminanceExtendedFailCount = 0;
129+
unsigned int RedExtendedFailCount = 0;
130130
FlashResult luminanceFrameResult = FlashResult::Pass;
131131
FlashResult redFrameResult = FlashResult::Pass;
132132
std::string patternArea = "0.00%";
@@ -161,7 +161,7 @@ namespace iris
161161

162162
struct FrameDataJson
163163
{
164-
void reserve(const int& size)
164+
void reserve(const unsigned int& size)
165165
{
166166
frame.reserve(size);
167167
timeStampMs.reserve(size);
@@ -190,7 +190,7 @@ namespace iris
190190

191191
}
192192

193-
void reserveLineGraphData(const int& size)
193+
void reserveLineGraphData(const unsigned int& size)
194194
{
195195
timeStampMs.reserve(size);
196196
luminanceTransitions.reserve(size);
@@ -238,25 +238,25 @@ namespace iris
238238
patternFrameResult.push_back((int)data.patternFrameResult);
239239
}
240240

241-
std::vector<int> frame;
241+
std::vector<unsigned int> frame;
242242
std::vector<std::string> timeStampMs;
243243
std::vector<std::string> luminanceFlashArea;
244244
std::vector<float> luminanceAverage;
245245
std::vector<float> averageLuminanceDiff;
246246
std::vector<float> averageLuminanceDiffAcc;
247-
std::vector <std::string> redFlashArea;
247+
std::vector < std::string> redFlashArea;
248248
std::vector<float> redAverage;
249249
std::vector<float> averageRedDiff;
250250
std::vector<float> averageRedDiffAcc;
251-
std::vector<int> luminanceTransitions;
252-
std::vector<int> redTransitions;
253-
std::vector<int> luminanceExtendedFailCount;
254-
std::vector<int> redExtendedFailCount;
255-
std::vector<short> luminanceFrameResult;
256-
std::vector<short> redFrameResult;
251+
std::vector<unsigned int> luminanceTransitions;
252+
std::vector<unsigned int> redTransitions;
253+
std::vector<unsigned int> luminanceExtendedFailCount;
254+
std::vector<unsigned int> redExtendedFailCount;
255+
std::vector<unsigned short> luminanceFrameResult;
256+
std::vector<unsigned short> redFrameResult;
257257
std::vector<std::string> patternArea;
258258
std::vector<int> patternDetectedLines;
259-
std::vector<short> patternFrameResult;
259+
std::vector<unsigned short> patternFrameResult;
260260
};
261261

262262
//Serializes FrameData to Json object

include/iris/Result.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@ namespace iris
4545

4646
struct Result
4747
{
48-
int VideoLen = 0;
49-
int AnalysisTime = 0;
50-
int TotalFrame = 0;
51-
int patternFailFrames = 0;
48+
float VideoLen = 0;
49+
unsigned int AnalysisTime = 0;
50+
unsigned int TotalFrame = 0;
5251
AnalysisResult OverallResult = AnalysisResult::Pass;
5352
std::vector<AnalysisResult> Results;
5453
//total amount of frames that were counted that belonged to each incident type
5554
TotalFlashIncidents totalLuminanceIncidents;
5655
TotalFlashIncidents totalRedIncidents;
56+
unsigned int patternFailFrames = 0;
5757
};
5858

5959

0 commit comments

Comments
 (0)