diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6ee7c99..dacda6a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,8 +16,9 @@ option(BUILD_EXAMPLE_APP "Build Iris example console application" OFF)
option(EXPORT_IRIS "Export and install library" ON)
option(BUILD_SHARED_LIBS "Build iris as a shared library" OFF)
option(BUILD_COVERAGE "Builds code coverage target" OFF)
+option(PROFILER "Enable profiling" OFF)
-if (NOT UNIX)
+if (BUILD_COVERAGE AND NOT UNIX)
set(BUILD_COVERAGE OFF)
message("Code coverage can only be built in Linux systems")
endif()
@@ -32,6 +33,7 @@ set(PUBLIC_HEADERS
"include/iris/Log.h"
"include/iris/Result.h"
"include/iris/TotalFlashIncidents.h"
+ "include/iris/ScopeProfiler.h"
)
source_group("Public header files" FILES ${PUBLIC_HEADERS})
@@ -44,14 +46,12 @@ set(SOURCE_FILES
"src/RedSaturation.h"
"src/RedSaturation.cpp"
"src/CDLuminance.cpp"
- "src/TransitionEvaluator.cpp"
"src/Configuration.cpp"
"src/ConfigurationParams.h"
"src/Flash.h"
"src/RelativeLuminance.h"
"src/CDLuminance.h"
- "src/FrameRgbConverter.h"
- "src/TransitionEvaluator.h"
+ "src/FrameRgbConverter.h"
"src/FrameData.h"
"src/FlashDetection.h"
"src/FlashDetection.cpp"
@@ -60,12 +60,19 @@ set(SOURCE_FILES
"src/PatternDetection.h"
"src/PatternDetection.cpp"
"src/PhotosensitivityDetector.h"
+ "src/TransitionTracker.h"
+ "src/TransitionTrackerByFPS.h"
+ "src/TransitionTrackerByTime.h"
+ "src/TransitionTrackerByFPS.cpp"
+ "src/TransitionTrackerByTime.cpp"
+ "src/ScopeProfiler.cpp"
)
source_group("Source files" FILES ${SOURCE_FILES})
# Dependencies
find_package(OpenCV CONFIG REQUIRED)
+find_package(FFMPEG REQUIRED)
add_subdirectory ("utils")
if(BUILD_SHARED_LIBS)
@@ -115,6 +122,7 @@ target_link_libraries(${PROJECT_NAME}
PUBLIC
utils
${OpenCV_LIBS}
+ ${FFMPEG_LIBRARIES}
)
# ---------------------------------------------------------------------------------------
@@ -136,6 +144,14 @@ if(BUILD_TESTS)
add_subdirectory("test/AddressSanitizer.Tests")
endif()
+# ---------------------------------------------------------------------------------------
+# Profiler
+# ---------------------------------------------------------------------------------------
+if(PROFILER)
+ message("Profiler enabled")
+ target_compile_definitions(${PROJECT_NAME} PUBLIC -DPROFILING)
+endif()
+
# ---------------------------------------------------------------------------------------
# Install
# ---------------------------------------------------------------------------------------
@@ -192,4 +208,4 @@ export(EXPORT "${PROJECT_NAME}Targets"
NAMESPACE ${namespace}::
)
-endif()
\ No newline at end of file
+endif()
diff --git a/config/appsettings.json b/config/appsettings.json
index ea4cee6..af3ccac 100644
--- a/config/appsettings.json
+++ b/config/appsettings.json
@@ -287,11 +287,12 @@
"MaxDataStored": 10 //max stored frame data in memory until persistence
},
- "TransitionEvaluator": {
+ "TransitionTracker": {
"MaxTransitions": 6, //max allowed transitions and max transitions to count for extended fail
"MinTransitions": 4, //amount of min transitions to add to extended fail count
"ExtendedFailSeconds": 4, //max seconds until the start of extended failure
- "ExtendedFailWindow": 5 //seconds in extended fail count window
+ "ExtendedFailWindow": 5, //seconds in extended fail count window
+ "AnalyseByTime": false
},
"FlashDetection": {
@@ -559,7 +560,9 @@
"VideoAnalyser": {
"LuminanceType": "RELATIVE", //CD || RELATIVE
- "PatternDetectionEnabled": false
+ "PatternDetectionEnabled": false,
+ "FrameResizeEnabled": false,
+ "ResizeFrameProportion": 0.2
},
"Logging": {
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index 81f5eb9..2caf50f 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -20,12 +20,18 @@ target_include_directories(${PROJECT_NAME} PUBLIC
# Copy needed dll files into executable when building iris as dll
if(BUILD_SHARED_LIBS)
message("Copy dynamic libraries into IrisApp directory")
- file(GLOB_RECURSE DLL_FILES ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/*.dll)
- file(COPY ${DLL_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
- set(IRIS_DLL iris.dll)
if (CMAKE_BUILD_TYPE STREQUAL "Debug") # set DEBUG_POSTFIX
set(IRIS_DLL irisd.dll)
+ set(UTILS_DLL utilsd.dll)
+ file(GLOB_RECURSE DLL_DEBUG_FILES ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/debug/bin/*.dll)
+ file(COPY ${DLL_DEBUG_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+
+ else()
+ file(GLOB_RECURSE DLL_FILES ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/bin/*.dll)
+ file(COPY ${DLL_FILES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+ set(IRIS_DLL iris.dll)
+ set(UTILS_DLL utils.dll)
endif()
add_custom_command(TARGET ${PROJECT_NAME}
@@ -33,6 +39,12 @@ if(BUILD_SHARED_LIBS)
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/${IRIS_DLL}
${CMAKE_CURRENT_BINARY_DIR}
- COMMENT "Copying Iris DLL to build directory"
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_BINARY_DIR}/utils/${UTILS_DLL}
+ ${CMAKE_CURRENT_BINARY_DIR}
+
+ COMMENT "Copying Iris and utils DLL to build directory"
)
+
+
endif()
diff --git a/example/appsettings.json b/example/appsettings.json
index d54f77a..2e3c3ef 100644
--- a/example/appsettings.json
+++ b/example/appsettings.json
@@ -286,11 +286,12 @@
"MaxDataStored": 10 //max stored frame data in memory until persistence
},
- "TransitionEvaluator": {
+ "TransitionTracker": {
"MaxTransitions": 6, //max allowed transitions and max transitions to count for extended fail
"MinTransitions": 4, //amount of min transitions to add to extended fail count
"ExtendedFailSeconds": 4, //max seconds until the start of extended failure
- "ExtendedFailWindow": 5 //seconds in extended fail count window
+ "ExtendedFailWindow": 5, //seconds in extended fail count window
+ "AnalyseByTime": false
},
"FlashDetection": {
@@ -558,7 +559,9 @@
"VideoAnalyser": {
"LuminanceType": "RELATIVE", //CD || RELATIVE
- "PatternDetectionEnabled": false
+ "PatternDetectionEnabled": false,
+ "FrameResizeEnabled": false,
+ "ResizeFrameProportion": 0.2
},
"Logging": {
diff --git a/example/main.cpp b/example/main.cpp
index 76cab56..4e14335 100644
--- a/example/main.cpp
+++ b/example/main.cpp
@@ -116,6 +116,18 @@ int main(int argc, char* argv[])
configuration.SetPatternDetectionStatus(false);
}
}
+ if (cmdOptionExists(argv, argv + argc, "-r"))
+ {
+ std::string resize = getCmdOption(argv, argv + argc, "-r");
+ if (resize == "true" || resize == "1")
+ {
+ configuration.SetFrameResizeEnabled(true);
+ }
+ else if (resize == "false" || resize == "0")
+ {
+ configuration.SetFrameResizeEnabled(false);
+ }
+ }
if (cmdOptionExists(argv, argv + argc, "-a"))
{
@@ -126,7 +138,6 @@ int main(int argc, char* argv[])
//Run video analysis
CreateResultsDir(configuration);
-
if (sourceVideo != nullptr) //Run specific video
{
iris::VideoAnalyser vA(&configuration);
diff --git a/include/iris/Configuration.h b/include/iris/Configuration.h
index b553f68..26c662d 100644
--- a/include/iris/Configuration.h
+++ b/include/iris/Configuration.h
@@ -11,7 +11,7 @@ namespace EA::EACC::Utils
namespace iris
{
struct FlashParams;
- struct TransitionEvaluatorParams;
+ struct TransitionTrackerParams;
struct PatternDetectionParams;
struct PatternAnalyserParams;
struct StraightLineDetectorParams;
@@ -42,11 +42,17 @@ namespace iris
inline FlashParams* GetRedSaturationFlashParams() { return m_redSaturationFlashParams; }
inline EA::EACC::Utils::FrameConverterParams* GetFrameSrgbConverterParams() { return m_frameSrgbConverterParams; }
inline EA::EACC::Utils::FrameConverterParams* GetFrameCDLuminanceConverterParams() { return m_frameCDLuminanceConverterParams; }
- inline TransitionEvaluatorParams* GetTransitionEvaluatorParams() { return m_transitionEvaluatorParams; }
+ inline TransitionTrackerParams* GetTransitionTrackerParams() { return m_transitionTrackerParams; }
inline PatternDetectionParams* GetPatternDetectionParams() { return m_patternDetectionParams; }
inline bool PatternDetectionEnabled() { return m_patternDetectionEnabled; }
inline void SetPatternDetectionStatus(bool status) { m_patternDetectionEnabled = status; }
+
+ inline bool FrameResizeEnabled() { return m_frameResizeEnabled; }
+ inline void SetFrameResizeEnabled(bool status) { m_frameResizeEnabled = status; }
+
+ inline float GetFrameResizeProportion() { return m_frameResizeProportion; }
+ inline void SetFrameResizeProportion(float proportion) { m_frameResizeProportion = proportion; }
void SetSafeArea(float areaProportion);
@@ -58,11 +64,15 @@ namespace iris
FlashParams* m_redSaturationFlashParams = nullptr;
EA::EACC::Utils::FrameConverterParams* m_frameSrgbConverterParams = nullptr;
EA::EACC::Utils::FrameConverterParams* m_frameCDLuminanceConverterParams = nullptr;
- TransitionEvaluatorParams* m_transitionEvaluatorParams = nullptr;
+ TransitionTrackerParams* m_transitionTrackerParams = nullptr;
PatternDetectionParams* m_patternDetectionParams = nullptr;
LuminanceType m_luminanceType = LuminanceType::UN_SET;
bool m_patternDetectionEnabled = true;
+ bool m_frameResizeEnabled = true;
+
+ float m_frameResizeProportion = 1;
+
std::string m_resultsPath;
};
-}
\ No newline at end of file
+}
diff --git a/include/iris/FrameData.h b/include/iris/FrameData.h
index 5043641..20ce321 100644
--- a/include/iris/FrameData.h
+++ b/include/iris/FrameData.h
@@ -26,7 +26,7 @@ namespace iris
public:
FrameData() {};
- FrameData(int frame, long timeMs) : Frame(frame)
+ FrameData(unsigned int frame, unsigned long timeMs) : Frame(frame)
{
TimeStampMs = msToTimeSpan(timeMs);
};
@@ -108,7 +108,7 @@ namespace iris
///
/// Frame index
///
- int Frame = 0;
+ unsigned int Frame = 0;
///
/// frame timestamp in milliseconds
@@ -123,10 +123,10 @@ namespace iris
float AverageRedDiff = 0;
float AverageRedDiffAcc = 0;
float PatternRisk = 0;
- int LuminanceTransitions = 0;
- int RedTransitions = 0;
- int LuminanceExtendedFailCount = 0;
- int RedExtendedFailCount = 0;
+ unsigned int LuminanceTransitions = 0;
+ unsigned int RedTransitions = 0;
+ unsigned int LuminanceExtendedFailCount = 0;
+ unsigned int RedExtendedFailCount = 0;
FlashResult luminanceFrameResult = FlashResult::Pass;
FlashResult redFrameResult = FlashResult::Pass;
std::string patternArea = "0.00%";
@@ -161,7 +161,7 @@ namespace iris
struct FrameDataJson
{
- void reserve(const int& size)
+ void reserve(const unsigned int& size)
{
frame.reserve(size);
timeStampMs.reserve(size);
@@ -190,7 +190,7 @@ namespace iris
}
- void reserveLineGraphData(const int& size)
+ void reserveLineGraphData(const unsigned int& size)
{
timeStampMs.reserve(size);
luminanceTransitions.reserve(size);
@@ -238,25 +238,25 @@ namespace iris
patternFrameResult.push_back((int)data.patternFrameResult);
}
- std::vector frame;
+ std::vector frame;
std::vector timeStampMs;
std::vector luminanceFlashArea;
std::vector luminanceAverage;
std::vector averageLuminanceDiff;
std::vector averageLuminanceDiffAcc;
- std::vector redFlashArea;
+ std::vector < std::string> redFlashArea;
std::vector redAverage;
std::vector averageRedDiff;
std::vector averageRedDiffAcc;
- std::vector luminanceTransitions;
- std::vector redTransitions;
- std::vector luminanceExtendedFailCount;
- std::vector redExtendedFailCount;
- std::vector luminanceFrameResult;
- std::vector redFrameResult;
+ std::vector luminanceTransitions;
+ std::vector redTransitions;
+ std::vector luminanceExtendedFailCount;
+ std::vector redExtendedFailCount;
+ std::vector luminanceFrameResult;
+ std::vector redFrameResult;
std::vector patternArea;
std::vector patternDetectedLines;
- std::vector patternFrameResult;
+ std::vector patternFrameResult;
};
//Serializes FrameData to Json object
diff --git a/include/iris/Result.h b/include/iris/Result.h
index ebf7226..5f064cd 100644
--- a/include/iris/Result.h
+++ b/include/iris/Result.h
@@ -45,15 +45,15 @@ namespace iris
struct Result
{
- int VideoLen = 0;
- int AnalysisTime = 0;
- int TotalFrame = 0;
- int patternFailFrames = 0;
+ float VideoLen = 0;
+ unsigned int AnalysisTime = 0;
+ unsigned int TotalFrame = 0;
AnalysisResult OverallResult = AnalysisResult::Pass;
std::vector Results;
//total amount of frames that were counted that belonged to each incident type
TotalFlashIncidents totalLuminanceIncidents;
TotalFlashIncidents totalRedIncidents;
+ unsigned int patternFailFrames = 0;
};
diff --git a/include/iris/ScopeProfiler.h b/include/iris/ScopeProfiler.h
new file mode 100644
index 0000000..1069156
--- /dev/null
+++ b/include/iris/ScopeProfiler.h
@@ -0,0 +1,102 @@
+#pragma once
+
+#include
+#include
+#include
+#include