diff --git a/.github/workflows/web-server-tests.yml b/.github/workflows/web-server-tests.yml
index 2ff37d11..c8e1ab55 100644
--- a/.github/workflows/web-server-tests.yml
+++ b/.github/workflows/web-server-tests.yml
@@ -40,6 +40,19 @@ jobs:
pip install -r requirements.txt
pip install -r requirements-test.txt
+ - name: Set up Node
+ if: matrix.python-version == '3.12'
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+
+ - name: Lint JavaScript
+ if: matrix.python-version == '3.12'
+ working-directory: Software/web-server
+ run: |
+ npm ci
+ npx eslint 'static/**/*.js'
+
- name: Run tests with coverage
working-directory: Software/web-server
run: |
diff --git a/.gitignore b/.gitignore
index 6cf86bb1..dc9d5717 100644
--- a/.gitignore
+++ b/.gitignore
@@ -103,4 +103,5 @@ packaging/pitrac
*.FCBak
# Node.js (root-level tooling)
-node_modules/
\ No newline at end of file
+node_modules/
+!Software/web-server/static/vendor/
diff --git a/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj b/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj
index c83ab061..b872b283 100644
--- a/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj
+++ b/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj
@@ -131,9 +131,9 @@
Level3
true
- _CRT_SECURE_NO_WARNINGS;BOOST_BIND_GLOBAL_PLACEHOLDERS;BOOST_ALL_DYN_LINK;BOOST_USE_WINAPI_VERSION=0x0A00;YAML_CPP_STATIC_DEFINE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ _CRT_SECURE_NO_WARNINGS;BOOST_BIND_GLOBAL_PLACEHOLDERS;BOOST_ALL_DYN_LINK;BOOST_USE_WINAPI_VERSION=0x0A00;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- E:\Dev_Libs\opencv\build\include;E:\Dev_Libs\yaml-cpp\include;E:\Dev_Libs\boost_1_90_0\boost;../packages/Microsoft.ML.OnnxRuntime.1.23.2/build/native/include
+ E:\Dev_Libs\opencv\build\include;E:\Dev_Libs\boost_1_90_0\boost;../packages/Microsoft.ML.OnnxRuntime.1.23.2/build/native/include
stdcpp20
OldStyle
@@ -141,7 +141,7 @@
Console
true
E:\Dev_Libs\opencv\build\x64\vc16\lib;E:\Dev_Libs\boost_1_90_0\lib64-msvc-14.3
- E:\Dev_Libs\opencv\build\x64\vc16\lib\opencv_world4120d.lib;E:\dev_libs\yaml-cpp\build\Debug\yaml-cppd.lib;../packages/Microsoft.ML.OnnxRuntime.1.23.2/runtimes/win-x64/native/onnxruntime.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)
+ E:\Dev_Libs\opencv\build\x64\vc16\lib\opencv_world4120d.lib;../packages/Microsoft.ML.OnnxRuntime.1.23.2/runtimes/win-x64/native/onnxruntime.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)
@@ -213,7 +213,6 @@
-
true
@@ -253,22 +252,12 @@
-
-
-
-
-
-
-
-
-
-
@@ -378,7 +367,6 @@
-
true
@@ -415,23 +403,15 @@
-
-
-
-
-
-
-
-
@@ -477,7 +457,6 @@
-
@@ -503,8 +482,6 @@
-
-
diff --git a/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.BACKUP b/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.BACKUP
deleted file mode 100644
index 3c8437cc..00000000
--- a/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.BACKUP
+++ /dev/null
@@ -1,544 +0,0 @@
-
-
-
-
-
- Debug
- ARM
-
-
- Debug
- Win32
-
-
- Release
- ARM
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 16.0
- Win32Proj
- {3aa11590-5347-47e5-837c-1d38ea9a56f3}
- ImageProcessing
- 10.0
-
-
-
- Application
- true
- v145
- Unicode
-
-
- Application
- false
- v145
- true
- Unicode
-
-
- Application
- true
- v145
- Unicode
-
-
- Application
- true
- v145
- Unicode
-
-
- Application
- false
- v145
- true
- Unicode
-
-
- Application
- false
- v145
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Level3
- true
- WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
- true
- true
- true
- WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
- true
- true
- true
-
-
-
-
- Level3
- true
- _CRT_SECURE_NO_WARNINGS;BOOST_BIND_GLOBAL_PLACEHOLDERS;BOOST_ALL_DYN_LINK;BOOST_USE_WINAPI_VERSION=0x0A00;YAML_CPP_STATIC_DEFINE;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- E:\Dev_Libs\opencv\build\include;E:\Dev_Libs\yaml-cpp\include;..\packages\Microsoft.ML.OnnxRuntime.1.23.2\build\native\include;E:\Dev_Libs\boost_1_90_0\boost
- stdcpp20
- OldStyle
-
-
- Console
- true
- E:\Dev_Libs\opencv\build\x64\vc16\lib;E:\Dev_Libs\boost_1_90_0\lib64-msvc-14.3
- E:\Dev_Libs\opencv\build\x64\vc16\lib\opencv_world4120d.lib;E:\dev_libs\yaml-cpp\build\Debug\yaml-cppd.lib;..\packages\Microsoft.ML.OnnxRuntime.1.23.2\runtimes\win-x64\native\onnxruntime.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)
-
-
-
-
- Level3
- true
- _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- E:\Dev_Libs\opencv\build\include;E:\Dev_Libs\boost_1_81_0\;E:\Dev_Libs\NumCpp-master\include;
- stdcpp20
- OldStyle
-
-
- Console
- true
- E:\Dev_Libs\opencv\build\x64\vc16\lib;E:\Dev_Libs\boost_1_81_0\stage\lib
- opencv_world490d.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)
-
-
-
-
- Level3
- true
- true
- true
- NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- E:\Dev_Libs\opencv\build\include;E:\Dev_Libs\boost_1_81_0\;E:\Dev_Libs\boost_1_81_0\boost;E:\Dev_Libs\NumCpp-master\include
- stdcpp20
- OldStyle
-
-
- Console
- true
- true
- true
- E:\Dev_Libs\opencv\build\x64\vc16\lib\;E:\Dev_Libs\boost_1_81_0\stage\lib
- opencv_world490.lib;%(AdditionalDependencies)
- true
- true
-
-
-
-
- Level3
- true
- true
- true
- NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- E:\Dev_Libs\opencv\build\include;E:\Dev_Libs\boost_1_81_0\;E:\Dev_Libs\boost_1_81_0\boost;E:\Dev_Libs\NumCpp-master\include
- stdcpp20
- OldStyle
-
-
- Console
- true
- true
- true
- E:\Dev_Libs\opencv\build\x64\vc16\lib\;E:\Dev_Libs\boost_1_81_0\stage\lib
- opencv_world490.lib;%(AdditionalDependencies)
- true
- true
-
-
-
-
-
-
-
-
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
-
-
-
-
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
-
-
- stdcpp20
- stdcpp20
-
-
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.filters b/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.filters
index 1433ac6f..b58e6a0f 100644
--- a/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.filters
+++ b/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.filters
@@ -90,21 +90,6 @@
Source Files
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
Source Files
@@ -117,18 +102,6 @@
Source Files
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
Resource Files
@@ -249,18 +222,12 @@
Source Files
-
- Source Files
-
Source Files
Source Files
-
- Source Files
-
Source Files
@@ -335,21 +302,6 @@
Header Files
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
Header Files
@@ -368,15 +320,6 @@
Header Files
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
Header Files
@@ -479,9 +422,6 @@
Header Files
-
- Header Files
-
Header Files
@@ -559,12 +499,9 @@
-
-
-
Resource Files
diff --git a/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.user b/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.user
index 8d4fe8b0..a1b0dcba 100755
--- a/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.user
+++ b/Software/LMSourceCode/ImageProcessing/ImageProcessing.vcxproj.user
@@ -1,17 +1,11 @@
- --show_images 1 --base_image_logging_dir L:\ --lm_comparison_mode=0 --logging_level trace --artifact_save_level=all --wait_keys 1 --system_mode camera1 --search_center_x 800 --search_center_y 550
+ --base_image_logging_dir L:\ --lm_comparison_mode=0 --system_mode camera1
PITRAC_BASE_IMAGE_LOGGING_DIR=L:\
PATH=%PATH%;E:\Dev_Libs\opencv\build\x64\vc16\bin;E:\Dev_Libs\boost_1_90_0\lib64-msvc-14.3
-PITRAC_SLOT1_CAMERA_TYPE=5
-PITRAC_SLOT2_CAMERA_TYPE=5
-PITRAC_SLOT1_LENS_TYPE=1
-PITRAC_SLOT2_LENS_TYPE=1
-PITRAC_SLOT1_CAMERA_ORIENTATION =1
-PITRAC_SLOT2_CAMERA_ORIENTATION =1
HOME=.
WindowsLocalDebugger
- --show_images 1 --base_image_logging_dir L:\ --lm_comparison_mode=1 --logging_level info --artifact_save_level=all --wait_keys 0 --system_mode camera1 --search_center_x 800 --search_center_y 550|--show_images 1 --base_image_logging_dir L:\ --lm_comparison_mode=1 --logging_level info --artifact_save_level=all --wait_keys 1 --system_mode camera1 --search_center_x 800 --search_center_y 550|--show_images 1 --base_image_logging_dir L:\ --lm_comparison_mode=0 --logging_level info --artifact_save_level=all --wait_keys 1 --system_mode camera1 --search_center_x 800 --search_center_y 550|--show_images 1 --base_image_logging_dir L:\ --lm_comparison_mode=0 --logging_level trace --artifact_save_level=all --wait_keys 0 --system_mode camera1 --search_center_x 800 --search_center_y 550|--show_images 1 --base_image_logging_dir L:\ --lm_comparison_mode=0 --logging_level trace --artifact_save_level=all --wait_keys 1 --system_mode camera1 --search_center_x 800 --search_center_y 550|
+ --base_image_logging_dir L:\ --lm_comparison_mode=1 --system_mode camera1|--base_image_logging_dir L:\ --lm_comparison_mode=0 --system_mode camera1|
\ No newline at end of file
diff --git a/Software/LMSourceCode/ImageProcessing/ball_image_proc.cpp b/Software/LMSourceCode/ImageProcessing/ball_image_proc.cpp
index 15373cc3..568dbbd0 100644
--- a/Software/LMSourceCode/ImageProcessing/ball_image_proc.cpp
+++ b/Software/LMSourceCode/ImageProcessing/ball_image_proc.cpp
@@ -71,39 +71,39 @@ namespace golf_sim {
static const double kEllipseColorMaskWideningAmount = 35;
static const bool kSerializeOpsForDebug = false;
- int BallImageProc::kCoarseXRotationDegreesIncrement = 6;
- int BallImageProc::kCoarseXRotationDegreesStart = -42;
- int BallImageProc::kCoarseXRotationDegreesEnd = 42;
+ int BallImageProc::kCoarseXRotationDegreesIncrement = 4;
+ int BallImageProc::kCoarseXRotationDegreesStart = -36;
+ int BallImageProc::kCoarseXRotationDegreesEnd = 36;
int BallImageProc::kCoarseYRotationDegreesIncrement = 5;
- int BallImageProc::kCoarseYRotationDegreesStart = -30;
- int BallImageProc::kCoarseYRotationDegreesEnd = 30;
- int BallImageProc::kCoarseZRotationDegreesIncrement = 6;
- int BallImageProc::kCoarseZRotationDegreesStart = -50;
- int BallImageProc::kCoarseZRotationDegreesEnd = 60;
+ int BallImageProc::kCoarseYRotationDegreesStart = -15;
+ int BallImageProc::kCoarseYRotationDegreesEnd = 15;
+ int BallImageProc::kCoarseZRotationDegreesIncrement = 4;
+ int BallImageProc::kCoarseZRotationDegreesStart = -10;
+ int BallImageProc::kCoarseZRotationDegreesEnd = 110;
int BallImageProc::kCoarseSearchResolution = 90;
double BallImageProc::kPlacedBallCannyLower;
double BallImageProc::kPlacedBallCannyUpper;
- double BallImageProc::kPlacedBallStartingParam2 = 40;
- double BallImageProc::kPlacedBallMinParam2 = 30;
- double BallImageProc::kPlacedBallMaxParam2 = 60;
- double BallImageProc::kPlacedBallCurrentParam1 = 120.0;
- double BallImageProc::kPlacedBallParam2Increment = 4;
+ double BallImageProc::kPlacedBallStartingParam2 = 0.9;
+ double BallImageProc::kPlacedBallMinParam2 = 0.8;
+ double BallImageProc::kPlacedBallMaxParam2 = 1.0;
+ double BallImageProc::kPlacedBallCurrentParam1 = 130.0;
+ double BallImageProc::kPlacedBallParam2Increment = 0.03;
int BallImageProc::kPlacedMinHoughReturnCircles = 1;
int BallImageProc::kPlacedMaxHoughReturnCircles = 4;
- double BallImageProc::kStrobedBallsCannyLower = 50;
- double BallImageProc::kStrobedBallsCannyUpper = 110;
+ double BallImageProc::kStrobedBallsCannyLower = 33;
+ double BallImageProc::kStrobedBallsCannyUpper = 90;
- int BallImageProc::kStrobedBallsMaxHoughReturnCircles = 12;
- int BallImageProc::kStrobedBallsMinHoughReturnCircles = 1;
+ int BallImageProc::kStrobedBallsMaxHoughReturnCircles = 20;
+ int BallImageProc::kStrobedBallsMinHoughReturnCircles = 6;
- int BallImageProc::kStrobedBallsPreCannyBlurSize = 5;
+ int BallImageProc::kStrobedBallsPreCannyBlurSize = 3;
int BallImageProc::kStrobedBallsPreHoughBlurSize = 13;
- double BallImageProc::kStrobedBallsStartingParam2 = 40;
- double BallImageProc::kStrobedBallsMinParam2 = 30;
- double BallImageProc::kStrobedBallsMaxParam2 = 60;
+ double BallImageProc::kStrobedBallsStartingParam2 = 60;
+ double BallImageProc::kStrobedBallsMinParam2 = 18;
+ double BallImageProc::kStrobedBallsMaxParam2 = 140;
double BallImageProc::kStrobedBallsCurrentParam1 = 120.0;
double BallImageProc::kStrobedBallsHoughDpParam1 = 1.5;
double BallImageProc::kStrobedBallsParam2Increment = 4;
@@ -111,26 +111,26 @@ namespace golf_sim {
bool BallImageProc::kStrobedBallsUseAltHoughAlgorithm = true;
double BallImageProc::kStrobedBallsAltCannyLower = 35;
double BallImageProc::kStrobedBallsAltCannyUpper = 70;
- int BallImageProc::kStrobedBallsAltPreCannyBlurSize = 11;
- int BallImageProc::kStrobedBallsAltPreHoughBlurSize = 16;
- double BallImageProc::kStrobedBallsAltStartingParam2 = 0.95;
- double BallImageProc::kStrobedBallsAltMinParam2 = 0.6;
+ int BallImageProc::kStrobedBallsAltPreCannyBlurSize = 9;
+ int BallImageProc::kStrobedBallsAltPreHoughBlurSize = 15;
+ double BallImageProc::kStrobedBallsAltStartingParam2 = 0.65;
+ double BallImageProc::kStrobedBallsAltMinParam2 = 0.5;
double BallImageProc::kStrobedBallsAltMaxParam2 = 1.0;
double BallImageProc::kStrobedBallsAltCurrentParam1 = 130.0;
- double BallImageProc::kStrobedBallsAltHoughDpParam1 = 1.5;
+ double BallImageProc::kStrobedBallsAltHoughDpParam1 = 0.8;
double BallImageProc::kStrobedBallsAltParam2Increment = 0.05;
bool BallImageProc::kUseCLAHEProcessing;
int BallImageProc::kCLAHEClipLimit;
int BallImageProc::kCLAHETilesGridSize;
- double BallImageProc::kPuttingBallStartingParam2 = 40;
- double BallImageProc::kPuttingBallMinParam2 = 30;
- double BallImageProc::kPuttingBallMaxParam2 = 60;
- double BallImageProc::kPuttingBallCurrentParam1 = 120.0;
- double BallImageProc::kPuttingBallParam2Increment = 4;
- int BallImageProc::kPuttingMaxHoughReturnCircles = 12;
- int BallImageProc::kPuttingMinHoughReturnCircles = 1;
+ double BallImageProc::kPuttingBallStartingParam2 = 0.9;
+ double BallImageProc::kPuttingBallMinParam2 = 0.8;
+ double BallImageProc::kPuttingBallMaxParam2 = 1.0;
+ double BallImageProc::kPuttingBallCurrentParam1 = 300.0;
+ double BallImageProc::kPuttingBallParam2Increment = 0.03;
+ int BallImageProc::kPuttingMaxHoughReturnCircles = 25;
+ int BallImageProc::kPuttingMinHoughReturnCircles = 6;
double BallImageProc::kPuttingHoughDpParam1 = 1.5;
double BallImageProc::kExternallyStrobedEnvCannyLower = 35;
@@ -148,27 +148,25 @@ namespace golf_sim {
int BallImageProc::kExternallyStrobedEnvPreHoughBlurSize = 11;
int BallImageProc::kExternallyStrobedEnvPreCannyBlurSize = 3;
double BallImageProc::kExternallyStrobedEnvHoughDpParam1 = 1.0;
- int BallImageProc::kExternallyStrobedEnvNarrowingPreCannyBlurSize = 3;
- int BallImageProc::kExternallyStrobedEnvNarrowingPreHoughBlurSize = 9;
int BallImageProc::kExternallyStrobedEnvMinimumSearchRadius = 60;
int BallImageProc::kExternallyStrobedEnvMaximumSearchRadius = 80;
- bool BallImageProc::kUseDynamicRadiiAdjustment = true;
- int BallImageProc::kNumberRadiiToAverageForDynamicAdjustment = 3;
- double BallImageProc::kStrobedNarrowingRadiiMinRatio = 0.8;
- double BallImageProc::kStrobedNarrowingRadiiMaxRatio = 1.2;
- double BallImageProc::kStrobedNarrowingRadiiDpParam = 1.8;
- double BallImageProc::kStrobedNarrowingRadiiParam2 = 100.0;
+ bool BallImageProc::kUseDynamicRadiiAdjustment = false;
+ int BallImageProc::kNumberRadiiToAverageForDynamicAdjustment = 2;
+ double BallImageProc::kStrobedNarrowingRadiiMinRatio = 0.7;
+ double BallImageProc::kStrobedNarrowingRadiiMaxRatio = 1.6;
+ double BallImageProc::kStrobedNarrowingRadiiDpParam = 1.5;
+ double BallImageProc::kStrobedNarrowingRadiiParam2 = 0.8;
double BallImageProc::kPlacedNarrowingRadiiMinRatio = 0.9;
double BallImageProc::kPlacedNarrowingRadiiMaxRatio = 1.1;
- double BallImageProc::kPlacedNarrowingStartingParam2 = 80.0;
- double BallImageProc::kPlacedNarrowingRadiiDpParam = 2.0;
+ double BallImageProc::kPlacedNarrowingStartingParam2 = 0.9;
+ double BallImageProc::kPlacedNarrowingRadiiDpParam = 1.5;
double BallImageProc::kPlacedNarrowingParam1 = 130.0;
- int BallImageProc::kPlacedPreCannyBlurSize = 5;
- int BallImageProc::kPlacedPreHoughBlurSize = 11;
+ int BallImageProc::kPlacedPreCannyBlurSize = 11;
+ int BallImageProc::kPlacedPreHoughBlurSize = 13;
int BallImageProc::kPuttingPreHoughBlurSize = 9;
@@ -182,13 +180,10 @@ namespace golf_sim {
double BallImageProc::kBestCircleCannyUpper = 110;
int BallImageProc::kBestCirclePreCannyBlurSize = 5;
int BallImageProc::kBestCirclePreHoughBlurSize = 13;
- double BallImageProc::kBestCircleParam1 = 120.;
- double BallImageProc::kBestCircleParam2 = 35.;
+ double BallImageProc::kBestCircleParam1 = 300.;
+ double BallImageProc::kBestCircleParam2 = 0.65;
double BallImageProc::kBestCircleHoughDpParam1 = 1.5;
- double BallImageProc::kExternallyStrobedBestCircleCannyLower = 55;
- double BallImageProc::kExternallyStrobedBestCircleCannyUpper = 110;
- int BallImageProc::kExternallyStrobedBestCirclePreCannyBlurSize = 5;
int BallImageProc::kExternallyStrobedBestCirclePreHoughBlurSize = 13;
double BallImageProc::kExternallyStrobedBestCircleParam1 = 120.;
double BallImageProc::kExternallyStrobedBestCircleParam2 = 35.;
@@ -198,11 +193,11 @@ namespace golf_sim {
int BallImageProc::kExternallyStrobedCLAHEClipLimit = 6;
int BallImageProc::kExternallyStrobedCLAHETilesGridSize = 6;
- double BallImageProc::kBestCircleIdentificationMinRadiusRatio = 0.85;
- double BallImageProc::kBestCircleIdentificationMaxRadiusRatio = 1.10;
+ double BallImageProc::kBestCircleIdentificationMinRadiusRatio = 0.9;
+ double BallImageProc::kBestCircleIdentificationMaxRadiusRatio = 1.2;
- int BallImageProc::kGaborMaxWhitePercent = 44; // Nominal 46;
- int BallImageProc::kGaborMinWhitePercent = 38; // Nominal 40;
+ int BallImageProc::kGaborMaxWhitePercent = 45; // Nominal 46;
+ int BallImageProc::kGaborMinWhitePercent = 39; // Nominal 40;
std::string BallImageProc::kSpinDetectionMethod = "ml";
// Model Detection Configuration
@@ -211,7 +206,7 @@ namespace golf_sim {
#ifdef _WIN32
std::string BallImageProc::kModelPath = "../../Software/LMSourceCode/ml_assets/yolo26-ball-detector";
#else
- std::string BallImageProc::kModelPath = "../ml_assets/yolo26-ball-detector";
+ std::string BallImageProc::kModelPath = "/etc/pitrac/models/yolo26-ball-detector";
#endif
float BallImageProc::kModelConfidenceThreshold = 0.5f;
float BallImageProc::kModelNMSThreshold = 0.4f;
@@ -244,145 +239,6 @@ namespace golf_sim {
min_ball_radius_ = -1;
max_ball_radius_ = -1;
- // The following constants are only used internal to the GolfSimCamera class, and so can be initialized in the constructor
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseXRotationDegreesIncrement", kCoarseXRotationDegreesIncrement);
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseXRotationDegreesStart", kCoarseXRotationDegreesStart);
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseXRotationDegreesEnd", kCoarseXRotationDegreesEnd);
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseYRotationDegreesIncrement", kCoarseYRotationDegreesIncrement);
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseYRotationDegreesStart", kCoarseYRotationDegreesStart);
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseYRotationDegreesEnd", kCoarseYRotationDegreesEnd);
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseZRotationDegreesIncrement", kCoarseZRotationDegreesIncrement);
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseZRotationDegreesStart", kCoarseZRotationDegreesStart);
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseZRotationDegreesEnd", kCoarseZRotationDegreesEnd);
-
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseSearchResolution", kCoarseSearchResolution);
-
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kGaborMinWhitePercent", kGaborMinWhitePercent);
- GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kGaborMaxWhitePercent", kGaborMaxWhitePercent);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallCannyLower", kPlacedBallCannyLower);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallCannyUpper", kPlacedBallCannyUpper);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallStartingParam2", kPlacedBallStartingParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallMinParam2", kPlacedBallMinParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallMaxParam2", kPlacedBallMaxParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallCurrentParam1", kPlacedBallCurrentParam1);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallParam2Increment", kPlacedBallParam2Increment);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedMinHoughReturnCircles", kPlacedMinHoughReturnCircles);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedMaxHoughReturnCircles", kPlacedMaxHoughReturnCircles);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsCannyLower", kStrobedBallsCannyLower);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsCannyUpper", kStrobedBallsCannyUpper);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsPreCannyBlurSize", kStrobedBallsPreCannyBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsPreHoughBlurSize", kStrobedBallsPreHoughBlurSize);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsStartingParam2", kStrobedBallsStartingParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsMinParam2", kStrobedBallsMinParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsMaxParam2", kStrobedBallsMaxParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsCurrentParam1", kStrobedBallsCurrentParam1);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsParam2Increment", kStrobedBallsParam2Increment);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsMinHoughReturnCircles", kStrobedBallsMinHoughReturnCircles);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsMaxHoughReturnCircles", kStrobedBallsMaxHoughReturnCircles);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsUseAltHoughAlgorithm", kStrobedBallsUseAltHoughAlgorithm);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltCannyLower", kStrobedBallsAltCannyLower);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltCannyUpper", kStrobedBallsAltCannyUpper);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltPreCannyBlurSize", kStrobedBallsAltPreCannyBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltPreHoughBlurSize", kStrobedBallsAltPreHoughBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltStartingParam2", kStrobedBallsAltStartingParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltMinParam2", kStrobedBallsAltMinParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltMaxParam2", kStrobedBallsAltMaxParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltCurrentParam1", kStrobedBallsAltCurrentParam1);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltHoughDpParam1", kStrobedBallsAltHoughDpParam1);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltParam2Increment", kStrobedBallsAltParam2Increment);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kUseCLAHEProcessing", kUseCLAHEProcessing);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kCLAHEClipLimit", kCLAHEClipLimit);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kCLAHETilesGridSize", kCLAHETilesGridSize);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingBallStartingParam2", kPuttingBallStartingParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingBallMinParam2", kPuttingBallMinParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingBallMaxParam2", kPuttingBallMaxParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingBallCurrentParam1", kPuttingBallCurrentParam1);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingBallParam2Increment", kPuttingBallParam2Increment);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingMinHoughReturnCircles", kPuttingMinHoughReturnCircles);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingMaxHoughReturnCircles", kPuttingMaxHoughReturnCircles);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingHoughDpParam1", kPuttingHoughDpParam1);
-
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvCurrentParam1", kExternallyStrobedEnvCurrentParam1);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvMaxParam2", kExternallyStrobedEnvMaxParam2);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvStartingParam2", kExternallyStrobedEnvStartingParam2);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvNarrowingParam2", kExternallyStrobedEnvNarrowingParam2);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvNarrowingDpParam", kExternallyStrobedEnvNarrowingDpParam);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvNarrowingPreCannyBlurSize", kExternallyStrobedEnvNarrowingPreCannyBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvNarrowingPreHoughBlurSize", kExternallyStrobedEnvNarrowingPreHoughBlurSize);
-
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvParam2Increment", kExternallyStrobedEnvParam2Increment);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvMinHoughReturnCircles", kExternallyStrobedEnvMinHoughReturnCircles);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvMaxHoughReturnCircles", kExternallyStrobedEnvMaxHoughReturnCircles);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvPreHoughBlurSize", kExternallyStrobedEnvPreHoughBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvPreCannyBlurSize", kExternallyStrobedEnvPreCannyBlurSize);
-
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCircleCannyLower", kExternallyStrobedBestCircleCannyLower);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCircleCannyUpper", kExternallyStrobedBestCircleCannyUpper);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCirclePreCannyBlurSize", kExternallyStrobedBestCirclePreCannyBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCirclePreHoughBlurSize", kExternallyStrobedBestCirclePreHoughBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCircleParam1", kExternallyStrobedBestCircleParam1);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCircleParam2", kExternallyStrobedBestCircleParam2);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCircleHoughDpParam1", kExternallyStrobedBestCircleHoughDpParam1);
-
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedUseCLAHEProcessing", kExternallyStrobedUseCLAHEProcessing);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedCLAHEClipLimit", kExternallyStrobedCLAHEClipLimit);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedCLAHETilesGridSize", kExternallyStrobedCLAHETilesGridSize);
-
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvHoughDpParam1", kExternallyStrobedEnvHoughDpParam1);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvMaximumSearchRadius", kExternallyStrobedEnvMaximumSearchRadius);
- GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvMinimumSearchRadius", kExternallyStrobedEnvMinimumSearchRadius);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedPreHoughBlurSize", kPlacedPreHoughBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedPreCannyBlurSize", kPlacedPreCannyBlurSize);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsPreHoughBlurSize", kStrobedBallsPreHoughBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingPreHoughBlurSize", kPuttingPreHoughBlurSize);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallHoughDpParam1", kPlacedBallHoughDpParam1);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsHoughDpParam1", kStrobedBallsHoughDpParam1);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kUseBestCircleRefinement", kUseBestCircleRefinement);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kUseBestCircleLargestCircle", kUseBestCircleLargestCircle);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleCannyLower", kBestCircleCannyLower);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleCannyUpper", kBestCircleCannyUpper);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCirclePreCannyBlurSize", kBestCirclePreCannyBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCirclePreHoughBlurSize", kBestCirclePreHoughBlurSize);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleParam1", kBestCircleParam1);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleParam2", kBestCircleParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleHoughDpParam1", kBestCircleHoughDpParam1);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleIdentificationMinRadiusRatio", kBestCircleIdentificationMinRadiusRatio);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleIdentificationMaxRadiusRatio", kBestCircleIdentificationMaxRadiusRatio);
-
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kUseDynamicRadiiAdjustment", kUseDynamicRadiiAdjustment);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kNumberRadiiToAverageForDynamicAdjustment", kNumberRadiiToAverageForDynamicAdjustment);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedNarrowingRadiiMinRatio", kStrobedNarrowingRadiiMinRatio);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedNarrowingRadiiMaxRatio", kStrobedNarrowingRadiiMaxRatio);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedNarrowingRadiiDpParam", kStrobedNarrowingRadiiDpParam);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedNarrowingRadiiParam2", kStrobedNarrowingRadiiParam2);
-
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedNarrowingRadiiMinRatio", kPlacedNarrowingRadiiMinRatio);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedNarrowingRadiiMaxRatio", kPlacedNarrowingRadiiMaxRatio);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedNarrowingStartingParam2", kPlacedNarrowingStartingParam2);
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedNarrowingRadiiDpParam", kPlacedNarrowingRadiiDpParam);
-
- int kImageTypeToProcessWithYOLOAsInt;
- GolfSimConfiguration::SetConstant("gs_config.ball_identification.kImageTypeToProcessWithYOLO", kImageTypeToProcessWithYOLOAsInt);
- kImageTypeToProcessWithYOLO= static_cast(kImageTypeToProcessWithYOLOAsInt);
-
-
- GolfSimConfiguration::SetConstant("gs_config.logging.kLogIntermediateSpinImagesToFile", kLogIntermediateSpinImagesToFile);
-
// Preload model at startup if using experimental detection for either ball placement or flight
if (kStrobedBallDetectionMethod == "experimental" ||
kBallPlacementDetectionMethod == "experimental") {
@@ -1714,9 +1570,6 @@ namespace golf_sim {
cv::GaussianBlur(cannyOutput_for_balls, finalChoiceSubImg, cv::Size(kBestCirclePreHoughBlurSize, kBestCirclePreHoughBlurSize), 0); // Nominal is 7x7
}
else {
- // cv::GaussianBlur(finalChoiceSubImg, finalChoiceSubImg, cv::Size(kExternallyStrobedBestCirclePreCannyBlurSize, kExternallyStrobedBestCirclePreCannyBlurSize), 0);
-
- // cv::Canny(finalChoiceSubImg, cannyOutput_for_balls, kExternallyStrobedBestCircleCannyLower, kExternallyStrobedBestCircleCannyUpper);
cannyOutput_for_balls = finalChoiceSubImg.clone();
LoggingTools::DebugShowImage("Best Circle (externally-strobed)" + std::to_string(expandedRadiusForHough) + " cannyOutput for best ball", cannyOutput_for_balls);
@@ -4394,6 +4247,136 @@ namespace golf_sim {
kSpinDetectionMethod = "ml";
}
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseXRotationDegreesIncrement", kCoarseXRotationDegreesIncrement);
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseXRotationDegreesStart", kCoarseXRotationDegreesStart);
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseXRotationDegreesEnd", kCoarseXRotationDegreesEnd);
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseYRotationDegreesIncrement", kCoarseYRotationDegreesIncrement);
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseYRotationDegreesStart", kCoarseYRotationDegreesStart);
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseYRotationDegreesEnd", kCoarseYRotationDegreesEnd);
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseZRotationDegreesIncrement", kCoarseZRotationDegreesIncrement);
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseZRotationDegreesStart", kCoarseZRotationDegreesStart);
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseZRotationDegreesEnd", kCoarseZRotationDegreesEnd);
+
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kCoarseSearchResolution", kCoarseSearchResolution);
+
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kGaborMinWhitePercent", kGaborMinWhitePercent);
+ GolfSimConfiguration::SetConstant("gs_config.spin_analysis.kGaborMaxWhitePercent", kGaborMaxWhitePercent);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallCannyLower", kPlacedBallCannyLower);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallCannyUpper", kPlacedBallCannyUpper);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallStartingParam2", kPlacedBallStartingParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallMinParam2", kPlacedBallMinParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallMaxParam2", kPlacedBallMaxParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallCurrentParam1", kPlacedBallCurrentParam1);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallParam2Increment", kPlacedBallParam2Increment);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedMinHoughReturnCircles", kPlacedMinHoughReturnCircles);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedMaxHoughReturnCircles", kPlacedMaxHoughReturnCircles);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsCannyLower", kStrobedBallsCannyLower);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsCannyUpper", kStrobedBallsCannyUpper);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsPreCannyBlurSize", kStrobedBallsPreCannyBlurSize);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsPreHoughBlurSize", kStrobedBallsPreHoughBlurSize);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsStartingParam2", kStrobedBallsStartingParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsMinParam2", kStrobedBallsMinParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsMaxParam2", kStrobedBallsMaxParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsCurrentParam1", kStrobedBallsCurrentParam1);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsParam2Increment", kStrobedBallsParam2Increment);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsMinHoughReturnCircles", kStrobedBallsMinHoughReturnCircles);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsMaxHoughReturnCircles", kStrobedBallsMaxHoughReturnCircles);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsUseAltHoughAlgorithm", kStrobedBallsUseAltHoughAlgorithm);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltCannyLower", kStrobedBallsAltCannyLower);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltCannyUpper", kStrobedBallsAltCannyUpper);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltPreCannyBlurSize", kStrobedBallsAltPreCannyBlurSize);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltPreHoughBlurSize", kStrobedBallsAltPreHoughBlurSize);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltStartingParam2", kStrobedBallsAltStartingParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltMinParam2", kStrobedBallsAltMinParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltMaxParam2", kStrobedBallsAltMaxParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltCurrentParam1", kStrobedBallsAltCurrentParam1);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltHoughDpParam1", kStrobedBallsAltHoughDpParam1);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsAltParam2Increment", kStrobedBallsAltParam2Increment);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kUseCLAHEProcessing", kUseCLAHEProcessing);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kCLAHEClipLimit", kCLAHEClipLimit);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kCLAHETilesGridSize", kCLAHETilesGridSize);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingBallStartingParam2", kPuttingBallStartingParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingBallMinParam2", kPuttingBallMinParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingBallMaxParam2", kPuttingBallMaxParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingBallCurrentParam1", kPuttingBallCurrentParam1);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingBallParam2Increment", kPuttingBallParam2Increment);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingMinHoughReturnCircles", kPuttingMinHoughReturnCircles);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingMaxHoughReturnCircles", kPuttingMaxHoughReturnCircles);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingHoughDpParam1", kPuttingHoughDpParam1);
+
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvCurrentParam1", kExternallyStrobedEnvCurrentParam1);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvMaxParam2", kExternallyStrobedEnvMaxParam2);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvStartingParam2", kExternallyStrobedEnvStartingParam2);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvNarrowingParam2", kExternallyStrobedEnvNarrowingParam2);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvNarrowingDpParam", kExternallyStrobedEnvNarrowingDpParam);
+
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvParam2Increment", kExternallyStrobedEnvParam2Increment);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvMinHoughReturnCircles", kExternallyStrobedEnvMinHoughReturnCircles);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvMaxHoughReturnCircles", kExternallyStrobedEnvMaxHoughReturnCircles);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvPreHoughBlurSize", kExternallyStrobedEnvPreHoughBlurSize);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvPreCannyBlurSize", kExternallyStrobedEnvPreCannyBlurSize);
+
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCirclePreHoughBlurSize", kExternallyStrobedBestCirclePreHoughBlurSize);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCircleParam1", kExternallyStrobedBestCircleParam1);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCircleParam2", kExternallyStrobedBestCircleParam2);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedBestCircleHoughDpParam1", kExternallyStrobedBestCircleHoughDpParam1);
+
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedUseCLAHEProcessing", kExternallyStrobedUseCLAHEProcessing);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedCLAHEClipLimit", kExternallyStrobedCLAHEClipLimit);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedCLAHETilesGridSize", kExternallyStrobedCLAHETilesGridSize);
+
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvHoughDpParam1", kExternallyStrobedEnvHoughDpParam1);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvMaximumSearchRadius", kExternallyStrobedEnvMaximumSearchRadius);
+ GolfSimConfiguration::SetConstant("gs_config.testing.kExternallyStrobedEnvMinimumSearchRadius", kExternallyStrobedEnvMinimumSearchRadius);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedPreHoughBlurSize", kPlacedPreHoughBlurSize);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedPreCannyBlurSize", kPlacedPreCannyBlurSize);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPuttingPreHoughBlurSize", kPuttingPreHoughBlurSize);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedBallHoughDpParam1", kPlacedBallHoughDpParam1);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedBallsHoughDpParam1", kStrobedBallsHoughDpParam1);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kUseBestCircleRefinement", kUseBestCircleRefinement);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kUseBestCircleLargestCircle", kUseBestCircleLargestCircle);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleCannyLower", kBestCircleCannyLower);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleCannyUpper", kBestCircleCannyUpper);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCirclePreCannyBlurSize", kBestCirclePreCannyBlurSize);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCirclePreHoughBlurSize", kBestCirclePreHoughBlurSize);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleParam1", kBestCircleParam1);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleParam2", kBestCircleParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleHoughDpParam1", kBestCircleHoughDpParam1);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleIdentificationMinRadiusRatio", kBestCircleIdentificationMinRadiusRatio);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kBestCircleIdentificationMaxRadiusRatio", kBestCircleIdentificationMaxRadiusRatio);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kUseDynamicRadiiAdjustment", kUseDynamicRadiiAdjustment);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kNumberRadiiToAverageForDynamicAdjustment", kNumberRadiiToAverageForDynamicAdjustment);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedNarrowingRadiiMinRatio", kStrobedNarrowingRadiiMinRatio);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedNarrowingRadiiMaxRatio", kStrobedNarrowingRadiiMaxRatio);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedNarrowingRadiiDpParam", kStrobedNarrowingRadiiDpParam);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kStrobedNarrowingRadiiParam2", kStrobedNarrowingRadiiParam2);
+
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedNarrowingRadiiMinRatio", kPlacedNarrowingRadiiMinRatio);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedNarrowingRadiiMaxRatio", kPlacedNarrowingRadiiMaxRatio);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedNarrowingStartingParam2", kPlacedNarrowingStartingParam2);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kPlacedNarrowingRadiiDpParam", kPlacedNarrowingRadiiDpParam);
+
+ int kImageTypeToProcessWithYOLOAsInt = static_cast(kImageTypeToProcessWithYOLO);
+ GolfSimConfiguration::SetConstant("gs_config.ball_identification.kImageTypeToProcessWithYOLO", kImageTypeToProcessWithYOLOAsInt);
+ kImageTypeToProcessWithYOLO = static_cast(kImageTypeToProcessWithYOLOAsInt);
+
+ GolfSimConfiguration::SetConstant("gs_config.logging.kLogIntermediateSpinImagesToFile", kLogIntermediateSpinImagesToFile);
+
GS_LOG_MSG(info, "Model directory: " + kModelPath);
GS_LOG_MSG(info, "Detection method: " + kStrobedBallDetectionMethod);
GS_LOG_MSG(info, "Spin detection: " + kSpinDetectionMethod);
diff --git a/Software/LMSourceCode/ImageProcessing/ball_image_proc.h b/Software/LMSourceCode/ImageProcessing/ball_image_proc.h
index c420235b..71c396d7 100644
--- a/Software/LMSourceCode/ImageProcessing/ball_image_proc.h
+++ b/Software/LMSourceCode/ImageProcessing/ball_image_proc.h
@@ -140,8 +140,6 @@ class BallImageProc
static int kExternallyStrobedEnvMaximumSearchRadius;
static double kStrobedNarrowingRadiiDpParam;
static double kStrobedNarrowingRadiiParam2;
- static int kExternallyStrobedEnvNarrowingPreCannyBlurSize;
- static int kExternallyStrobedEnvNarrowingPreHoughBlurSize;
static bool kExternallyStrobedUseCLAHEProcessing;
static int kExternallyStrobedCLAHEClipLimit;
@@ -173,9 +171,6 @@ class BallImageProc
static double kBestCircleParam2;
static double kBestCircleHoughDpParam1;
- static double kExternallyStrobedBestCircleCannyLower;
- static double kExternallyStrobedBestCircleCannyUpper;
- static int kExternallyStrobedBestCirclePreCannyBlurSize;
static int kExternallyStrobedBestCirclePreHoughBlurSize;
static double kExternallyStrobedBestCircleParam1;
static double kExternallyStrobedBestCircleParam2;
diff --git a/Software/LMSourceCode/ImageProcessing/build.output.unix.txt b/Software/LMSourceCode/ImageProcessing/build.output.unix.txt
deleted file mode 100644
index ec5c1121..00000000
--- a/Software/LMSourceCode/ImageProcessing/build.output.unix.txt
+++ /dev/null
@@ -1,95 +0,0 @@
-ninja: Entering directory `build'
-[1/82] Generating core/version.cpp with a custom command
-[2/82] Generating copy_closed_source_object with a custom command
-Inserting Closed Source Object Files...
-[3/82] Compiling C++ object pitrac_lm.p/meson-generated_.._core_version.cpp.o
-[4/82] Compiling C++ object pitrac_lm.p/gs_globals.cpp.o
-[5/82] Compiling C++ object pitrac_lm.p/ED.cpp.o
-[6/82] Compiling C++ object pitrac_lm.p/EDPF.cpp.o
-[7/82] Compiling C++ object pitrac_lm.p/EDColor.cpp.o
-[8/82] Compiling C++ object pitrac_lm.p/ball_watcher_image_buffer.cpp.o
-[9/82] Compiling C++ object pitrac_lm.p/ball_watcher.cpp.o
-[10/82] Compiling C++ object pitrac_lm.p/libcamera_jpeg.cpp.o
-[11/82] Compiling C++ object pitrac_lm.p/colorsys.cpp.o
-[12/82] Compiling C++ object pitrac_lm.p/gs_test.cpp.o
-[13/82] Compiling C++ object pitrac_lm.p/gs_fsm.cpp.o
-[14/82] Compiling C++ object pitrac_lm.p/libcamera_interface.cpp.o
-[15/82] Compiling C++ object pitrac_lm.p/pulse_strobe.cpp.o
-[16/82] Compiling C++ object pitrac_lm.p/ball_image_proc.cpp.o
-[17/82] Compiling C++ object pitrac_lm.p/cv_utils.cpp.o
-[18/82] Compiling C++ object pitrac_lm.p/EllipseDetectorCommon.cpp.o
-[19/82] Compiling C++ object pitrac_lm.p/golf_ball.cpp.o
-[20/82] Compiling C++ object pitrac_lm.p/EllipseDetectorYaed.cpp.o
-In file included from ../EllipseDetectorYaed.cpp:15:
-../EllipseDetectorYaed.h: In constructor ‘golf_sim::CEllipseDetectorYaed::CEllipseDetectorYaed()’:
-../EllipseDetectorYaed.h:105:24: warning: ‘golf_sim::CEllipseDetectorYaed::_times’ will be initialized after [-Wreorder]
- 105 | vector _times; // _times is a vector containing the execution time of each step.
- | ^~~~~~
-../EllipseDetectorYaed.h:104:24: warning: ‘std::vector > golf_sim::CEllipseDetectorYaed::_timesHelper’ [-Wreorder]
- 104 | vector _timesHelper;
- | ^~~~~~~~~~~~
-../EllipseDetectorYaed.cpp:20:1: warning: when initialized here [-Wreorder]
- 20 | CEllipseDetectorYaed::CEllipseDetectorYaed(void) : _times(6, 0.0), _timesHelper(6, 0.0)
- | ^~~~~~~~~~~~~~~~~~~~
-[21/82] Compiling C++ object pitrac_lm.p/gs_options.cpp.o
-[22/82] Compiling C++ object pitrac_lm.p/gs_clubs.cpp.o
-[23/82] Compiling C++ object pitrac_lm.p/gs_camera.cpp.o
-[24/82] Compiling C++ object pitrac_lm.p/gs_gspro_response.cpp.o
-[25/82] Compiling C++ object pitrac_lm.p/gs_config.cpp.o
-[26/82] Compiling C++ object pitrac_lm.p/gs_sim_interface.cpp.o
-[27/82] Compiling C++ object pitrac_lm.p/gs_gspro_interface.cpp.o
-[28/82] Compiling C++ object pitrac_lm.p/gs_gspro_test_server.cpp.o
-[29/82] Compiling C++ object pitrac_lm.p/gs_e6_results.cpp.o
-[30/82] Compiling C++ object pitrac_lm.p/gs_e6_interface.cpp.o
-[31/82] Compiling C++ object pitrac_lm.p/logging_tools.cpp.o
-[32/82] Compiling C++ object pitrac_lm.p/gs_sim_socket_interface.cpp.o
-[33/82] Compiling C++ object pitrac_lm.p/worker_thread.cpp.o
-[34/82] Compiling C++ object pitrac_lm.p/gs_events.cpp.o
-[35/82] Compiling C++ object pitrac_lm.p/camera_hardware.cpp.o
-[36/82] Compiling C++ object pitrac_lm.p/gs_gspro_results.cpp.o
-[37/82] Compiling C++ object pitrac_lm.p/gs_ipc_message.cpp.o
-[38/82] Compiling C++ object pitrac_lm.p/gs_ipc_control_msg.cpp.o
-[39/82] Compiling C++ object pitrac_lm.p/gs_results.cpp.o
-[40/82] Compiling C++ object pitrac_lm.p/gs_ipc_mat.cpp.o
-[41/82] Compiling C++ object pitrac_lm.p/gs_ui_system.cpp.o
-[42/82] Compiling C++ object pitrac_lm.p/gs_ipc_result.cpp.o
-[43/82] Compiling C++ object pitrac_lm.p/core_buffer_sync.cpp.o
-[44/82] Compiling C++ object pitrac_lm.p/core_dma_heaps.cpp.o
-[45/82] Compiling C++ object pitrac_lm.p/gs_ipc_test.cpp.o
-[46/82] Compiling C++ object pitrac_lm.p/gs_ipc_system.cpp.o
-[47/82] Compiling C++ object pitrac_lm.p/gs_message_consumer.cpp.o
-[48/82] Compiling C++ object pitrac_lm.p/core_post_processor.cpp.o
-[49/82] Compiling C++ object pitrac_lm.p/gs_message_producer.cpp.o
-[50/82] Compiling C++ object pitrac_lm.p/core_options.cpp.o
-[51/82] Compiling C++ object pitrac_lm.p/encoder_encoder.cpp.o
-[52/82] Compiling C++ object pitrac_lm.p/encoder_h264_encoder.cpp.o
-[53/82] Compiling C++ object pitrac_lm.p/encoder_mjpeg_encoder.cpp.o
-[54/82] Compiling C++ object pitrac_lm.p/image_bmp.cpp.o
-[55/82] Compiling C++ object pitrac_lm.p/encoder_libav_encoder.cpp.o
-[56/82] Compiling C++ object pitrac_lm.p/core_rpicam_app.cpp.o
-[57/82] Compiling C++ object pitrac_lm.p/encoder_null_encoder.cpp.o
-[58/82] Compiling C++ object pitrac_lm.p/image_dng.cpp.o
-[59/82] Compiling C++ object pitrac_lm.p/image_png.cpp.o
-[60/82] Compiling C++ object pitrac_lm.p/image_jpeg.cpp.o
-[61/82] Compiling C++ object pitrac_lm.p/output_circular_output.cpp.o
-[62/82] Compiling C++ object pitrac_lm.p/output_file_output.cpp.o
-[63/82] Compiling C++ object pitrac_lm.p/image_yuv.cpp.o
-[64/82] Compiling C++ object pitrac_lm.p/output_net_output.cpp.o
-[65/82] Compiling C++ object pitrac_lm.p/output_output.cpp.o
-[66/82] Compiling C++ object pitrac_lm.p/preview_null_preview.cpp.o
-[67/82] Compiling C++ object pitrac_lm.p/preview_preview.cpp.o
-[68/82] Compiling C++ object pitrac_lm.p/post_processing_stages_histogram.cpp.o
-[69/82] Compiling C++ object pitrac_lm.p/preview_drm_preview.cpp.o
-[70/82] Compiling C++ object pitrac_lm.p/preview_egl_preview.cpp.o
-[71/82] Compiling C++ object pitrac_lm.p/post_processing_stages_pwl.cpp.o
-[72/82] Compiling C++ object pitrac_lm.p/post_processing_stages_negate_stage.cpp.o
-[73/82] Compiling C++ object pitrac_lm.p/preview_qt_preview.cpp.o
-[74/82] Compiling C++ object pitrac_lm.p/post_processing_stages_post_processing_stage.cpp.o
-[75/82] Compiling C++ object pitrac_lm.p/post_processing_stages_hdr_stage.cpp.o
-[76/82] Compiling C++ object pitrac_lm.p/post_processing_stages_sobel_cv_stage.cpp.o
-[77/82] Compiling C++ object pitrac_lm.p/post_processing_stages_annotate_cv_stage.cpp.o
-[78/82] Compiling C++ object pitrac_lm.p/post_processing_stages_plot_pose_cv_stage.cpp.o
-[79/82] Compiling C++ object pitrac_lm.p/post_processing_stages_face_detect_cv_stage.cpp.o
-[80/82] Compiling C++ object pitrac_lm.p/post_processing_stages_object_detect_draw_cv_stage.cpp.o
-[81/82] Compiling C++ object pitrac_lm.p/post_processing_stages_motion_detect_stage.cpp.o
-[82/82] Linking target pitrac_lm
diff --git a/Software/LMSourceCode/ImageProcessing/camera_hardware.cpp b/Software/LMSourceCode/ImageProcessing/camera_hardware.cpp
index dbf930ca..b8223e57 100644
--- a/Software/LMSourceCode/ImageProcessing/camera_hardware.cpp
+++ b/Software/LMSourceCode/ImageProcessing/camera_hardware.cpp
@@ -91,7 +91,7 @@ namespace golf_sim {
{ "100", CameraModel::kCameraUnknown },
};
if (camera_table.count(model_enum_value_string) == 0)
- throw std::runtime_error("Invalid camera model_enum_value_string: " + model_enum_value_string + ". Expected an integer. Check environment variables.");
+ throw std::runtime_error("Invalid camera model_enum_value_string: " + model_enum_value_string + ". Expected an integer. Check the cameras.slotN.type setting.");
CameraHardware::CameraModel camera_model = (CameraHardware::CameraModel)camera_table[model_enum_value_string];
@@ -107,7 +107,7 @@ namespace golf_sim {
{ "100", LensType::kLensUnknown },
};
if (lens_table.count(lens_enum_value_string) == 0)
- throw std::runtime_error("Invalid camera lens_enum_value_string: " + lens_enum_value_string + ". Expected an integer. Check environment variables.");
+ throw std::runtime_error("Invalid camera lens_enum_value_string: " + lens_enum_value_string + ". Expected an integer. Check the cameras.slotN.lens setting.");
CameraHardware::LensType lens_type = (CameraHardware::LensType)lens_table[lens_enum_value_string];
@@ -123,7 +123,7 @@ namespace golf_sim {
{ "100", CameraOrientation::kCameraOrientationUnknown },
};
if (orientation_table.count(lens_enum_value_string) == 0)
- throw std::runtime_error("Invalid camera lens_enum_value_string: " + lens_enum_value_string + ". Expected an integer. Check environment variables.");
+ throw std::runtime_error("Invalid camera lens_enum_value_string: " + lens_enum_value_string + ". Expected an integer. Check the cameras.slotN.orientation setting.");
CameraHardware::CameraOrientation orientation_type = (CameraHardware::CameraOrientation)orientation_table[lens_enum_value_string];
@@ -265,11 +265,11 @@ namespace golf_sim {
GS_LOG_TRACE_MSG(trace, "Video resolution (x,y) is: " + std::to_string(video_resolution_x_) + "/" + std::to_string(video_resolution_y_) + ".");
// Attempt to get the expected ball radius from the .json file
- std::string ball_radius_pixels_at_40cm_name = "kExpectedBallRadiusPixelsAt40cmCamera" + std::string(camera_number == GsCameraNumber::kGsCamera1 ? "1" : "2");
+ std::string ball_radius_pixels_at_40cm_name = camera_number == GsCameraNumber::kGsCamera1 ? "gs_config.cameras.kExpectedBallRadiusPixelsAt40cmCamera1" : "gs_config.cameras.kExpectedBallRadiusPixelsAt40cmCamera2";
int expected_ball_radius_pixels_at_40cm_from_config_file = -1;
- GolfSimConfiguration::SetConstant("gs_config.cameras." + ball_radius_pixels_at_40cm_name, expected_ball_radius_pixels_at_40cm_from_config_file);
+ GolfSimConfiguration::SetConstant(ball_radius_pixels_at_40cm_name, expected_ball_radius_pixels_at_40cm_from_config_file);
// The default will be used unless the .json file has a value, in which case that value will be used.
@@ -290,12 +290,13 @@ namespace golf_sim {
camera_distortion_values.cols,
camera_distortion_values.type());
- std::string calibration_element_name = "kCamera" + std::to_string((int)camera_number_) + "CalibrationMatrix";
- std::string distortion_element_name = "kCamera" + std::to_string((int)camera_number_) + "DistortionVector";
+ const bool is_camera1 = camera_number_ == GsCameraNumber::kGsCamera1;
+ std::string calibration_element_name = is_camera1 ? "gs_config.cameras.kCamera1CalibrationMatrix" : "gs_config.cameras.kCamera2CalibrationMatrix";
+ std::string distortion_element_name = is_camera1 ? "gs_config.cameras.kCamera1DistortionVector" : "gs_config.cameras.kCamera2DistortionVector";
- if (GolfSimConfiguration::PropertyExists("gs_config.cameras." + calibration_element_name) ) {
- GolfSimConfiguration::SetConstant("gs_config.cameras." + calibration_element_name, camera_calibration_matrix_values);
- GolfSimConfiguration::SetConstant("gs_config.cameras." + distortion_element_name, camera_distortion_values);
+ if (GolfSimConfiguration::PropertyExists(calibration_element_name) ) {
+ GolfSimConfiguration::SetConstant(calibration_element_name, camera_calibration_matrix_values);
+ GolfSimConfiguration::SetConstant(distortion_element_name, camera_distortion_values);
}
bool calibration_information_is_valid = (camera_calibration_matrix_values.at(0,0) != 0.0) &&
@@ -478,24 +479,18 @@ namespace golf_sim {
// Only if we are using a custom focal length, then use that length
if (lens_type == Lens_Custom) {
- tag = "gs_config.cameras.kSlot" + std::to_string(camera_number_) + "CustomLensFocalLength";
- if (GolfSimConfiguration::PropertyExists(tag)) {
- GolfSimConfiguration::SetConstant(tag, focal_length_);
- GS_LOG_TRACE_MSG(trace, "Setting custom focal length (from JSON file) = " + std::to_string(focal_length_));
- }
+ tag = camera_number_ == GsCameraNumber::kGsCamera1 ? "cameras.kSlot1CustomLensFocalLength" : "cameras.kSlot2CustomLensFocalLength";
}
else {
// Otherwise, for non-custom lenses, just use the standard focal length parameter
- tag = "gs_config.cameras.kCamera" + std::to_string(camera_number_) + "FocalLength";
- if (GolfSimConfiguration::PropertyExists(tag)) {
- GolfSimConfiguration::SetConstant(tag, focal_length_);
- GS_LOG_TRACE_MSG(trace, "Setting focal length (from JSON file) = " + std::to_string(focal_length_));
- }
+ tag = camera_number_ == GsCameraNumber::kGsCamera1 ? "gs_config.cameras.kCamera1FocalLength" : "gs_config.cameras.kCamera2FocalLength";
}
+ GolfSimConfiguration::SetConstant(tag, focal_length_);
+ GS_LOG_TRACE_MSG(trace, "Focal length = " + std::to_string(focal_length_));
}
- tag = "gs_config.cameras.kCamera" + std::to_string(camera_number_) + "Angles";
+ tag = camera_number_ == GsCameraNumber::kGsCamera1 ? "gs_config.cameras.kCamera1Angles" : "gs_config.cameras.kCamera2Angles";
GolfSimConfiguration::SetConstant(tag, camera_angles_);
cameraInitialized = true;
diff --git a/Software/LMSourceCode/ImageProcessing/configuration_manager.cpp b/Software/LMSourceCode/ImageProcessing/configuration_manager.cpp
deleted file mode 100644
index 463b5e14..00000000
--- a/Software/LMSourceCode/ImageProcessing/configuration_manager.cpp
+++ /dev/null
@@ -1,509 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (C) 2022-2025, Verdant Consultants, LLC.
- */
-
-#include "configuration_manager.h"
-#include "logging_tools.h"
-#include
-#include
-#include
-#include
-
-// Helper function to merge property trees (user overrides defaults)
-namespace {
- void merge_ptree(const boost::property_tree::ptree& from, boost::property_tree::ptree& to) {
- for (const auto& [key, value] : from) {
- if (value.empty()) {
- // Leaf node - copy value
- to.put(key, value.data());
- } else {
- // Non-leaf node - recursive merge
- auto child = to.get_child_optional(key);
- if (child) {
- boost::property_tree::ptree merged = *child;
- merge_ptree(value, merged);
- to.put_child(key, merged);
- } else {
- to.put_child(key, value);
- }
- }
- }
- }
-
- // Helper function to convert YAML to property tree
- void yaml_to_ptree(const YAML::Node& node, boost::property_tree::ptree& pt, const std::string& key = "") {
- if (node.IsScalar()) {
- pt.put(key, node.as());
- } else if (node.IsSequence()) {
- for (size_t i = 0; i < node.size(); ++i) {
- yaml_to_ptree(node[i], pt, key + "." + std::to_string(i));
- }
- } else if (node.IsMap()) {
- for (const auto& it : node) {
- std::string child_key = key.empty() ? it.first.as() : key + "." + it.first.as();
- yaml_to_ptree(it.second, pt, child_key);
- }
- }
- }
-
- // Helper function to load YAML file to property tree
- void load_yaml_to_ptree(const std::string& filename, boost::property_tree::ptree& pt) {
- try {
- YAML::Node yaml_node = YAML::LoadFile(filename);
- yaml_to_ptree(yaml_node, pt);
- } catch (const YAML::Exception& e) {
- throw std::runtime_error("Failed to load YAML file: " + std::string(e.what()));
- }
- }
-}
-
-namespace golf_sim {
-
-bool ConfigurationManager::Initialize(
- const std::string& json_config_file,
- const std::string& yaml_config_file,
- const std::map& cli_overrides) {
-
- GS_LOG_TRACE_MSG(trace, "Initializing ConfigurationManager");
-
- json_config_file_ = json_config_file;
-
- // Load system defaults from golf_sim_config.json
- if (std::filesystem::exists(json_config_file)) {
- try {
- boost::property_tree::read_json(json_config_file, json_config_);
- GS_LOG_MSG(info, "Loaded system defaults from: " + json_config_file);
- } catch (const boost::property_tree::json_parser_error& e) {
- GS_LOG_MSG(error, "Failed to parse system config: " + std::string(e.what()));
- return false;
- }
- } else {
- GS_LOG_MSG(warning, "System configuration file not found: " + json_config_file);
- }
-
- // Load user settings from user_settings.json (new JSON-only approach)
- std::string user_settings_file = std::string(std::getenv("HOME") ? std::getenv("HOME") : "") + "/.pitrac/config/user_settings.json";
-
- if (std::filesystem::exists(user_settings_file)) {
- try {
- boost::property_tree::ptree user_settings;
- boost::property_tree::read_json(user_settings_file, user_settings);
-
- // Merge user settings into json_config (user overrides defaults)
- merge_ptree(user_settings, json_config_);
-
- GS_LOG_MSG(info, "Loaded user settings from: " + user_settings_file);
- } catch (const boost::property_tree::json_parser_error& e) {
- GS_LOG_MSG(error, "Failed to parse user settings: " + std::string(e.what()));
- // Continue with defaults if user settings are corrupt
- }
- } else {
- GS_LOG_MSG(debug, "No user settings found at: " + user_settings_file);
- }
-
- // DEPRECATED: Support legacy YAML for migration period only
- // This will be removed in future versions
- if (!yaml_config_file.empty() && yaml_config_file != "none") {
- std::string yaml_file = yaml_config_file;
- if (yaml_file.empty()) {
- // Check for legacy YAML in old locations
- const std::vector yaml_locations = {
- std::string(std::getenv("HOME") ? std::getenv("HOME") : "") + "/.pitrac/config/pitrac.yaml",
- "/etc/pitrac/pitrac.yaml"
- };
-
- for (const auto& location : yaml_locations) {
- if (std::filesystem::exists(location)) {
- GS_LOG_MSG(warning, "Found legacy YAML config at: " + location);
- GS_LOG_MSG(warning, "Please run 'pitrac config migrate-to-json' to convert to new format");
- break;
- }
- }
- }
- }
-
- // Apply CLI overrides
- for (const auto& [key, value] : cli_overrides) {
- SetOverride(key, value);
- }
-
- // Check if a preset is specified
- std::string preset = GetString("_preset", "");
- if (!preset.empty()) {
- ApplyPreset(preset);
- }
-
- return true;
-}
-
-std::string ConfigurationManager::GetString(const std::string& key, const std::string& default_value) const {
- return GetValue(key, default_value);
-}
-
-int ConfigurationManager::GetInt(const std::string& key, int default_value) const {
- std::string str_val = GetString(key, std::to_string(default_value));
- try {
- return std::stoi(str_val);
- } catch (...) {
- return default_value;
- }
-}
-
-float ConfigurationManager::GetFloat(const std::string& key, float default_value) const {
- std::string str_val = GetString(key, std::to_string(default_value));
- try {
- return std::stof(str_val);
- } catch (...) {
- return default_value;
- }
-}
-
-bool ConfigurationManager::GetBool(const std::string& key, bool default_value) const {
- std::string str_val = GetString(key, default_value ? "true" : "false");
-
- // Handle various boolean representations
- if (str_val == "true" || str_val == "1" || str_val == "yes" || str_val == "on") {
- return true;
- }
- if (str_val == "false" || str_val == "0" || str_val == "no" || str_val == "off") {
- return false;
- }
-
- return default_value;
-}
-
-void ConfigurationManager::SetOverride(const std::string& key, const std::string& value) {
- std::lock_guard lock(config_mutex_);
- SetInTree(cli_overrides_, key, value);
-}
-
-bool ConfigurationManager::HasKey(const std::string& key) const {
- if (GetFromTree(cli_overrides_, key).has_value()) return true;
- if (GetFromTree(yaml_config_, key).has_value()) return true;
-
- std::string json_path = MapToJsonPath(key);
- if (GetFromTree(json_config_, json_path).has_value()) return true;
-
- return false;
-}
-
-std::string ConfigurationManager::GetJsonPath(const std::string& yaml_key) const {
- return MapToJsonPath(yaml_key);
-}
-
-bool ConfigurationManager::ApplyPreset(const std::string& preset_name) {
- try {
- auto preset = presets_.get_child_optional("presets." + preset_name);
- if (!preset) {
- GS_LOG_MSG(warning, "Preset not found: " + preset_name);
- return false;
- }
-
- GS_LOG_MSG(info, "Applying preset: " + preset_name);
-
- // Apply preset settings
- auto settings = preset->get_child_optional("settings");
- if (settings) {
- for (const auto& [key, value] : *settings) {
- std::string val = value.get_value();
- SetInTree(yaml_config_, key, val);
- }
- }
-
- return true;
- } catch (const std::exception& e) {
- GS_LOG_MSG(error, "Failed to apply preset: " + std::string(e.what()));
- return false;
- }
-}
-
-bool ConfigurationManager::ValidateConfiguration() const {
- validation_errors_.clear();
- bool valid = true;
-
- // Validate all YAML settings against schema
- for (const auto& [key, value] : yaml_config_) {
- std::string str_val = value.get_value();
- if (!ValidateValue(key, str_val)) {
- valid = false;
- }
- }
-
- // Validate CLI overrides
- for (const auto& [key, value] : cli_overrides_) {
- std::string str_val = value.get_value();
- if (!ValidateValue(key, str_val)) {
- valid = false;
- }
- }
-
- return valid;
-}
-
-std::vector ConfigurationManager::GetValidationErrors() const {
- return validation_errors_;
-}
-
-bool ConfigurationManager::ExportEffectiveConfig(const std::string& output_file, const std::string& format) const {
- try {
- boost::property_tree::ptree effective_config;
-
- // Build effective configuration by merging all tiers
- // Start with JSON defaults
- effective_config = json_config_;
-
- // Apply YAML overrides
- for (const auto& [key, value] : yaml_config_) {
- std::string json_path = MapToJsonPath(key);
- SetInTree(effective_config, json_path, value.get_value());
- }
-
- // Apply CLI overrides
- for (const auto& [key, value] : cli_overrides_) {
- std::string json_path = MapToJsonPath(key);
- SetInTree(effective_config, json_path, value.get_value());
- }
-
- // Export in requested format
- if (format == "json") {
- boost::property_tree::write_json(output_file, effective_config);
- } else if (format == "yaml") {
- // For now, export as JSON when yaml is requested
- // TODO: Implement proper YAML export using yaml-cpp
- GS_LOG_MSG(warning, "YAML export not yet implemented, exporting as JSON instead");
- boost::property_tree::write_json(output_file, effective_config);
- } else {
- GS_LOG_MSG(error, "Unknown export format: " + format);
- return false;
- }
-
- return true;
- } catch (const std::exception& e) {
- GS_LOG_MSG(error, "Failed to export configuration: " + std::string(e.what()));
- return false;
- }
-}
-
-std::string ConfigurationManager::GetValueSource(const std::string& key) const {
- if (GetFromTree(cli_overrides_, key).has_value()) {
- return "cli";
- }
- if (GetFromTree(yaml_config_, key).has_value()) {
- return "yaml";
- }
-
- std::string json_path = MapToJsonPath(key);
- if (GetFromTree(json_config_, json_path).has_value()) {
- return "json";
- }
-
- return "not_found";
-}
-
-bool ConfigurationManager::Reload() {
- GS_LOG_MSG(info, "Reloading configuration");
-
- // Clear existing configuration
- json_config_.clear();
- yaml_config_.clear();
- // Keep CLI overrides
-
- // Reload files
- return Initialize(json_config_file_, yaml_config_file_, {});
-}
-
-bool ConfigurationManager::LoadMappings(const std::string& mappings_file) {
- try {
- load_yaml_to_ptree(mappings_file, mappings_);
-
- // Extract presets if present
- auto presets = mappings_.get_child_optional("presets");
- if (presets) {
- presets_ = *presets;
- }
-
- // Build reverse mapping cache
- BuildReverseMappingCache();
-
- GS_LOG_MSG(info, "Loaded parameter mappings from: " + mappings_file);
- return true;
- } catch (const std::exception& e) {
- GS_LOG_MSG(error, "Failed to load mappings: " + std::string(e.what()));
- return false;
- }
-}
-
-std::string ConfigurationManager::MapToJsonPath(const std::string& yaml_key) const {
- try {
- // Look up mapping
- auto mapping = mappings_.get_child_optional("mappings." + yaml_key);
- if (mapping) {
- auto json_path = mapping->get_optional("json_path");
- if (json_path) {
- return *json_path;
- }
- }
- } catch (...) {
- // Ignore and return original key
- }
-
- // No mapping found, return original key
- return yaml_key;
-}
-
-std::string ConfigurationManager::MapToYamlKey(const std::string& json_path) const {
- // First check the cache
- auto it = json_to_yaml_map_.find(json_path);
- if (it != json_to_yaml_map_.end()) {
- return it->second;
- }
-
- // No mapping found, return original path
- return json_path;
-}
-
-void ConfigurationManager::BuildReverseMappingCache() {
- json_to_yaml_map_.clear();
-
- try {
- auto mappings = mappings_.get_child_optional("mappings");
- if (!mappings) {
- return;
- }
-
- // Iterate through all mappings and build reverse map
- for (const auto& [yaml_key, mapping_node] : *mappings) {
- auto json_path = mapping_node.get_optional("json_path");
- if (json_path) {
- // Store the reverse mapping: JSON path -> YAML key
- json_to_yaml_map_[*json_path] = yaml_key;
- GS_LOG_TRACE_MSG(trace, "Reverse mapping: " + *json_path + " -> " + yaml_key);
- }
- }
-
- GS_LOG_MSG(debug, "Built reverse mapping cache with " + std::to_string(json_to_yaml_map_.size()) + " entries");
- } catch (const std::exception& e) {
- GS_LOG_MSG(warning, "Failed to build reverse mapping cache: " + std::string(e.what()));
- }
-}
-
-std::string ConfigurationManager::ConvertToJson(const std::string& yaml_key, const std::string& value) const {
- try {
- auto mapping = mappings_.get_child_optional("mappings." + yaml_key);
- if (mapping) {
- auto to_json = mapping->get_optional("to_json");
- if (to_json) {
- // Simple conversion for boolean to "0"/"1"
- if (*to_json == "value ? \"1\" : \"0\"") {
- return (value == "true" || value == "1") ? "1" : "0";
- }
- }
- }
- } catch (...) {
- // Ignore and return original value
- }
-
- return value;
-}
-
-std::string ConfigurationManager::ConvertFromJson(const std::string& yaml_key, const std::string& value) const {
- try {
- auto mapping = mappings_.get_child_optional("mappings." + yaml_key);
- if (mapping) {
- auto from_json = mapping->get_optional("from_json");
- if (from_json) {
- // Simple conversion for "0"/"1" to boolean
- if (*from_json == "value == \"1\"") {
- return value == "1" ? "true" : "false";
- }
- }
- }
- } catch (...) {
- // Ignore and return original value
- }
-
- return value;
-}
-
-std::string ConfigurationManager::ExpandPath(const std::string& path) const {
- if (path.empty() || path[0] != '~') {
- return path;
- }
-
- const char* home = std::getenv("HOME");
- if (!home) {
- return path;
- }
-
- return std::string(home) + path.substr(1);
-}
-
-bool ConfigurationManager::ValidateValue(const std::string& key, const std::string& value) const {
- try {
- auto mapping = mappings_.get_child_optional("mappings." + key);
- if (!mapping) {
- return true; // No validation rules, assume valid
- }
-
- auto validation = mapping->get_child_optional("validation");
- if (!validation) {
- return true; // No validation rules
- }
-
- // Check enum values
- auto enum_values = validation->get_child_optional("enum");
- if (enum_values) {
- bool found = false;
- for (const auto& [_, enum_val] : *enum_values) {
- if (enum_val.get_value() == value) {
- found = true;
- break;
- }
- }
- if (!found) {
- validation_errors_.push_back(key + ": value '" + value + "' not in allowed values");
- return false;
- }
- }
-
- // Check min/max for numeric values
- auto min = validation->get_optional("min");
- auto max = validation->get_optional("max");
-
- if (min || max) {
- try {
- float num_val = std::stof(value);
-
- if (min && num_val < *min) {
- validation_errors_.push_back(key + ": value " + value + " below minimum " + std::to_string(*min));
- return false;
- }
-
- if (max && num_val > *max) {
- validation_errors_.push_back(key + ": value " + value + " above maximum " + std::to_string(*max));
- return false;
- }
- } catch (...) {
- validation_errors_.push_back(key + ": value '" + value + "' is not numeric");
- return false;
- }
- }
-
- // Check pattern (regex)
- auto pattern = validation->get_optional("pattern");
- if (pattern) {
- std::regex re(*pattern);
- if (!std::regex_match(value, re)) {
- validation_errors_.push_back(key + ": value '" + value + "' does not match pattern");
- return false;
- }
- }
-
- return true;
- } catch (...) {
- return true; // Ignore validation errors
- }
-}
-
-} // namespace golf_sim
\ No newline at end of file
diff --git a/Software/LMSourceCode/ImageProcessing/configuration_manager.h b/Software/LMSourceCode/ImageProcessing/configuration_manager.h
deleted file mode 100644
index 1f327b11..00000000
--- a/Software/LMSourceCode/ImageProcessing/configuration_manager.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (C) 2022-2025, Verdant Consultants, LLC.
- */
-
-#pragma once
-
-#include
-#include
-#include
-#include
-#include
-#include