diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index 254780e61..1fea19cab 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -51,7 +51,8 @@ jobs: echo "C:\Program Files\OpenCppCoverage" >> $env:GITHUB_PATH - name: Configure CMake - run: cmake -B ${{ env.build }} + run: cmake -DCMAKE_BUILD_TYPE=Debug -B ${{ env.build }} + # Build is not required for MSVC Code Analysis and will be used for Codecov - name: Build CMake diff --git a/wolf/CMakeLists.txt b/wolf/CMakeLists.txt index d5687b795..6bb8e83eb 100644 --- a/wolf/CMakeLists.txt +++ b/wolf/CMakeLists.txt @@ -94,7 +94,7 @@ option(WOLF_SYSTEM_STACKTRACE "Enable boost stacktrace" OFF) option(WOLF_SYSTEM_POSTGRESQL "Enable postgresql database client" OFF) # machine learing modules -option(WOLF_ML_OCR "Enable machine learning referee ocr" OFF) +option(WOLF_ML_OCR "Enable machine learning referee ocr" ON) option(WOLF_ML_NUDITY_DETECTION "Enable machine learning nudity detection" OFF) #option(WOLF_ENABLE_LTO "Enable cross language linking time optimization" OFF) @@ -302,7 +302,13 @@ if (WOLF_TEST) add_executable(${TEST_PROJECT_NAME} tests.cpp ) - target_link_libraries(${TEST_PROJECT_NAME} PRIVATE ${PROJECT_NAME}) + + if(WOLF_ML_OCR AND LINUX) + target_link_libraries(${TEST_PROJECT_NAME} PRIVATE ${PROJECT_NAME} ${leptonica_BINARY_DIR}/install/lib/libleptonica.so) + else() + target_link_libraries(${TEST_PROJECT_NAME} PRIVATE ${PROJECT_NAME}) + endif() + if (NOT WIN32) target_compile_options(${TEST_PROJECT_NAME} PRIVATE -std=c++2b) endif() diff --git a/wolf/cmake/ml.cmake b/wolf/cmake/ml.cmake index eb31d9196..d4d590b2b 100644 --- a/wolf/cmake/ml.cmake +++ b/wolf/cmake/ml.cmake @@ -69,7 +69,7 @@ if(WOLF_ML_OCR) tesseract ) - add_custom_command(OUTPUT tess_config.out COMMAND cmake -B ${tesseract_BINARY_DIR} -DBUILD_TESTS=OFF -DBUILD_TRAINING_TOOLS=OFF -DDISABLE_ARCHIVE=ON -DDISABLE_CURL=ON -DFAST_FLOAT=ON -DGRAPHICS_DISABLED=ON -DINSTALL_CONFIGS=OFF -DLeptonica_DIR=${leptonica_BINARY_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${tesseract_BINARY_DIR}/install ${tesseract_SOURCE_DIR} ) + add_custom_command(OUTPUT tess_config.out COMMAND cmake -B ${tesseract_BINARY_DIR} -DBUILD_SHARED_LIBS=1 -DBUILD_TESTS=OFF -DBUILD_TRAINING_TOOLS=OFF -DDISABLE_ARCHIVE=ON -DDISABLE_CURL=ON -DFAST_FLOAT=ON -DGRAPHICS_DISABLED=ON -DINSTALL_CONFIGS=OFF -DLeptonica_DIR=${leptonica_BINARY_DIR} -DCMAKE_INSTALL_PREFIX:PATH=${tesseract_BINARY_DIR}/install ${tesseract_SOURCE_DIR} ) add_custom_target(tess_config ALL DEPENDS tess_config.out) add_custom_command(OUTPUT tess_build.out COMMAND cmake --build ${tesseract_BINARY_DIR} --target install ) add_custom_target(tess_build ALL DEPENDS tess_build.out) diff --git a/wolf/ml/referee_ocr/w_utilities.cpp b/wolf/ml/referee_ocr/w_utilities.cpp index bd32c6e89..9933aecf9 100644 --- a/wolf/ml/referee_ocr/w_utilities.cpp +++ b/wolf/ml/referee_ocr/w_utilities.cpp @@ -261,7 +261,6 @@ auto store_image_in_folder( for (size_t i = 0; i < pVideoResult.size(); i++) { fs::path out_path = pOutputImageFolderPath + "/" + video_name + "_" + std::to_string(i) + ".png"; - std::cout << out_path.string() << std::endl; cv::imwrite(out_path.string().c_str(), pVideoResult[i].result_image); cv::waitKey(300); pVideoResult[i].release(); diff --git a/wolf/ml/test/common_test_asset/image_processor/find_all_contours_solid_black.png b/wolf/ml/test/common_test_asset/image_processor/find_all_contours_solid_black.png new file mode 100644 index 000000000..5f77ef3cc Binary files /dev/null and b/wolf/ml/test/common_test_asset/image_processor/find_all_contours_solid_black.png differ diff --git a/wolf/ml/test/common_test_asset/image_processor/gaussian_filter_7.png b/wolf/ml/test/common_test_asset/image_processor/gaussian_filter_7.png new file mode 100644 index 000000000..d9bd867c6 Binary files /dev/null and b/wolf/ml/test/common_test_asset/image_processor/gaussian_filter_7.png differ diff --git a/wolf/ml/test/common_test_asset/image_processor/gaussian_filter_default.png b/wolf/ml/test/common_test_asset/image_processor/gaussian_filter_default.png new file mode 100644 index 000000000..5bc2a690a Binary files /dev/null and b/wolf/ml/test/common_test_asset/image_processor/gaussian_filter_default.png differ diff --git a/wolf/ml/test/common_test_asset/image_processor/make_white_background_50.png b/wolf/ml/test/common_test_asset/image_processor/make_white_background_50.png new file mode 100644 index 000000000..46ab38573 Binary files /dev/null and b/wolf/ml/test/common_test_asset/image_processor/make_white_background_50.png differ diff --git a/wolf/ml/test/common_test_asset/image_processor/make_white_background_default.png b/wolf/ml/test/common_test_asset/image_processor/make_white_background_default.png new file mode 100644 index 000000000..a2816e612 Binary files /dev/null and b/wolf/ml/test/common_test_asset/image_processor/make_white_background_default.png differ diff --git a/wolf/ml/test/common_test_asset/image_processor/negative_image_default.png b/wolf/ml/test/common_test_asset/image_processor/negative_image_default.png new file mode 100644 index 000000000..5aa8237dc Binary files /dev/null and b/wolf/ml/test/common_test_asset/image_processor/negative_image_default.png differ diff --git a/wolf/ml/test/common_test_asset/image_processor/prepare_image_for_contour_detection_default.png b/wolf/ml/test/common_test_asset/image_processor/prepare_image_for_contour_detection_default.png new file mode 100644 index 000000000..0d122c9b9 Binary files /dev/null and b/wolf/ml/test/common_test_asset/image_processor/prepare_image_for_contour_detection_default.png differ diff --git a/wolf/ml/test/common_test_asset/image_processor/test_image.png b/wolf/ml/test/common_test_asset/image_processor/test_image.png new file mode 100644 index 000000000..52a862d4c Binary files /dev/null and b/wolf/ml/test/common_test_asset/image_processor/test_image.png differ diff --git a/wolf/ml/test/common_test_asset/image_processor/threshold_filter_180.png b/wolf/ml/test/common_test_asset/image_processor/threshold_filter_180.png new file mode 100644 index 000000000..a89aad411 Binary files /dev/null and b/wolf/ml/test/common_test_asset/image_processor/threshold_filter_180.png differ diff --git a/wolf/ml/test/common_test_asset/image_processor/threshold_filter_default.png b/wolf/ml/test/common_test_asset/image_processor/threshold_filter_default.png new file mode 100644 index 000000000..af9c2823d Binary files /dev/null and b/wolf/ml/test/common_test_asset/image_processor/threshold_filter_default.png differ diff --git a/wolf/ml/test/common_test_asset/ocr_engine/contours_to_char_structs_Solid_black.png b/wolf/ml/test/common_test_asset/ocr_engine/contours_to_char_structs_Solid_black.png new file mode 100644 index 000000000..5f77ef3cc Binary files /dev/null and b/wolf/ml/test/common_test_asset/ocr_engine/contours_to_char_structs_Solid_black.png differ diff --git a/wolf/ml/test/common_test_asset/ocr_engine/contours_to_char_structs_default.png b/wolf/ml/test/common_test_asset/ocr_engine/contours_to_char_structs_default.png new file mode 100644 index 000000000..0d122c9b9 Binary files /dev/null and b/wolf/ml/test/common_test_asset/ocr_engine/contours_to_char_structs_default.png differ diff --git a/wolf/ml/test/common_test_asset/ocr_engine/enhance_contour_image_for_model_make_white.png b/wolf/ml/test/common_test_asset/ocr_engine/enhance_contour_image_for_model_make_white.png new file mode 100644 index 000000000..a2816e612 Binary files /dev/null and b/wolf/ml/test/common_test_asset/ocr_engine/enhance_contour_image_for_model_make_white.png differ diff --git a/wolf/ml/test/common_test_asset/ocr_engine/enhance_contour_image_for_model_resize.png b/wolf/ml/test/common_test_asset/ocr_engine/enhance_contour_image_for_model_resize.png new file mode 100644 index 000000000..3d5533079 Binary files /dev/null and b/wolf/ml/test/common_test_asset/ocr_engine/enhance_contour_image_for_model_resize.png differ diff --git a/wolf/ml/test/common_test_asset/ocr_engine/filter_chars_by_contour_size copy 2.png b/wolf/ml/test/common_test_asset/ocr_engine/filter_chars_by_contour_size copy 2.png new file mode 100644 index 000000000..80ee8a982 Binary files /dev/null and b/wolf/ml/test/common_test_asset/ocr_engine/filter_chars_by_contour_size copy 2.png differ diff --git a/wolf/ml/test/common_test_asset/ocr_engine/filter_chars_by_contour_size copy.png b/wolf/ml/test/common_test_asset/ocr_engine/filter_chars_by_contour_size copy.png new file mode 100644 index 000000000..80ee8a982 Binary files /dev/null and b/wolf/ml/test/common_test_asset/ocr_engine/filter_chars_by_contour_size copy.png differ diff --git a/wolf/ml/test/common_test_asset/ocr_engine/filter_chars_by_contour_size.png b/wolf/ml/test/common_test_asset/ocr_engine/filter_chars_by_contour_size.png new file mode 100644 index 000000000..80ee8a982 Binary files /dev/null and b/wolf/ml/test/common_test_asset/ocr_engine/filter_chars_by_contour_size.png differ diff --git a/wolf/ml/test/common_test_asset/ocr_engine/mask_contour.png b/wolf/ml/test/common_test_asset/ocr_engine/mask_contour.png new file mode 100644 index 000000000..2f0b23a19 Binary files /dev/null and b/wolf/ml/test/common_test_asset/ocr_engine/mask_contour.png differ diff --git a/wolf/ml/test/common_test_asset/ocr_engine/test_image.png b/wolf/ml/test/common_test_asset/ocr_engine/test_image.png new file mode 100644 index 000000000..52a862d4c Binary files /dev/null and b/wolf/ml/test/common_test_asset/ocr_engine/test_image.png differ diff --git a/wolf/ml/test/common_test_asset/soccer/.fill_stat_map b/wolf/ml/test/common_test_asset/soccer/.fill_stat_map new file mode 100644 index 000000000..0f0c5aaef --- /dev/null +++ b/wolf/ml/test/common_test_asset/soccer/.fill_stat_map @@ -0,0 +1,109 @@ + +CONFIG_SIMILARITY_ALGORITHM=NormalizedLevenshtein +CONFIG_USE_SIMILARITY=True +SIMILAR_STRINGS_FILE_PATH=asset/team_names.txt +SIMILARITY_THRESHOLD=0.5 +SOCCER_GLOBAL_HEIGHT_TO_DIST_RATIO=0.4 +SOCCER_GLOBAL_PLATFORM_FREE=TRUE +SOCCER_NAME_AWAY_DO_RESIZE_CONTOUR=FALSE +SOCCER_NAME_AWAY_GAUSSIAN_BLUR_WIN_SIZE=5 +SOCCER_NAME_AWAY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_NAME_AWAY_IS_DIGIT=FALSE +SOCCER_NAME_AWAY_IS_TIME=FALSE +SOCCER_NAME_AWAY_IS_WHITE=TRUE +SOCCER_NAME_AWAY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_NAME_AWAY_MARGIN=5 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_AREA=1000 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_HEIGHT=100 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_WIDTH=100 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_AREA=1 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_WIDTH=1 +SOCCER_NAME_AWAY_THRESHOLD=150 +SOCCER_NAME_AWAY_VERBOSE=FALSE +SOCCER_NAME_AWAY_WHITE_BACKGROUND_THRESHOLD=30 +SOCCER_NAME_AWAY_WINDOW_NAME=name_away +SOCCER_NAME_AWAY_WINDOW=740,103,337,42 +SOCCER_NAME_HOME_DO_RESIZE_CONTOUR=TRUE +SOCCER_NAME_HOME_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_NAME_HOME_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_NAME_HOME_IS_DIGIT=FALSE +SOCCER_NAME_HOME_IS_TIME=FALSE +SOCCER_NAME_HOME_IS_WHITE=TRUE +SOCCER_NAME_HOME_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_NAME_HOME_MARGIN=5 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_AREA=500 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_HEIGHT=40 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_WIDTH=30 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_AREA=1 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_WIDTH=1 +SOCCER_NAME_HOME_THRESHOLD=150 +SOCCER_NAME_HOME_VERBOSE=False +SOCCER_NAME_HOME_WHITE_BACKGROUND_THRESHOLD=40 +SOCCER_NAME_HOME_WINDOW_NAME=name_home +SOCCER_NAME_HOME_WINDOW=200,103,337,42 +SOCCER_RESULT_AWAY_DO_RESIZE_CONTOUR=FALSE +SOCCER_RESULT_AWAY_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_RESULT_AWAY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_RESULT_AWAY_IS_DIGIT=TRUE +SOCCER_RESULT_AWAY_IS_TIME=TRUE +SOCCER_RESULT_AWAY_IS_WHITE=TRUE +SOCCER_RESULT_AWAY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_RESULT_AWAY_MARGIN=6 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_AREA=10000 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_HEIGHT=45 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_WIDTH=32 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_AREA=20 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_WIDTH=4 +SOCCER_RESULT_AWAY_THRESHOLD=110 +SOCCER_RESULT_AWAY_VERBOSE=FALSE +SOCCER_RESULT_AWAY_WHITE_BACKGROUND_THRESHOLD=150 +SOCCER_RESULT_AWAY_WINDOW_NAME=result_away +SOCCER_RESULT_AWAY_WINDOW=685,99,32,47 +SOCCER_RESULT_HOME_DO_RESIZE_CONTOUR=FALSE +SOCCER_RESULT_HOME_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_RESULT_HOME_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_RESULT_HOME_IS_DIGIT=TRUE +SOCCER_RESULT_HOME_IS_TIME=TRUE +SOCCER_RESULT_HOME_IS_WHITE=TRUE +SOCCER_RESULT_HOME_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_RESULT_HOME_MARGIN=6 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_AREA=1500 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_HEIGHT=45 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_WIDTH=32 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_AREA=20 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_WIDTH=4 +SOCCER_RESULT_HOME_THRESHOLD=110 +SOCCER_RESULT_HOME_VERBOSE=FALSE +SOCCER_RESULT_HOME_WHITE_BACKGROUND_THRESHOLD=150 +SOCCER_RESULT_HOME_WINDOW_NAME=game_result_home +SOCCER_RESULT_HOME_WINDOW=564,99,32,47 +SOCCER_SCREEN_IDENTITY_DO_RESIZE_CONTOUR=TRUE +SOCCER_SCREEN_IDENTITY_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_SCREEN_IDENTITY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_SCREEN_IDENTITY_IS_DIGIT=TRUE +SOCCER_SCREEN_IDENTITY_IS_TIME=FALSE +SOCCER_SCREEN_IDENTITY_IS_WHITE=TRUE +SOCCER_SCREEN_IDENTITY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_SCREEN_IDENTITY_MARGIN=5 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_AREA=105 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_HEIGHT=16 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_WIDTH=14 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_AREA=2 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_HEIGHT=8 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_WIDTH=2 +SOCCER_SCREEN_IDENTITY_THRESHOLD=150 +SOCCER_SCREEN_IDENTITY_VERBOSE=FALSE +SOCCER_SCREEN_IDENTITY_WHITE_BACKGROUND_THRESHOLD=30 +SOCCER_SCREEN_IDENTITY_WINDOW_NAME=screen_identity +SOCCER_SCREEN_IDENTITY_WINDOW=614,80,17,26 +SOCCER_STAT_EXTRA_FIRST_HALF_STRING=105 00 +SOCCER_STAT_EXTRA_SECOND_HALF_STRING=120 00 +SOCCER_STAT_FIRST_HALF_STRING=45 00 +SOCCER_STAT_PENALTY_STRING=penalty +SOCCER_STAT_SECOND_HALF_STRING=90 00 +TELEMETRY_USE=OFF +TESSERACT_LOG=tesseract.log diff --git a/wolf/ml/test/common_test_asset/soccer/.initial_match_result_struct b/wolf/ml/test/common_test_asset/soccer/.initial_match_result_struct new file mode 100644 index 000000000..ade28d6d9 --- /dev/null +++ b/wolf/ml/test/common_test_asset/soccer/.initial_match_result_struct @@ -0,0 +1,100 @@ +CONFIG_SIMILARITY_ALGORITHM=NormalizedLevenshtein +CONFIG_USE_SIMILARITY=True +SIMILARITY_THRESHOLD=0.5 +SOCCER_NAME_AWAY_DO_RESIZE_CONTOUR=FALSE +SOCCER_NAME_AWAY_GAUSSIAN_BLUR_WIN_SIZE=5 +SOCCER_NAME_AWAY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_NAME_AWAY_IS_DIGIT=FALSE +SOCCER_NAME_AWAY_IS_TIME=FALSE +SOCCER_NAME_AWAY_IS_WHITE=TRUE +SOCCER_NAME_AWAY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_NAME_AWAY_MARGIN=5 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_AREA=1000 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_HEIGHT=100 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_WIDTH=100 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_AREA=1 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_WIDTH=1 +SOCCER_NAME_AWAY_THRESHOLD=150 +SOCCER_NAME_AWAY_VERBOSE=FALSE +SOCCER_NAME_AWAY_WHITE_BACKGROUND_THRESHOLD=30 +SOCCER_NAME_AWAY_WINDOW_NAME=name_away +SOCCER_NAME_AWAY_WINDOW=740,103,337,42 +SOCCER_NAME_HOME_DO_RESIZE_CONTOUR=TRUE +SOCCER_NAME_HOME_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_NAME_HOME_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_NAME_HOME_IS_DIGIT=FALSE +SOCCER_NAME_HOME_IS_TIME=FALSE +SOCCER_NAME_HOME_IS_WHITE=TRUE +SOCCER_NAME_HOME_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_NAME_HOME_MARGIN=5 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_AREA=500 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_HEIGHT=40 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_WIDTH=30 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_AREA=1 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_WIDTH=1 +SOCCER_NAME_HOME_THRESHOLD=150 +SOCCER_NAME_HOME_VERBOSE=False +SOCCER_NAME_HOME_WHITE_BACKGROUND_THRESHOLD=40 +SOCCER_NAME_HOME_WINDOW_NAME=name_home +SOCCER_NAME_HOME_WINDOW=200,103,337,42 +SOCCER_RESULT_AWAY_DO_RESIZE_CONTOUR=FALSE +SOCCER_RESULT_AWAY_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_RESULT_AWAY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_RESULT_AWAY_IS_DIGIT=TRUE +SOCCER_RESULT_AWAY_IS_TIME=TRUE +SOCCER_RESULT_AWAY_IS_WHITE=TRUE +SOCCER_RESULT_AWAY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_RESULT_AWAY_MARGIN=6 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_AREA=10000 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_HEIGHT=45 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_WIDTH=32 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_AREA=20 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_WIDTH=4 +SOCCER_RESULT_AWAY_THRESHOLD=110 +SOCCER_RESULT_AWAY_VERBOSE=FALSE +SOCCER_RESULT_AWAY_WHITE_BACKGROUND_THRESHOLD=150 +SOCCER_RESULT_AWAY_WINDOW_NAME=result_away +SOCCER_RESULT_AWAY_WINDOW=685,99,32,47 +SOCCER_RESULT_HOME_DO_RESIZE_CONTOUR=FALSE +SOCCER_RESULT_HOME_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_RESULT_HOME_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_RESULT_HOME_IS_DIGIT=TRUE +SOCCER_RESULT_HOME_IS_TIME=TRUE +SOCCER_RESULT_HOME_IS_WHITE=TRUE +SOCCER_RESULT_HOME_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_RESULT_HOME_MARGIN=6 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_AREA=1500 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_HEIGHT=45 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_WIDTH=32 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_AREA=20 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_WIDTH=4 +SOCCER_RESULT_HOME_THRESHOLD=110 +SOCCER_RESULT_HOME_VERBOSE=FALSE +SOCCER_RESULT_HOME_WHITE_BACKGROUND_THRESHOLD=150 +SOCCER_RESULT_HOME_WINDOW_NAME=game_result_home +SOCCER_RESULT_HOME_WINDOW=564,99,32,47 +SOCCER_SCREEN_IDENTITY_DO_RESIZE_CONTOUR=TRUE +SOCCER_SCREEN_IDENTITY_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_SCREEN_IDENTITY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_SCREEN_IDENTITY_IS_DIGIT=TRUE +SOCCER_SCREEN_IDENTITY_IS_TIME=FALSE +SOCCER_SCREEN_IDENTITY_IS_WHITE=TRUE +SOCCER_SCREEN_IDENTITY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_SCREEN_IDENTITY_MARGIN=5 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_AREA=105 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_HEIGHT=16 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_WIDTH=14 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_AREA=2 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_HEIGHT=8 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_WIDTH=2 +SOCCER_SCREEN_IDENTITY_THRESHOLD=150 +SOCCER_SCREEN_IDENTITY_VERBOSE=FALSE +SOCCER_SCREEN_IDENTITY_WHITE_BACKGROUND_THRESHOLD=30 +SOCCER_SCREEN_IDENTITY_WINDOW_NAME=screen_identity +SOCCER_SCREEN_IDENTITY_WINDOW=614,80,17,26 +TELEMETRY_USE=OFF +TESSERACT_LOG=tesseract.log diff --git a/wolf/ml/test/common_test_asset/soccer/.replace_team_names_with_most_similar_string b/wolf/ml/test/common_test_asset/soccer/.replace_team_names_with_most_similar_string new file mode 100644 index 000000000..4b12582a2 --- /dev/null +++ b/wolf/ml/test/common_test_asset/soccer/.replace_team_names_with_most_similar_string @@ -0,0 +1,2 @@ +SIMILAR_STRINGS_FILE_PATH=../wolf/ml/test/common_test_asset/soccer/replace_team_names_with_most_similar_string.txt +SIMILARITY_THRESHOLD=0.5 diff --git a/wolf/ml/test/common_test_asset/soccer/.replace_team_names_with_most_similar_string_0_9 b/wolf/ml/test/common_test_asset/soccer/.replace_team_names_with_most_similar_string_0_9 new file mode 100644 index 000000000..308eb5f44 --- /dev/null +++ b/wolf/ml/test/common_test_asset/soccer/.replace_team_names_with_most_similar_string_0_9 @@ -0,0 +1,2 @@ +SIMILAR_STRINGS_FILE_PATH=../wolf/ml/test/common_test_asset/soccer/replace_team_names_with_most_similar_string.txt +SIMILARITY_THRESHOLD=0.9 diff --git a/wolf/ml/test/common_test_asset/soccer/.set_config b/wolf/ml/test/common_test_asset/soccer/.set_config new file mode 100644 index 000000000..d4abea73d --- /dev/null +++ b/wolf/ml/test/common_test_asset/soccer/.set_config @@ -0,0 +1,20 @@ +SOCCER_SCREEN_IDENTITY=COMMENT +SOCCER_SCREEN_IDENTITY_WINDOW_NAME=window_name_test +SOCCER_SCREEN_IDENTITY_IS_TIME=FALSE +SOCCER_SCREEN_IDENTITY_WINDOW=614,80,17,26 +SOCCER_SCREEN_IDENTITY_DO_RESIZE_CONTOUR=TRUE +SOCCER_SCREEN_IDENTITY_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_SCREEN_IDENTITY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_SCREEN_IDENTITY_IS_WHITE=TRUE +SOCCER_SCREEN_IDENTITY_IS_DIGIT=TRUE +SOCCER_SCREEN_IDENTITY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_SCREEN_IDENTITY_MARGIN=5 +SOCCER_SCREEN_IDENTITY_THRESHOLD=150 +SOCCER_SCREEN_IDENTITY_VERBOSE=FALSE +SOCCER_SCREEN_IDENTITY_WHITE_BACKGROUND_THRESHOLD=30 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_AREA=105 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_AREA=2 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_WIDTH=14 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_WIDTH=2 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_HEIGHT=16 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_HEIGHT=8 diff --git a/wolf/ml/test/common_test_asset/soccer/.single_image_result_extraction b/wolf/ml/test/common_test_asset/soccer/.single_image_result_extraction new file mode 100644 index 000000000..0e659dc13 --- /dev/null +++ b/wolf/ml/test/common_test_asset/soccer/.single_image_result_extraction @@ -0,0 +1,129 @@ + +CONFIG_SIMILARITY_ALGORITHM=NormalizedLevenshtein +CONFIG_USE_SIMILARITY=True +SIMILAR_STRINGS_FILE_PATH=asset/team_names.txt +SIMILARITY_THRESHOLD=0.5 +SIMILARITY_THRESHOLD_STAT=0.7 +SIMILARITY_USE_FOR_TEAM_NAMES=FALSE +SOCCER_GLOBAL_FRAME_HEIGHT=720 +SOCCER_GLOBAL_FRAME_WIDTH=1280 +SOCCER_GLOBAL_HEIGHT_TO_DIST_RATIO=0.4 +SOCCER_GLOBAL_MIN_FRAMES=4 +SOCCER_GLOBAL_PLATFORM_FREE=TRUE +SOCCER_GLOBAL_THRESHOLD=190 +SOCCER_NAME_AWAY_DO_RESIZE_CONTOUR=FALSE +SOCCER_NAME_AWAY_GAUSSIAN_BLUR_WIN_SIZE=5 +SOCCER_NAME_AWAY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_NAME_AWAY_IS_DIGIT=FALSE +SOCCER_NAME_AWAY_IS_TIME=FALSE +SOCCER_NAME_AWAY_IS_WHITE=TRUE +SOCCER_NAME_AWAY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_NAME_AWAY_MARGIN=5 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_AREA=1000 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_HEIGHT=100 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_WIDTH=100 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_AREA=1 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_WIDTH=1 +SOCCER_NAME_AWAY_THRESHOLD=150 +SOCCER_NAME_AWAY_VERBOSE=FALSE +SOCCER_NAME_AWAY_WHITE_BACKGROUND_THRESHOLD=30 +SOCCER_NAME_AWAY_WINDOW_NAME=name_away +SOCCER_NAME_AWAY_WINDOW=740,103,337,42 +SOCCER_NAME_HOME_DO_RESIZE_CONTOUR=TRUE +SOCCER_NAME_HOME_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_NAME_HOME_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_NAME_HOME_IS_DIGIT=FALSE +SOCCER_NAME_HOME_IS_TIME=FALSE +SOCCER_NAME_HOME_IS_WHITE=TRUE +SOCCER_NAME_HOME_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_NAME_HOME_MARGIN=5 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_AREA=500 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_HEIGHT=40 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_WIDTH=30 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_AREA=1 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_WIDTH=1 +SOCCER_NAME_HOME_THRESHOLD=150 +SOCCER_NAME_HOME_VERBOSE=False +SOCCER_NAME_HOME_WHITE_BACKGROUND_THRESHOLD=40 +SOCCER_NAME_HOME_WINDOW_NAME=name_home +SOCCER_NAME_HOME_WINDOW=200,103,337,42 +SOCCER_PENALTY_RESTRICTIONS_MAX_AREA=1400 +SOCCER_PENALTY_RESTRICTIONS_MAX_HEIGHT=50 +SOCCER_PENALTY_RESTRICTIONS_MAX_WIDTH=30 +SOCCER_PENALTY_RESTRICTIONS_MIN_AREA=10 +SOCCER_PENALTY_RESTRICTIONS_MIN_HEIGHT=10 +SOCCER_PENALTY_RESTRICTIONS_MIN_WIDTH=2 +SOCCER_PLATFORM_FREE_FRACTION=0.6 +SOCCER_PLATFORM_FREE_RESTRICTIONS_MAX_AREA=1000 +SOCCER_PLATFORM_FREE_RESTRICTIONS_MAX_HEIGHT=45 +SOCCER_PLATFORM_FREE_RESTRICTIONS_MAX_WIDTH=27 +SOCCER_PLATFORM_FREE_RESTRICTIONS_MIN_AREA=10 +SOCCER_PLATFORM_FREE_RESTRICTIONS_MIN_HEIGHT=14 +SOCCER_PLATFORM_FREE_RESTRICTIONS_MIN_WIDTH=2 +SOCCER_RESULT_AWAY_DO_RESIZE_CONTOUR=FALSE +SOCCER_RESULT_AWAY_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_RESULT_AWAY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_RESULT_AWAY_IS_DIGIT=TRUE +SOCCER_RESULT_AWAY_IS_TIME=TRUE +SOCCER_RESULT_AWAY_IS_WHITE=TRUE +SOCCER_RESULT_AWAY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_RESULT_AWAY_MARGIN=6 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_AREA=10000 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_HEIGHT=45 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_WIDTH=32 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_AREA=20 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_WIDTH=4 +SOCCER_RESULT_AWAY_THRESHOLD=110 +SOCCER_RESULT_AWAY_VERBOSE=FALSE +SOCCER_RESULT_AWAY_WHITE_BACKGROUND_THRESHOLD=150 +SOCCER_RESULT_AWAY_WINDOW_NAME=result_away +SOCCER_RESULT_AWAY_WINDOW=685,99,32,47 +SOCCER_RESULT_HOME_DO_RESIZE_CONTOUR=FALSE +SOCCER_RESULT_HOME_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_RESULT_HOME_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_RESULT_HOME_IS_DIGIT=TRUE +SOCCER_RESULT_HOME_IS_TIME=TRUE +SOCCER_RESULT_HOME_IS_WHITE=TRUE +SOCCER_RESULT_HOME_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_RESULT_HOME_MARGIN=6 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_AREA=1500 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_HEIGHT=45 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_WIDTH=32 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_AREA=20 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_WIDTH=4 +SOCCER_RESULT_HOME_THRESHOLD=110 +SOCCER_RESULT_HOME_VERBOSE=FALSE +SOCCER_RESULT_HOME_WHITE_BACKGROUND_THRESHOLD=150 +SOCCER_RESULT_HOME_WINDOW_NAME=game_result_home +SOCCER_RESULT_HOME_WINDOW=564,99,32,47 +SOCCER_SCREEN_IDENTITY_DO_RESIZE_CONTOUR=TRUE +SOCCER_SCREEN_IDENTITY_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_SCREEN_IDENTITY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_SCREEN_IDENTITY_IS_DIGIT=TRUE +SOCCER_SCREEN_IDENTITY_IS_TIME=FALSE +SOCCER_SCREEN_IDENTITY_IS_WHITE=TRUE +SOCCER_SCREEN_IDENTITY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_SCREEN_IDENTITY_MARGIN=5 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_AREA=105 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_HEIGHT=16 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_WIDTH=14 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_AREA=2 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_HEIGHT=8 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_WIDTH=2 +SOCCER_SCREEN_IDENTITY_THRESHOLD=150 +SOCCER_SCREEN_IDENTITY_VERBOSE=FALSE +SOCCER_SCREEN_IDENTITY_WHITE_BACKGROUND_THRESHOLD=30 +SOCCER_SCREEN_IDENTITY_WINDOW_NAME=screen_identity +SOCCER_SCREEN_IDENTITY_WINDOW=614,80,17,26 +SOCCER_STAT_CHECK_PENALTY=PEN +SOCCER_STAT_EXTRA_FIRST_HALF_STRING=105 00 +SOCCER_STAT_EXTRA_SECOND_HALF_STRING=120 00 +SOCCER_STAT_FIRST_HALF_STRING=45 00 +SOCCER_STAT_PENALTY_STRING=PEN +SOCCER_STAT_SECOND_HALF_STRING=90 00 +TELEMETRY_USE=OFF +TESSERACT_LOG=tesseract.log diff --git a/wolf/ml/test/common_test_asset/soccer/.update_match_data b/wolf/ml/test/common_test_asset/soccer/.update_match_data new file mode 100644 index 000000000..ade28d6d9 --- /dev/null +++ b/wolf/ml/test/common_test_asset/soccer/.update_match_data @@ -0,0 +1,100 @@ +CONFIG_SIMILARITY_ALGORITHM=NormalizedLevenshtein +CONFIG_USE_SIMILARITY=True +SIMILARITY_THRESHOLD=0.5 +SOCCER_NAME_AWAY_DO_RESIZE_CONTOUR=FALSE +SOCCER_NAME_AWAY_GAUSSIAN_BLUR_WIN_SIZE=5 +SOCCER_NAME_AWAY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_NAME_AWAY_IS_DIGIT=FALSE +SOCCER_NAME_AWAY_IS_TIME=FALSE +SOCCER_NAME_AWAY_IS_WHITE=TRUE +SOCCER_NAME_AWAY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_NAME_AWAY_MARGIN=5 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_AREA=1000 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_HEIGHT=100 +SOCCER_NAME_AWAY_RESTRICTIONS_MAX_WIDTH=100 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_AREA=1 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_NAME_AWAY_RESTRICTIONS_MIN_WIDTH=1 +SOCCER_NAME_AWAY_THRESHOLD=150 +SOCCER_NAME_AWAY_VERBOSE=FALSE +SOCCER_NAME_AWAY_WHITE_BACKGROUND_THRESHOLD=30 +SOCCER_NAME_AWAY_WINDOW_NAME=name_away +SOCCER_NAME_AWAY_WINDOW=740,103,337,42 +SOCCER_NAME_HOME_DO_RESIZE_CONTOUR=TRUE +SOCCER_NAME_HOME_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_NAME_HOME_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_NAME_HOME_IS_DIGIT=FALSE +SOCCER_NAME_HOME_IS_TIME=FALSE +SOCCER_NAME_HOME_IS_WHITE=TRUE +SOCCER_NAME_HOME_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_NAME_HOME_MARGIN=5 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_AREA=500 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_HEIGHT=40 +SOCCER_NAME_HOME_RESTRICTIONS_MAX_WIDTH=30 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_AREA=1 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_NAME_HOME_RESTRICTIONS_MIN_WIDTH=1 +SOCCER_NAME_HOME_THRESHOLD=150 +SOCCER_NAME_HOME_VERBOSE=False +SOCCER_NAME_HOME_WHITE_BACKGROUND_THRESHOLD=40 +SOCCER_NAME_HOME_WINDOW_NAME=name_home +SOCCER_NAME_HOME_WINDOW=200,103,337,42 +SOCCER_RESULT_AWAY_DO_RESIZE_CONTOUR=FALSE +SOCCER_RESULT_AWAY_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_RESULT_AWAY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_RESULT_AWAY_IS_DIGIT=TRUE +SOCCER_RESULT_AWAY_IS_TIME=TRUE +SOCCER_RESULT_AWAY_IS_WHITE=TRUE +SOCCER_RESULT_AWAY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_RESULT_AWAY_MARGIN=6 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_AREA=10000 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_HEIGHT=45 +SOCCER_RESULT_AWAY_RESTRICTIONS_MAX_WIDTH=32 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_AREA=20 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_RESULT_AWAY_RESTRICTIONS_MIN_WIDTH=4 +SOCCER_RESULT_AWAY_THRESHOLD=110 +SOCCER_RESULT_AWAY_VERBOSE=FALSE +SOCCER_RESULT_AWAY_WHITE_BACKGROUND_THRESHOLD=150 +SOCCER_RESULT_AWAY_WINDOW_NAME=result_away +SOCCER_RESULT_AWAY_WINDOW=685,99,32,47 +SOCCER_RESULT_HOME_DO_RESIZE_CONTOUR=FALSE +SOCCER_RESULT_HOME_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_RESULT_HOME_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_RESULT_HOME_IS_DIGIT=TRUE +SOCCER_RESULT_HOME_IS_TIME=TRUE +SOCCER_RESULT_HOME_IS_WHITE=TRUE +SOCCER_RESULT_HOME_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_RESULT_HOME_MARGIN=6 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_AREA=1500 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_HEIGHT=45 +SOCCER_RESULT_HOME_RESTRICTIONS_MAX_WIDTH=32 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_AREA=20 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_HEIGHT=20 +SOCCER_RESULT_HOME_RESTRICTIONS_MIN_WIDTH=4 +SOCCER_RESULT_HOME_THRESHOLD=110 +SOCCER_RESULT_HOME_VERBOSE=FALSE +SOCCER_RESULT_HOME_WHITE_BACKGROUND_THRESHOLD=150 +SOCCER_RESULT_HOME_WINDOW_NAME=game_result_home +SOCCER_RESULT_HOME_WINDOW=564,99,32,47 +SOCCER_SCREEN_IDENTITY_DO_RESIZE_CONTOUR=TRUE +SOCCER_SCREEN_IDENTITY_GAUSSIAN_BLUR_WIN_SIZE=3 +SOCCER_SCREEN_IDENTITY_IF_STORE_IMAGE_BOXES=FALSE +SOCCER_SCREEN_IDENTITY_IS_DIGIT=TRUE +SOCCER_SCREEN_IDENTITY_IS_TIME=FALSE +SOCCER_SCREEN_IDENTITY_IS_WHITE=TRUE +SOCCER_SCREEN_IDENTITY_MAKE_WHITE_BACKGROUND=FALSE +SOCCER_SCREEN_IDENTITY_MARGIN=5 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_AREA=105 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_HEIGHT=16 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MAX_WIDTH=14 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_AREA=2 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_HEIGHT=8 +SOCCER_SCREEN_IDENTITY_RESTRICTIONS_MIN_WIDTH=2 +SOCCER_SCREEN_IDENTITY_THRESHOLD=150 +SOCCER_SCREEN_IDENTITY_VERBOSE=FALSE +SOCCER_SCREEN_IDENTITY_WHITE_BACKGROUND_THRESHOLD=30 +SOCCER_SCREEN_IDENTITY_WINDOW_NAME=screen_identity +SOCCER_SCREEN_IDENTITY_WINDOW=614,80,17,26 +TELEMETRY_USE=OFF +TESSERACT_LOG=tesseract.log diff --git a/wolf/ml/test/common_test_asset/soccer/replace_team_names_with_most_similar_string.txt b/wolf/ml/test/common_test_asset/soccer/replace_team_names_with_most_similar_string.txt new file mode 100644 index 000000000..69e3c0da8 --- /dev/null +++ b/wolf/ml/test/common_test_asset/soccer/replace_team_names_with_most_similar_string.txt @@ -0,0 +1 @@ +REAL MADRID diff --git a/wolf/ml/test/common_test_asset/soccer/single_image_result_extraction.mp4 b/wolf/ml/test/common_test_asset/soccer/single_image_result_extraction.mp4 new file mode 100644 index 000000000..ed4805668 Binary files /dev/null and b/wolf/ml/test/common_test_asset/soccer/single_image_result_extraction.mp4 differ diff --git a/wolf/ml/test/common_test_asset/soccer/single_image_result_extraction.png b/wolf/ml/test/common_test_asset/soccer/single_image_result_extraction.png new file mode 100644 index 000000000..4b3d14eb0 Binary files /dev/null and b/wolf/ml/test/common_test_asset/soccer/single_image_result_extraction.png differ diff --git a/wolf/ml/test/common_test_asset/utilities/.get_env_boolean b/wolf/ml/test/common_test_asset/utilities/.get_env_boolean new file mode 100644 index 000000000..963c3bfc2 --- /dev/null +++ b/wolf/ml/test/common_test_asset/utilities/.get_env_boolean @@ -0,0 +1,3 @@ + +# Variables for testing get_env_boolean functions +BOOLEAN_VALUE=True diff --git a/wolf/ml/test/common_test_asset/utilities/.get_env_cv_rect b/wolf/ml/test/common_test_asset/utilities/.get_env_cv_rect new file mode 100644 index 000000000..bfe6ec357 --- /dev/null +++ b/wolf/ml/test/common_test_asset/utilities/.get_env_cv_rect @@ -0,0 +1,3 @@ + +# Variables for testing get_env_boolean functions +CV_RECT_VALUE=313,110,72,14 diff --git a/wolf/ml/test/common_test_asset/utilities/.get_env_float b/wolf/ml/test/common_test_asset/utilities/.get_env_float new file mode 100644 index 000000000..c398cc426 --- /dev/null +++ b/wolf/ml/test/common_test_asset/utilities/.get_env_float @@ -0,0 +1,3 @@ + +# Variables for testing get_env_float functions +FLOAT_VALUE=4.5 diff --git a/wolf/ml/test/common_test_asset/utilities/.get_env_int b/wolf/ml/test/common_test_asset/utilities/.get_env_int new file mode 100644 index 000000000..d742a068f --- /dev/null +++ b/wolf/ml/test/common_test_asset/utilities/.get_env_int @@ -0,0 +1,3 @@ + +# Variables for testing get_env_int functions +INT_VALUE=7 diff --git a/wolf/ml/test/common_test_asset/utilities/.get_env_string b/wolf/ml/test/common_test_asset/utilities/.get_env_string new file mode 100644 index 000000000..08ab60d17 --- /dev/null +++ b/wolf/ml/test/common_test_asset/utilities/.get_env_string @@ -0,0 +1,3 @@ + +# Variables for testing get_env_boolean functions +STRING_VALUE=this is a test! diff --git a/wolf/ml/test/common_test_asset/utilities/.get_nearest_string_0_5 b/wolf/ml/test/common_test_asset/utilities/.get_nearest_string_0_5 new file mode 100644 index 000000000..ce124cb31 --- /dev/null +++ b/wolf/ml/test/common_test_asset/utilities/.get_nearest_string_0_5 @@ -0,0 +1,2 @@ +SIMILAR_STRINGS_FILE_PATH=../wolf/ml/test/common_test_asset/utilities/get_nearest_string.txt +SIMILARITY_THRESHOLD=0.5 diff --git a/wolf/ml/test/common_test_asset/utilities/.get_nearest_string_0_9 b/wolf/ml/test/common_test_asset/utilities/.get_nearest_string_0_9 new file mode 100644 index 000000000..ac1030d5d --- /dev/null +++ b/wolf/ml/test/common_test_asset/utilities/.get_nearest_string_0_9 @@ -0,0 +1,2 @@ +SIMILAR_STRINGS_FILE_PATH=../wolf/ml/test/common_test_asset/utilities/get_nearest_string.txt +SIMILARITY_THRESHOLD=0.9 diff --git a/wolf/ml/test/common_test_asset/utilities/.set_env b/wolf/ml/test/common_test_asset/utilities/.set_env new file mode 100644 index 000000000..679c0f4cc --- /dev/null +++ b/wolf/ml/test/common_test_asset/utilities/.set_env @@ -0,0 +1,6 @@ +# This is a comment line +V1=v1 +V2=v2 +# Another comment line +V3=v3 +V4=v4 diff --git a/wolf/ml/test/common_test_asset/utilities/get_nearest_string.txt b/wolf/ml/test/common_test_asset/utilities/get_nearest_string.txt new file mode 100644 index 000000000..c343a0fc6 --- /dev/null +++ b/wolf/ml/test/common_test_asset/utilities/get_nearest_string.txt @@ -0,0 +1,2 @@ +test1 +hello diff --git a/wolf/ml/test/common_test_asset/utilities/get_value_from_json_file_by_key.json b/wolf/ml/test/common_test_asset/utilities/get_value_from_json_file_by_key.json new file mode 100644 index 000000000..0afae5cdb --- /dev/null +++ b/wolf/ml/test/common_test_asset/utilities/get_value_from_json_file_by_key.json @@ -0,0 +1,4 @@ +{ + "cpp-test-json": "ready", + "cpp-env-json": "OFF" +} diff --git a/wolf/ml/test/w_image_processor_test.cpp b/wolf/ml/test/w_image_processor_test.hpp similarity index 72% rename from wolf/ml/test/w_image_processor_test.cpp rename to wolf/ml/test/w_image_processor_test.hpp index d2f66e917..d003f77a0 100644 --- a/wolf/ml/test/w_image_processor_test.cpp +++ b/wolf/ml/test/w_image_processor_test.hpp @@ -1,15 +1,23 @@ -#include "w_image_processor.h" +#ifdef WOLF_TEST -#include +#pragma once + +#ifdef WOLF_ML_OCR + +#define BOOST_TEST_MODULE ml_image_processor + +#include + +#include #include #include namespace fs = std::filesystem; -fs::path image_processor_path = - "../../../ocr/common_test_asset/image_processor"; +fs::path image_processor_path = "../wolf/ml/test/common_test_asset/image_processor"; -TEST_CASE("prepare_image_for_contour_detection with default arguments", - "[w_image_processor_test.cpp]") { +using namespace wolf::ml::ocr; + +BOOST_AUTO_TEST_CASE(prepare_image_for_contour_detection_with_default_arguments) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); fs::path desired_image_path = @@ -21,22 +29,20 @@ TEST_CASE("prepare_image_for_contour_detection with default arguments", cv::Mat processed_image = prepare_image_for_contour_detection(source_image, config_for_ocr_struct); cv::Mat diff = processed_image != desired_image; - CHECK(cv::countNonZero(diff) == 0); + BOOST_TEST(cv::countNonZero(diff) == 0); } -TEST_CASE("negative_image with default arguments", - "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(negative_image_with_default_arguments) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); fs::path desired_image_path = image_processor_path / "negative_image_default.png"; cv::Mat desired_image = cv::imread(desired_image_path.string()); negative_image(source_image); - CHECK((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); + BOOST_TEST((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); } -TEST_CASE("make_white_background with default arguments", - "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(make_white_background_with_default_arguments) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); fs::path desired_image_temp = @@ -45,11 +51,10 @@ TEST_CASE("make_white_background with default arguments", config_for_ocr_struct config_for_ocr_struct; config_for_ocr_struct.make_white_background = true; make_contour_white_background(source_image, config_for_ocr_struct); - CHECK((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); + BOOST_TEST((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); } -TEST_CASE("make_white_background with threshold 50", - "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(make_white_background_with_threshold_50) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); fs::path desired_image_temp = @@ -59,11 +64,10 @@ TEST_CASE("make_white_background with threshold 50", config_for_ocr_struct.make_white_background = true; config_for_ocr_struct.white_background_threshold = 50; make_contour_white_background(source_image, config_for_ocr_struct); - CHECK((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); + BOOST_TEST((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); } -TEST_CASE("find_all_contours on image with contours", - "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(find_all_contours_on_image_with_contours) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); config_for_ocr_struct config_for_ocr_struct; @@ -71,11 +75,10 @@ TEST_CASE("find_all_contours on image with contours", prepare_image_for_contour_detection(source_image, config_for_ocr_struct); std::vector> contours = find_all_countors(filtered_image); - CHECK(contours.size() == 475); + BOOST_TEST(contours.size() == 475); } -TEST_CASE("find_all_contours on image without contours", - "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(find_all_contours_on_image_without_contours) { fs::path source_image_path = image_processor_path / "find_all_contours_solid_black.png"; cv::Mat source_image = cv::imread(source_image_path.string()); @@ -84,37 +87,34 @@ TEST_CASE("find_all_contours on image without contours", prepare_image_for_contour_detection(source_image, config_for_ocr_struct); std::vector> contours = find_all_countors(filtered_image); - CHECK(contours.size() == 0); + BOOST_TEST(contours.size() == 0); } -TEST_CASE("resize_function with only height argument", - "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(resize_function_with_only_height_argument) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); resize_image(source_image, 40); - CHECK(source_image.rows == 40); + BOOST_TEST(source_image.rows == 40); } -TEST_CASE("resize_function with only width argument", - "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(resize_function_with_only_width_argument) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); resize_image(source_image, -1, 60); - CHECK(source_image.cols == 60); + BOOST_TEST(source_image.cols == 60); } -TEST_CASE("resize_function without argument", "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(resize_function_without_argument) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); int cols = source_image.cols; int rows = source_image.rows; resize_image(source_image); - CHECK(source_image.cols == cols); - CHECK(source_image.rows == rows); + BOOST_TEST(source_image.cols == cols); + BOOST_TEST(source_image.rows == rows); } -TEST_CASE("gaussian_filter with default argument", - "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(gaussian_filter_with_default_argument) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); fs::path desired_image_path = @@ -122,10 +122,10 @@ TEST_CASE("gaussian_filter with default argument", cv::Mat desired_image = cv::imread(desired_image_path.string()); config_for_ocr_struct config_for_ocr_struct; gaussian_blur(source_image, config_for_ocr_struct); - CHECK((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); + BOOST_TEST((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); } -TEST_CASE("gaussian_filter with win size 7", "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(gaussian_filter_with_win_size_7) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); fs::path desired_image_path = image_processor_path / "gaussian_filter_7.png"; @@ -133,11 +133,10 @@ TEST_CASE("gaussian_filter with win size 7", "[w_image_processor_test.cpp]") { config_for_ocr_struct config_for_ocr_struct; config_for_ocr_struct.gaussian_blur_win_size = 7; gaussian_blur(source_image, config_for_ocr_struct); - CHECK((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); + BOOST_TEST((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); } -TEST_CASE("threshold_filter with default argument ", - "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(threshold_filter_with_default_argument) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); fs::path desired_image_path = @@ -148,11 +147,10 @@ TEST_CASE("threshold_filter with default argument ", config_for_ocr_struct config_for_ocr_struct; threshold_image(source_image, config_for_ocr_struct); cv::Mat diff = source_image != desired_image; - CHECK(cv::countNonZero(diff) == 0); + BOOST_TEST(cv::countNonZero(diff) == 0); } -TEST_CASE("threshold_filter with threshold value 180 ", - "[w_image_processor_test.cpp]") { +BOOST_AUTO_TEST_CASE(threshold_filter_with_threshold_value_180) { fs::path source_image_path = image_processor_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); fs::path desired_image_path = @@ -164,5 +162,9 @@ TEST_CASE("threshold_filter with threshold value 180 ", config_for_ocr_struct.threshold_value = 180; threshold_image(source_image, config_for_ocr_struct); cv::Mat diff = desired_image != desired_image; - CHECK(cv::countNonZero(diff) == 0); + BOOST_TEST(cv::countNonZero(diff) == 0); } + +#endif // WOLF_ML_OCR + +#endif // WOLF_TEST diff --git a/wolf/ml/test/w_ocr_engine_test.cpp b/wolf/ml/test/w_ocr_engine_test.hpp similarity index 67% rename from wolf/ml/test/w_ocr_engine_test.cpp rename to wolf/ml/test/w_ocr_engine_test.hpp index d723d0a34..b063f7675 100644 --- a/wolf/ml/test/w_ocr_engine_test.cpp +++ b/wolf/ml/test/w_ocr_engine_test.hpp @@ -1,54 +1,60 @@ -#include "w_ocr_engine.h" +#ifdef WOLF_TEST -#include +#pragma once + +#ifdef WOLF_ML_OCR + +#define BOOST_TEST_MODULE ml_ocr_engine + +#include + +#include #include #include -#include "w_image_processor.h" +#include + +using namespace wolf::ml::ocr; + namespace fs = std::filesystem; -OCR ocr_object; -fs::path ocr_engine_asset_path = "../../../ocr/common_test_asset/ocr_engine"; +w_ocr_engine ocr_object; +fs::path ocr_engine_asset_path = "../wolf/ml/test/common_test_asset/ocr_engine"; -TEST_CASE("check_if_overlapped with default arguments on overlapped rects", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(check_if_overlapped_with_default_arguments_on_overlapped_rects) { cv::Rect rect1(0, 0, 10, 10); cv::Rect rect2(0, 0, 10, 10); config_for_ocr_struct config_for_ocr_struct; - CHECK(ocr_object.check_if_overlapped(rect1, rect2, config_for_ocr_struct) == + BOOST_TEST(ocr_object.check_if_overlapped(rect1, rect2, config_for_ocr_struct) == true); } -TEST_CASE("check_if_overlapped with default arguments on non overlapped rects", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(check_if_overlapped_with_default_arguments_on_non_overlapped_rects) { cv::Rect rect1(0, 0, 10, 10); cv::Rect rect2(10, 10, 10, 10); config_for_ocr_struct config_for_ocr_struct; - CHECK(ocr_object.check_if_overlapped(rect1, rect2, config_for_ocr_struct) == + BOOST_TEST(ocr_object.check_if_overlapped(rect1, rect2, config_for_ocr_struct) == false); } -TEST_CASE("check_if_overlapped with threshold 0.01 ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(check_if_overlapped_with_threshold_0_01) { cv::Rect rect1(0, 0, 10, 10); cv::Rect rect2(9, 9, 10, 10); config_for_ocr_struct config_for_ocr_struct; config_for_ocr_struct.overlapped_threshold = 0.01; - CHECK(ocr_object.check_if_overlapped(rect1, rect2, config_for_ocr_struct) == + BOOST_TEST(ocr_object.check_if_overlapped(rect1, rect2, config_for_ocr_struct) == false); } -TEST_CASE("check_if_overlapped with threshold 0.009 ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(check_if_overlapped_with_threshold_0_009) { cv::Rect rect1(0, 0, 10, 10); cv::Rect rect2(9, 9, 10, 10); config_for_ocr_struct config_for_ocr_struct; config_for_ocr_struct.overlapped_threshold = 0.009; - CHECK(ocr_object.check_if_overlapped(rect1, rect2, config_for_ocr_struct) == + BOOST_TEST(ocr_object.check_if_overlapped(rect1, rect2, config_for_ocr_struct) == true); } -TEST_CASE("contours_to_char_structs with default arguments ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(contours_to_char_structs_with_default_arguments) { fs::path desired_image_path = ocr_engine_asset_path / "contours_to_char_structs_default.png"; cv::Mat desired_image_temp = cv::imread(desired_image_path.string()); @@ -56,14 +62,12 @@ TEST_CASE("contours_to_char_structs with default arguments ", cv::cvtColor(desired_image_temp, desired_image, cv::COLOR_BGR2GRAY); std::vector> contours = find_all_countors(desired_image); - std::vector characters = + std::vector characters = ocr_object.contours_to_char_structs(contours); - CHECK(characters.size() == 475); + BOOST_TEST(characters.size() == 475); } -TEST_CASE( - "contours_to_char_structs with default arguments on empty contour vector ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(contours_to_char_structs_with_default_arguments_on_empty_contour_vector) { fs::path desired_image_path = ocr_engine_asset_path / "contours_to_char_structs_Solid_black.png"; cv::Mat desired_image_temp = cv::imread(desired_image_path.string()); @@ -71,24 +75,22 @@ TEST_CASE( cv::cvtColor(desired_image_temp, desired_image, cv::COLOR_BGR2GRAY); std::vector> contours = find_all_countors(desired_image); - std::vector characters = + std::vector characters = ocr_object.contours_to_char_structs(contours); - CHECK(characters.size() == 0); + BOOST_TEST(characters.size() == 0); } -TEST_CASE("enhance_contour_image_for_model with default arguments ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(enhance_contour_image_for_modelwithdefaultarguments) { fs::path source_image_path = ocr_engine_asset_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); cv::Mat processed_image = source_image.clone(); config_for_ocr_struct config_for_ocr_struct; ocr_object.enhance_contour_image_for_model(processed_image, config_for_ocr_struct); - CHECK((sum(source_image != processed_image) == cv::Scalar(0, 0, 0, 0))); + BOOST_TEST((sum(source_image != processed_image) == cv::Scalar(0, 0, 0, 0))); } -TEST_CASE("enhance_contour_image_for_model with resize ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(enhance_contour_image_for_model_with_resize) { fs::path source_image_path = ocr_engine_asset_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); fs::path desired_image_path = @@ -98,11 +100,10 @@ TEST_CASE("enhance_contour_image_for_model with resize ", config_for_ocr_struct.do_resize_contour = true; ocr_object.enhance_contour_image_for_model(source_image, config_for_ocr_struct); - CHECK((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); + BOOST_TEST((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); } -TEST_CASE("enhance_contour_image_for_model with make_white ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(enhance_contour_image_for_modelwithmake_white) { fs::path source_image_path = ocr_engine_asset_path / "test_image.png"; cv::Mat source_image = cv::imread(source_image_path.string()); fs::path desired_image_path = @@ -112,43 +113,39 @@ TEST_CASE("enhance_contour_image_for_model with make_white ", config_for_ocr_struct.make_white_background = true; ocr_object.enhance_contour_image_for_model(source_image, config_for_ocr_struct); - CHECK((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); + BOOST_TEST((sum(source_image != desired_image) == cv::Scalar(0, 0, 0, 0))); } -TEST_CASE("euclidean_distance with two non overlapped chars ", - "[w_ocr_engine_test.cpp]") { - OCR::characters_struct char1; - OCR::characters_struct char2; +BOOST_AUTO_TEST_CASE(euclidean_distance_with_two_non_overlapped_chars) { + w_ocr_engine::characters_struct char1; + w_ocr_engine::characters_struct char2; char1.center.x = 1; char1.center.y = 1; char2.center.x = 1; char2.center.y = 2; double distance = ocr_object.euclidean_distance(char1, char2); - CHECK(distance == 1); + BOOST_TEST(distance == 1); } -TEST_CASE("euclidean_distance with two overlapped chars ", - "[w_ocr_engine_test.cpp]") { - OCR::characters_struct char1; - OCR::characters_struct char2; +BOOST_AUTO_TEST_CASE(euclidean_distance_with_two_overlapped_chars) { + w_ocr_engine::characters_struct char1; + w_ocr_engine::characters_struct char2; char1.center.x = 1; char1.center.y = 1; char2.center.x = 1; char2.center.y = 1; double distance = ocr_object.euclidean_distance(char1, char2); - CHECK(distance == 0); + BOOST_TEST(distance == 0); } -TEST_CASE("euclidean_distance with two empty chars ", - "[w_ocr_engine_test.cpp]") { - OCR::characters_struct char1; - OCR::characters_struct char2; +BOOST_AUTO_TEST_CASE(euclidean_distance_with_two_empty_chars) { + w_ocr_engine::characters_struct char1; + w_ocr_engine::characters_struct char2; double distance = ocr_object.euclidean_distance(char1, char2); - CHECK(distance == 0); + BOOST_TEST(distance == 0); } -TEST_CASE("filter_chars_by_contour_size without restriction ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(filter_chars_by_contour_size_without_restriction) { fs::path source_image_path = ocr_engine_asset_path / "filter_chars_by_contour_size.png"; cv::Mat source_image = cv::imread(source_image_path.string()); @@ -162,16 +159,15 @@ TEST_CASE("filter_chars_by_contour_size without restriction ", cv::Mat prepared = prepare_image_for_contour_detection(source_image, config_for_ocr_struct); std::vector> contours = find_all_countors(prepared); - std::vector characters = + std::vector characters = ocr_object.contours_to_char_structs(contours); - std::vector filtered_characters = + std::vector filtered_characters = ocr_object.filter_chars_by_contour_size(characters, config_for_ocr_struct); - CHECK(filtered_characters.size() == 3); + BOOST_TEST(filtered_characters.size() == 3); } -TEST_CASE("filter_chars_by_contour_size by area restriction ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(filter_chars_by_contour_size_by_area_restriction) { fs::path source_image_path = ocr_engine_asset_path / "filter_chars_by_contour_size.png"; cv::Mat source_image = cv::imread(source_image_path.string()); @@ -185,16 +181,15 @@ TEST_CASE("filter_chars_by_contour_size by area restriction ", cv::Mat prepared = prepare_image_for_contour_detection(source_image, config_for_ocr_struct); std::vector> contours = find_all_countors(prepared); - std::vector characters = + std::vector characters = ocr_object.contours_to_char_structs(contours); - std::vector filtered_characters = + std::vector filtered_characters = ocr_object.filter_chars_by_contour_size(characters, config_for_ocr_struct); - CHECK(filtered_characters.size() == 2); + BOOST_TEST(filtered_characters.size() == 2); } -TEST_CASE("filter_chars_by_contour_size by width restriction ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(filter_chars_by_contour_size_by_width_restriction) { fs::path source_image_path = ocr_engine_asset_path / "filter_chars_by_contour_size.png"; cv::Mat source_image = cv::imread(source_image_path.string()); @@ -208,55 +203,53 @@ TEST_CASE("filter_chars_by_contour_size by width restriction ", cv::Mat prepared = prepare_image_for_contour_detection(source_image, config_for_ocr_struct); std::vector> contours = find_all_countors(prepared); - std::vector characters = + std::vector characters = ocr_object.contours_to_char_structs(contours); - std::vector filtered_characters = + std::vector filtered_characters = ocr_object.filter_chars_by_contour_size(characters, config_for_ocr_struct); - CHECK(filtered_characters.size() == 1); + BOOST_TEST(filtered_characters.size() == 1); } -TEST_CASE("merge_overlapped_contours on two overlapped contours ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(merge_overlapped_contours_on_two_overlapped_contours) { config_for_ocr_struct config_for_ocr_struct; - OCR::characters_struct char1; + w_ocr_engine::characters_struct char1; char1.bound_rect.x = 0; char1.bound_rect.y = 0; char1.bound_rect.width = 10; char1.bound_rect.height = 10; - OCR::characters_struct char2; + w_ocr_engine::characters_struct char2; char2.bound_rect.x = 0; char2.bound_rect.y = 0; char2.bound_rect.width = 10; char2.bound_rect.height = 10; - std::vector characters; + std::vector characters; characters.push_back(char1); characters.push_back(char2); ocr_object.merge_overlapped_contours(characters, config_for_ocr_struct); - CHECK(characters.size() == 1); + BOOST_TEST(characters.size() == 1); } -TEST_CASE("merge_overlapped_contours on two non overlapped contours ", - "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(merge_overlapped_contours_on_two_non_overlapped_contours) { config_for_ocr_struct config_for_ocr_struct; - OCR::characters_struct char1; + w_ocr_engine::characters_struct char1; char1.bound_rect.x = 0; char1.bound_rect.y = 0; char1.bound_rect.width = 10; char1.bound_rect.height = 10; - OCR::characters_struct char2; + w_ocr_engine::characters_struct char2; char2.bound_rect.x = 0; char2.bound_rect.y = 10; char2.bound_rect.width = 10; char2.bound_rect.height = 10; - std::vector characters; + std::vector characters; characters.push_back(char1); characters.push_back(char2); ocr_object.merge_overlapped_contours(characters, config_for_ocr_struct); - CHECK(characters.size() == 2); + BOOST_TEST(characters.size() == 2); } -TEST_CASE("mask_contour works", "[w_ocr_engine_test.cpp]") { +BOOST_AUTO_TEST_CASE(mask_contour_works) { fs::path contours_image_path = ocr_engine_asset_path / "filter_chars_by_contour_size.png"; fs::path source_image_path = ocr_engine_asset_path / "test_image.png"; @@ -269,8 +262,12 @@ TEST_CASE("mask_contour works", "[w_ocr_engine_test.cpp]") { cv::Mat prepared = prepare_image_for_contour_detection(contours_image, config_for_ocr_struct); std::vector> contours = find_all_countors(prepared); - std::vector characters = + std::vector characters = ocr_object.contours_to_char_structs(contours); cv::Mat processed = ocr_object.mask_contour(source_image, characters[1]); - CHECK((sum(processed != desired_image) == cv::Scalar(0, 0, 0, 0))); + BOOST_TEST((sum(processed != desired_image) == cv::Scalar(0, 0, 0, 0))); } + +#endif // WOLF_ML_OCR + +#endif // WOLF_TEST diff --git a/wolf/ml/test/w_referee_test.cpp b/wolf/ml/test/w_referee_test.hpp similarity index 61% rename from wolf/ml/test/w_referee_test.cpp rename to wolf/ml/test/w_referee_test.hpp index 11a8405bc..5dab44648 100644 --- a/wolf/ml/test/w_referee_test.cpp +++ b/wolf/ml/test/w_referee_test.hpp @@ -1,21 +1,30 @@ -#include "w_referee.h" +#ifdef WOLF_TEST -#include +#pragma once + +#ifdef WOLF_ML_OCR + +#define BOOST_TEST_MODULE ml_referee + +#include + +#include #include #include -#include "w_ocr_engine.h" +#include namespace fs = std::filesystem; -fs::path ocr_referee_class_path = - "../../../ocr/common_test_asset/ocr_referee_class"; +fs::path w_referee_path = "../wolf/ml/test/common_test_asset/w_referee"; -TEST_CASE("concatenate_name_result function", "[w_referee_test.cpp]") { - ocr_referee_class ocr_referee_object; +using namespace wolf::ml::ocr; - std::vector cluster_temp; +BOOST_AUTO_TEST_CASE(concatenate_name_result_function) { + w_referee ocr_referee_object; - OCR::character_and_center char_center_temp; + std::vector cluster_temp; + + w_ocr_engine::character_and_center char_center_temp; char_center_temp.text = "T"; char_center_temp.center = cv::Point(5, 20); cluster_temp.push_back(char_center_temp); @@ -29,42 +38,42 @@ TEST_CASE("concatenate_name_result function", "[w_referee_test.cpp]") { char_center_temp.center = cv::Point(20, 20); cluster_temp.push_back(char_center_temp); - OCR::character_and_center temp_result = + w_ocr_engine::character_and_center temp_result = ocr_referee_object.concatenate_name_result(cluster_temp); - REQUIRE(temp_result.text.compare("T e s t") == 0); + BOOST_TEST(temp_result.text.compare("T e s t") == 0); } -TEST_CASE("if_the_string_is_in_the_vector function", "[w_referee_test.cpp]") { - ocr_referee_class ocr_referee_object; +BOOST_AUTO_TEST_CASE(if_the_string_is_in_the_vector_function) { + w_referee ocr_referee_object; - std::vector vote_vector_temp; - ocr_referee_class::vote_over_string_vector vote_var_temp; + std::vector vote_vector_temp; + w_referee::vote_over_string_vector vote_var_temp; vote_var_temp.already_voted = false; vote_var_temp.center = cv::Point(70, 77); vote_var_temp.str = "Test"; vote_vector_temp.push_back(vote_var_temp); - OCR::character_and_center char_temp; + w_ocr_engine::character_and_center char_temp; char_temp.center = cv::Point(70, 77); char_temp.text = "Test"; - REQUIRE(ocr_referee_object.if_the_string_is_in_the_vector(char_temp, + BOOST_TEST(ocr_referee_object.if_the_string_is_in_the_vector(char_temp, vote_vector_temp)); } -TEST_CASE("voting_over_results_and_names function", "[w_referee_test.cpp]") { - ocr_referee_class ocr_referee_object; +BOOST_AUTO_TEST_CASE(voting_over_results_and_names_function) { + w_referee ocr_referee_object; - std::vector all_results_temp; - ocr_referee_class::frame_result_struct frame_date_temp; + std::vector all_results_temp; + w_referee::frame_result_struct frame_date_temp; frame_date_temp.frame_number = 110; frame_date_temp.away_name.text = "ENGLAND"; frame_date_temp.away_result.text = "1"; frame_date_temp.home_name.text = "IRAN"; frame_date_temp.home_result.text = "2"; - frame_date_temp.stat = ocr_referee_class::final_result; + frame_date_temp.stat = w_referee::final_result; all_results_temp.push_back(frame_date_temp); all_results_temp.push_back(frame_date_temp); all_results_temp.push_back(frame_date_temp); @@ -86,10 +95,14 @@ TEST_CASE("voting_over_results_and_names function", "[w_referee_test.cpp]") { all_results_temp.push_back(frame_date_temp); all_results_temp.push_back(frame_date_temp); - ocr_referee_class::frame_result_struct frame_date_result; + w_referee::frame_result_struct frame_date_result; ocr_referee_object.voting_over_results_and_names(frame_date_result, all_results_temp); - REQUIRE(frame_date_result.away_result.text.compare("1") == 0); + BOOST_TEST(frame_date_result.away_result.text.compare("1") == 0); } + +#endif // WOLF_ML_OCR + +#endif // WOLF_TEST diff --git a/wolf/ml/test/w_soccer_test.cpp b/wolf/ml/test/w_soccer_test.hpp similarity index 60% rename from wolf/ml/test/w_soccer_test.cpp rename to wolf/ml/test/w_soccer_test.hpp index 91b2ad637..a4a467670 100644 --- a/wolf/ml/test/w_soccer_test.cpp +++ b/wolf/ml/test/w_soccer_test.hpp @@ -1,40 +1,50 @@ -#include "w_soccer.h" +#ifdef WOLF_TEST -#include +#pragma once + +#ifdef WOLF_ML_OCR + +#define BOOST_TEST_MODULE ml_soccer + +#include + +#include #include #include #include -#include "w_ocr_engine.h" -#include "w_read_video_frames.h" -#include "w_referee.h" -#include "w_utilities.h" +#include +#include +#include +#include namespace fs = std::filesystem; -fs::path soccer_asset_path = "../../../ocr/common_test_asset/soccer"; +fs::path soccer_asset_path = "../wolf/ml/test/common_test_asset/soccer"; -TEST_CASE("set_config function", "[w_soccer_test.cpp]") { +using namespace wolf::ml::ocr; + +BOOST_AUTO_TEST_CASE(set_config_function) { fs::path env_file_path = soccer_asset_path / ".set_config"; set_env(env_file_path.string().c_str()); char *type = new char[50]; snprintf(type, 50, "SOCCER_SCREEN_IDENTITY"); - OCR::config_struct screen_identity = w_soccer::set_config(type); + w_ocr_engine::config_struct screen_identity = w_soccer::set_config(type); delete[] type; - REQUIRE(!screen_identity.config_for_ocr.verbose); - REQUIRE(screen_identity.config_for_ocr.restrictions.max_area == 105); - REQUIRE(screen_identity.name.compare("window_name_test") == 0); + BOOST_TEST(!screen_identity.config_for_ocr.verbose); + BOOST_TEST(screen_identity.config_for_ocr.restrictions.max_area == 105); + BOOST_TEST(screen_identity.name.compare("window_name_test") == 0); } -std::vector video_result; +std::vector video_result; typedef void ocr_callback(char *, int, uint8_t *, int, int); void ocr_result(char *pResultBuffer, int pResultBufferSize, uint8_t *pImageBuffer, int pImageWidth, int pImageHeight) { - ocr_referee_class::match_result_struct match_result_temp; + w_referee::match_result_struct match_result_temp; std::string temp(pResultBuffer); std::vector result_vec = split_string(temp, ','); @@ -50,7 +60,7 @@ void ocr_result(char *pResultBuffer, int pResultBufferSize, video_result.push_back(match_result_temp); } -TEST_CASE("single_image_result_extraction function", "[w_soccer_test.cpp]") { +BOOST_AUTO_TEST_CASE(single_image_result_extraction_function) { fs::path json_file_path = soccer_asset_path / ".single_image_result_extraction"; fs::path video_path = @@ -63,7 +73,7 @@ TEST_CASE("single_image_result_extraction function", "[w_soccer_test.cpp]") { w_soccer *referee_obj = new w_soccer(); // This is an example of using the Project - read_video_frames player(video_path.string()); + w_read_video_frames player(video_path.string()); int number_of_frames = int(player.get_frame_amount()); cv::Mat frame; @@ -85,14 +95,14 @@ TEST_CASE("single_image_result_extraction function", "[w_soccer_test.cpp]") { << video_result[0].home_result.text << " " << video_result[0].away_result.text << std::endl; - REQUIRE(video_result[0].stat.compare("90 00") == 0); - REQUIRE(video_result[0].home_name.text.compare("ARSENAL") == 0); - REQUIRE(video_result[0].away_name.text.compare("FC BAYERN") == 0); - REQUIRE(video_result[0].home_result.text.compare("0") == 0); - REQUIRE(video_result[0].away_result.text.compare("8") == 0); + BOOST_TEST(video_result[0].stat.compare("90 00") == 0); + BOOST_TEST(video_result[0].home_name.text.compare("ARSENAL") == 0); + BOOST_TEST(video_result[0].away_name.text.compare("FC BAYERN") == 0); + BOOST_TEST(video_result[0].home_result.text.compare("0") == 0); + BOOST_TEST(video_result[0].away_result.text.compare("8") == 0); } -TEST_CASE("fill_stat_map function", "[w_soccer_test.cpp]") { +BOOST_AUTO_TEST_CASE(fill_stat_map_function) { fs::path json_file_path = soccer_asset_path / ".fill_stat_map"; set_env(json_file_path.string().c_str()); @@ -101,18 +111,16 @@ TEST_CASE("fill_stat_map function", "[w_soccer_test.cpp]") { std::map stat_map = referee_obj.get_stat_map(); - REQUIRE(stat_map["45 00"].compare("first_half") == 0); - REQUIRE(stat_map["90 00"].compare("second_half") == 0); - // REQUIRE(referee_obj->stat_extra_first_half.compare("105 00") == 0); - // REQUIRE(referee_obj->stat_extra_second_half.compare("120 00") == 0); - // REQUIRE(referee_obj->stat_penalty.compare("penalty") == 0); + BOOST_TEST(stat_map["45 00"].compare("first_half") == 0); + BOOST_TEST(stat_map["90 00"].compare("second_half") == 0); + // BOOST_TEST(referee_obj->stat_extra_first_half.compare("105 00") == 0); + // BOOST_TEST(referee_obj->stat_extra_second_half.compare("120 00") == 0); + // BOOST_TEST(referee_obj->stat_penalty.compare("penalty") == 0); } -TEST_CASE("replace_team_names_with_most_similar_string finds similar team to " - "REALMDRD", - "[w_soccer_test.cpp]") { - std::vector results; - ocr_referee_class::match_result_struct result; +BOOST_AUTO_TEST_CASE(replace_team_names_with_most_similar_string_finds_similar_team_to_REALMDRD) { + std::vector results; + w_referee::match_result_struct result; fs::path similar_strings_path = soccer_asset_path / ".replace_team_names_with_most_similar_string"; @@ -124,15 +132,15 @@ TEST_CASE("replace_team_names_with_most_similar_string finds similar team to " w_soccer::replace_team_names_with_most_similar_string(results); - REQUIRE(results[0].away_name.text.compare("REAL MADRID") == 0); + BOOST_TEST(results[0].away_name.text.compare("REAL MADRID") == 0); } -TEST_CASE("initial_match_result_struct function", "[w_soccer_test.cpp]") { +BOOST_AUTO_TEST_CASE(initial_match_result_struct_function) { fs::path json_file_path = soccer_asset_path / ".initial_match_result_struct"; set_env(json_file_path.string().c_str()); - ocr_referee_class::frame_result_struct frame_data; + w_referee::frame_result_struct frame_data; frame_data.away_name.text = "IRAN"; frame_data.away_result.text = "3"; frame_data.home_name.text = "ENGLAND"; @@ -143,24 +151,24 @@ TEST_CASE("initial_match_result_struct function", "[w_soccer_test.cpp]") { w_soccer soccer_object; - ocr_referee_class::match_result_struct match_struct_temp; + w_referee::match_result_struct match_struct_temp; match_struct_temp = soccer_object.initial_match_result_struct(frame_data, image); image.release(); - REQUIRE(match_struct_temp.all_frames_results[0].away_name.text.compare( + BOOST_TEST(match_struct_temp.all_frames_results[0].away_name.text.compare( "IRAN") == 0); - REQUIRE(match_struct_temp.stat.compare("first_half") == 0); - REQUIRE(match_struct_temp.all_frames_results[0].away_result.text.compare( + BOOST_TEST(match_struct_temp.stat.compare("first_half") == 0); + BOOST_TEST(match_struct_temp.all_frames_results[0].away_result.text.compare( "3") == 0); } -TEST_CASE("update_match_data function", "[w_soccer_test.cpp]") { +BOOST_AUTO_TEST_CASE(update_match_data_function) { fs::path json_file_path = soccer_asset_path / ".update_match_data"; set_env(json_file_path.string().c_str()); - ocr_referee_class::frame_result_struct frame_data; + w_referee::frame_result_struct frame_data; frame_data.away_name.text = "IRAN"; frame_data.away_result.text = "3"; frame_data.home_name.text = "ENGLAND"; @@ -171,9 +179,9 @@ TEST_CASE("update_match_data function", "[w_soccer_test.cpp]") { w_soccer soccer_object; - std::vector match_data_temp; + std::vector match_data_temp; match_data_temp = soccer_object.get_matches_data(); - REQUIRE(match_data_temp.size() == 0); + BOOST_TEST(match_data_temp.size() == 0); soccer_object.update_match_data(frame_data, image); frame_data.frame_number = 116; @@ -182,22 +190,22 @@ TEST_CASE("update_match_data function", "[w_soccer_test.cpp]") { soccer_object.update_match_data(frame_data, image); match_data_temp = soccer_object.get_matches_data(); - REQUIRE(match_data_temp.size() == 1); + BOOST_TEST(match_data_temp.size() == 1); frame_data.frame_number = 210; soccer_object.update_match_data(frame_data, image); match_data_temp = soccer_object.get_matches_data(); - REQUIRE(match_data_temp.size() == 2); - REQUIRE(match_data_temp[1].all_frames_results[0].frame_number == 210); + BOOST_TEST(match_data_temp.size() == 2); + BOOST_TEST(match_data_temp[1].all_frames_results[0].frame_number == 210); } -TEST_CASE("get_matches_data function", "[w_soccer_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_matches_data_function) { fs::path json_file_path = soccer_asset_path / ".update_match_data"; set_env(json_file_path.string().c_str()); - ocr_referee_class::frame_result_struct frame_data; + w_referee::frame_result_struct frame_data; frame_data.away_name.text = "IRAN"; frame_data.away_result.text = "3"; frame_data.home_name.text = "ENGLAND"; @@ -208,18 +216,16 @@ TEST_CASE("get_matches_data function", "[w_soccer_test.cpp]") { w_soccer soccer_object; - std::vector match_data_temp; + std::vector match_data_temp; soccer_object.update_match_data(frame_data, image); match_data_temp = soccer_object.get_matches_data(); - REQUIRE(match_data_temp.size() == 1); - REQUIRE(match_data_temp[0].all_frames_results[0].frame_number == 114); + BOOST_TEST(match_data_temp.size() == 1); + BOOST_TEST(match_data_temp[0].all_frames_results[0].frame_number == 114); } -TEST_CASE("replace_team_names_with_most_similar_string finds similar team to " - "empty string", - "[w_soccer_test.cpp]") { - std::vector results; - ocr_referee_class::match_result_struct result; +BOOST_AUTO_TEST_CASE(replace_team_names_with_most_similar_string_finds_similar_team_to_empty_string) { + std::vector results; + w_referee::match_result_struct result; fs::path similar_strings_path = soccer_asset_path / ".replace_team_names_with_most_similar_string"; @@ -231,5 +237,10 @@ TEST_CASE("replace_team_names_with_most_similar_string finds similar team to " w_soccer::replace_team_names_with_most_similar_string(results); - REQUIRE(results[0].away_name.text.compare("") == 0); + BOOST_TEST(results[0].away_name.text.compare("") == 0); } + + +#endif // WOLF_ML_OCR + +#endif // WOLF_TEST \ No newline at end of file diff --git a/wolf/ml/test/w_utilities_test.cpp b/wolf/ml/test/w_utilities_test.hpp similarity index 58% rename from wolf/ml/test/w_utilities_test.cpp rename to wolf/ml/test/w_utilities_test.hpp index 6687f2b46..ad05e5ae1 100644 --- a/wolf/ml/test/w_utilities_test.cpp +++ b/wolf/ml/test/w_utilities_test.hpp @@ -1,50 +1,56 @@ -#include "w_utilities.h" +#ifdef WOLF_TEST -#include +#pragma once + +#ifdef WOLF_ML_OCR + +#define BOOST_TEST_MODULE ml_utilities + +#include + +#include #include #include namespace fs = std::filesystem; +fs::path utilities_asset_path = "../wolf/ml/test/common_test_asset/utilities"; -fs::path utilities_asset_path = "../../../ocr/common_test_asset/utilities"; +using namespace wolf::ml::ocr; -TEST_CASE("get_value_from_json_file_by_key gives value by key", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_value_from_json_file_by_key_gives_value_by_key) { fs::path json_file_path = utilities_asset_path / "get_value_from_json_file_by_key.json"; std::string key = "cpp-test-json"; std::string value = get_value_from_json_file_by_key(json_file_path.string(), key); - REQUIRE(value.compare("ready") == 0); + BOOST_TEST(value.compare("ready") == 0); } -TEST_CASE("string_2_boolean on capitalized characters", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(string_2_boolean_on_capitalized_characters) { std::vector list_string; list_string.push_back("true"); list_string.push_back("FalSe"); bool temp; temp = string_2_boolean(list_string[0]); - REQUIRE(temp); + BOOST_TEST(temp); temp = string_2_boolean(list_string[1]); - REQUIRE(!temp); + BOOST_TEST(!temp); } -TEST_CASE("line_of_numbers_in_string_to_vector_of_integers function", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(line_of_numbers_in_string_to_vector_of_integers_function) { std::string temp = "100,200,300,400"; std::vector integer_list = line_of_numbers_in_string_to_vector_of_integers(temp); - REQUIRE(integer_list[0] == 100); - REQUIRE(integer_list[1] == 200); - REQUIRE(integer_list[2] == 300); - REQUIRE(integer_list[3] == 400); + BOOST_TEST(integer_list[0] == 100); + BOOST_TEST(integer_list[1] == 200); + BOOST_TEST(integer_list[2] == 300); + BOOST_TEST(integer_list[3] == 400); } -TEST_CASE("store_image_in_folder function", "[w_utilities_test.cpp]") { - std::vector temp_video_result; - ocr_referee_class::match_result_struct temp; - ocr_referee_class::frame_result_struct frame_result; +BOOST_AUTO_TEST_CASE(store_image_in_folder_function) { + std::vector temp_video_result; + w_referee::match_result_struct temp; + w_referee::frame_result_struct frame_result; frame_result.home_name.text = "Home"; frame_result.home_result.text = "2"; @@ -69,13 +75,13 @@ TEST_CASE("store_image_in_folder function", "[w_utilities_test.cpp]") { if (std::filesystem::remove(file_path.string())) { is_file_exist = true; } - REQUIRE(is_file_exist); + BOOST_TEST(is_file_exist); } -TEST_CASE("write_results_in_file function", "[w_utilities_test.cpp]") { - std::vector temp_video_result; - ocr_referee_class::match_result_struct temp; - ocr_referee_class::frame_result_struct frame_result; +BOOST_AUTO_TEST_CASE(write_results_in_file_function) { + std::vector temp_video_result; + w_referee::match_result_struct temp; + w_referee::frame_result_struct frame_result; frame_result.home_name.text = "Home"; frame_result.home_result.text = "2"; @@ -97,10 +103,10 @@ TEST_CASE("write_results_in_file function", "[w_utilities_test.cpp]") { read_text_file_line_by_line(temp_output_text_file.string()); if (!std::filesystem::remove(temp_output_text_file.string())) { - REQUIRE(false); + BOOST_TEST(false); } - REQUIRE(lines[0].compare(temp_video_result[0].stat + "," + + BOOST_TEST(lines[0].compare(temp_video_result[0].stat + "," + temp_video_result[0].home_name.text + "," + temp_video_result[0].home_result.text + "," + temp_video_result[0].away_name.text + "," + @@ -109,7 +115,7 @@ TEST_CASE("write_results_in_file function", "[w_utilities_test.cpp]") { 0); } -TEST_CASE("read_text_file_line_by_line function", "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(read_text_file_line_by_line_function) { fs::path file_path = "./test_read_text_file_line_by_line.txt"; std::string content = "This is a test!"; @@ -118,50 +124,43 @@ TEST_CASE("read_text_file_line_by_line function", "[w_utilities_test.cpp]") { read_text_file_line_by_line(file_path.string()); if (!std::filesystem::remove(file_path.string())) { - REQUIRE(false); + BOOST_TEST(false); } - REQUIRE(lines[0].compare(content) == 0); + BOOST_TEST(lines[0].compare(content) == 0); } -TEST_CASE("normalized_levenshtein_similarity on one empty argument", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(normalized_levenshtein_similarity_on_one_empty_argument) { float similarity = normalized_levenshtein_similarity("", "text"); - REQUIRE(similarity == 0); + BOOST_TEST(similarity == 0); } -TEST_CASE("normalized_levenshtein_similarity on two empty argument", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(normalized_levenshtein_similarity_on_two_empty_argument) { float similarity = normalized_levenshtein_similarity("", ""); - REQUIRE(similarity == 0); + BOOST_TEST(similarity == 0); } -TEST_CASE("normalized_levenshtein_similarity on two equal string", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(normalized_levenshtein_similarity_on_two_equal_string) { float similarity = normalized_levenshtein_similarity("test", "test"); - REQUIRE(similarity == 1); + BOOST_TEST(similarity == 1); } -TEST_CASE("normalized_levenshtein_similarity with similarity 0.5 on strings", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(normalized_levenshtein_similarity_with_similarity_0_5_on_strings) { float similarity = normalized_levenshtein_similarity("test", "mast"); - REQUIRE(similarity == 0.5); + BOOST_TEST(similarity == 0.5); } -TEST_CASE("normalized_levenshtein_similarity on same numbers", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(normalized_levenshtein_similarity_on_same_numbers) { float similarity = normalized_levenshtein_similarity("1234", "1234"); - REQUIRE(similarity == 1); + BOOST_TEST(similarity == 1); } -TEST_CASE("normalized_levenshtein_similarity on strings with different length", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(normalized_levenshtein_similarity_on_strings_with_different_length) { float similarity = normalized_levenshtein_similarity("test", "tst"); - REQUIRE(similarity == 0.75); + BOOST_TEST(similarity == 0.75); } -TEST_CASE("get_nearest_string with threshold 0.5 returns similar string", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_nearest_string_with_threshold_0_5_returns_similar_string) { fs::path similar_strings_path = utilities_asset_path / ".get_nearest_string_0_5"; @@ -169,11 +168,10 @@ TEST_CASE("get_nearest_string with threshold 0.5 returns similar string", std::string path = get_env_string("SIMILAR_STRINGS_FILE_PATH"); std::string output = get_nearest_string("tst1", path); - REQUIRE(output.compare("test1") == 0); + BOOST_TEST(output.compare("test1") == 0); } -TEST_CASE("get_nearest_string with threshold 0.9 returns input", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_nearest_string_with_threshold_0_9_returns_input) { fs::path similar_strings_path = utilities_asset_path / ".get_nearest_string_0_9"; @@ -181,11 +179,10 @@ TEST_CASE("get_nearest_string with threshold 0.9 returns input", std::string path = get_env_string("SIMILAR_STRINGS_FILE_PATH"); std::string output = get_nearest_string("tst1", path); - REQUIRE(output.compare("tst1") == 0); + BOOST_TEST(output.compare("tst1") == 0); } -TEST_CASE("get_nearest_string on empty string returns empty string", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_nearest_string_on_empty_string_returns_empty_string) { fs::path similar_strings_path = utilities_asset_path / ".get_nearest_string_0_5"; @@ -193,68 +190,63 @@ TEST_CASE("get_nearest_string on empty string returns empty string", std::string path = get_env_string("SIMILAR_STRINGS_FILE_PATH"); std::string output = get_nearest_string("", path); - REQUIRE(output.compare("") == 0); + BOOST_TEST(output.compare("") == 0); } -TEST_CASE("replace_string first phrase exists in text", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(replace_string_first_phrase_exists_in_text) { std::string text = "hello hamed"; replace_string(text, "hamed", "bagher"); - REQUIRE(text.compare("hello bagher") == 0); + BOOST_TEST(text.compare("hello bagher") == 0); } -TEST_CASE("replace_string returns text if first phrase not exists in text", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(replace_string_returns_text_if_first_phrase_not_exists_in_text) { std::string text = "hello hamed"; replace_string(text, "shahoo", "bagher"); - REQUIRE(text.compare("hello hamed") == 0); + BOOST_TEST(text.compare("hello hamed") == 0); } -TEST_CASE("replace_string returns empty text if input text was empty", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(replace_string_returns_empty_text_if_input_text_was_empty) { std::string text = ""; replace_string(text, "shahoo", "bagher"); - REQUIRE(text.compare("") == 0); + BOOST_TEST(text.compare("") == 0); } -TEST_CASE("is_line_contains_variable function find empty line", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(is_line_contains_variable_function_find_empty_line) { const std::string content = ""; - REQUIRE(!is_line_contains_variable(content)); + BOOST_TEST(!is_line_contains_variable(content)); } -TEST_CASE("is_line_contains_variable function find line started by #", - "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(is_line_contains_variable_function_find_line_started_by_sharp) { const std::string content = "# This is a commented line!"; - REQUIRE(!is_line_contains_variable(content)); + BOOST_TEST(!is_line_contains_variable(content)); } -TEST_CASE("set_env function", "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(set_env_function) { fs::path dot_env_file_path = utilities_asset_path / ".set_env"; set_env(dot_env_file_path.string().c_str()); if (const char *env_p1 = getenv("V1")) { std::string temp(env_p1); - REQUIRE(temp.compare("v1") == 0); + BOOST_TEST(temp.compare("v1") == 0); } if (const char *env_p2 = getenv("V2")) { std::string temp(env_p2); - REQUIRE(temp.compare("v2") == 0); + BOOST_TEST(temp.compare("v2") == 0); } if (const char *env_p3 = getenv("V3")) { std::string temp(env_p3); - REQUIRE(temp.compare("v3") == 0); + BOOST_TEST(temp.compare("v3") == 0); } if (const char *env_p4 = getenv("V4")) { std::string temp(env_p4); - REQUIRE(temp.compare("v4") == 0); + BOOST_TEST(temp.compare("v4") == 0); } } -TEST_CASE("get_env_int function", "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_env_int_function) { fs::path dot_env_file_path = utilities_asset_path / ".get_env_int"; set_env(dot_env_file_path.string().c_str()); @@ -262,10 +254,10 @@ TEST_CASE("get_env_int function", "[w_utilities_test.cpp]") { std::string key = "INT_VALUE"; int value = get_env_int(key.c_str()); - REQUIRE(value == 7); + BOOST_TEST(value == 7); } -TEST_CASE("get_env_float function", "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_env_float_function) { fs::path dot_env_file_path = utilities_asset_path / ".get_env_float"; set_env(dot_env_file_path.string().c_str()); @@ -273,10 +265,10 @@ TEST_CASE("get_env_float function", "[w_utilities_test.cpp]") { std::string key = "FLOAT_VALUE"; float value = get_env_float(key.c_str()); - REQUIRE(value == 4.5); + BOOST_TEST(value == 4.5); } -TEST_CASE("get_env_boolean function", "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_env_boolean_function) { fs::path dot_env_file_path = utilities_asset_path / ".get_env_boolean"; set_env(dot_env_file_path.string().c_str()); @@ -284,10 +276,10 @@ TEST_CASE("get_env_boolean function", "[w_utilities_test.cpp]") { std::string key = "BOOLEAN_VALUE"; bool value = get_env_boolean(key.c_str()); - REQUIRE(value); + BOOST_TEST(value); } -TEST_CASE("get_env_string function", "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_env_string_function) { fs::path dot_env_file_path = utilities_asset_path / ".get_env_string"; set_env(dot_env_file_path.string().c_str()); @@ -295,10 +287,10 @@ TEST_CASE("get_env_string function", "[w_utilities_test.cpp]") { std::string key = "STRING_VALUE"; std::string value = get_env_string(key.c_str()); - REQUIRE(value.compare("this is a test! == 0")); + BOOST_TEST(value.compare("this is a test! == 0")); } -TEST_CASE("get_env_cv_rect function", "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_env_cv_rect_function) { fs::path dot_env_file_path = utilities_asset_path / ".get_env_cv_rect"; set_env(dot_env_file_path.string().c_str()); @@ -306,16 +298,20 @@ TEST_CASE("get_env_cv_rect function", "[w_utilities_test.cpp]") { std::string key = "CV_RECT_VALUE"; cv::Rect value = get_env_cv_rect(key.c_str()); - REQUIRE(value.x == 313); - REQUIRE(value.y == 110); - REQUIRE(value.width == 72); - REQUIRE(value.height == 14); + BOOST_TEST(value.x == 313); + BOOST_TEST(value.y == 110); + BOOST_TEST(value.width == 72); + BOOST_TEST(value.height == 14); } -TEST_CASE("get_relative_path_to_root function", "[w_utilities_test.cpp]") { +BOOST_AUTO_TEST_CASE(get_relative_path_to_root_function) { std::string temp = get_relative_path_to_root(); bool result = (temp.compare("../") == 0 || temp.compare("../../../") == 0); - REQUIRE(result); + BOOST_TEST(result); } + +#endif // WOLF_ML_OCR + +#endif // WOLF_TEST diff --git a/wolf/tests.cpp b/wolf/tests.cpp index 69dd68ce6..172d92009 100644 --- a/wolf/tests.cpp +++ b/wolf/tests.cpp @@ -53,3 +53,13 @@ BOOST_AUTO_TEST_CASE(wolf_test) { //#include #pragma endregion + +#pragma region ml tests + +#include +#include +#include +#include +#include + +#pragma endregion