Optimized Belief Propagation (CPU and GPU)
BpSettings.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2024 Scott Grauer-Gray
3 
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18 
28 #ifndef BP_SETTINGS_H_
29 #define BP_SETTINGS_H_
30 
31 #include <vector>
32 #include <string>
33 #include <string_view>
35 #include "RunEval/RunData.h"
36 #include "BpConstsEnumsAliases.h"
37 #include "BpRunUtils.h"
38 
45 template <typename T>
46 concept Params_t =
47  requires(T t) {
48  { t.AsRunData() } -> std::same_as<RunData>;
49  };
50 
55 namespace beliefprop {
56 
57 //constants for headers corresponding to belief propagation settings in evaluation
58 constexpr std::string_view kNumDispValsHeader{"Num Possible Disparity Values"};
59 constexpr std::string_view kNumBpLevelsHeader{"Num BP Levels",};
60 constexpr std::string_view kNumBpItersHeader{"Num BP Iterations"};
61 constexpr std::string_view kDiscCostCapHeader{"DISC_K_BP"};
62 constexpr std::string_view kDataCostCapHeader{"DataKBp"};
63 constexpr std::string_view kBpSettingsLambdaHeader{"LambdaBp"};
64 constexpr std::string_view kBpSettingsSigmaHeader{"SigmaBp"};
65 
68 constexpr unsigned int kDefaultLevelsBp{5};
69 
71 constexpr unsigned int kDefaultItersBp{7};
72 
74 constexpr float kDefaultSigmaBp{0.0};
75 
77 constexpr float kDefaultLambdaBp{0.1};
78 
80 constexpr float kDefaultDataKBp{15.0};
81 
86 struct BpSettings
87 {
88  //initally set to default values
94 
98  float disc_k_bp{beliefprop::kHighValBp<float>};
99 
101  unsigned int num_disp_vals{0};
102 
109  RunData AsRunData() const {
110  RunData curr_run_data;
111  curr_run_data.AddDataWHeader(std::string(kNumDispValsHeader), num_disp_vals);
112  curr_run_data.AddDataWHeader(std::string(kNumBpLevelsHeader), num_levels);
113  curr_run_data.AddDataWHeader(std::string(kNumBpItersHeader), num_iterations);
114  curr_run_data.AddDataWHeader(std::string(kDiscCostCapHeader), (double)disc_k_bp);
115  curr_run_data.AddDataWHeader(std::string(kDataCostCapHeader), (double)data_k_bp);
116  curr_run_data.AddDataWHeader(std::string(kBpSettingsLambdaHeader), (double)lambda_bp);
117  curr_run_data.AddDataWHeader(std::string(kBpSettingsSigmaHeader), (double)smoothing_sigma);
118 
119  return curr_run_data;
120  }
121 };
122 
123 }
124 
125 #endif //BP_SETTINGS_H_
File with namespace for enums, constants, structures, and functions specific to belief propagation pr...
File with namespace for enums, constants, structures, and functions specific to belief propagation pr...
concept Params_t
Parameters type requires AsRunData() function to return the parameters as a RunData object.
Definition: BpSettings.h:46
Declares class for defining input signature for evaluation run that consists of evaluation set number...
Declares class to store headers with data corresponding to current program run and evaluation.
Class to store headers with data corresponding to current program run and evaluation.
Definition: RunData.h:42
void AddDataWHeader(const std::string &header, const std::string &data)
Add string data with header describing added data.
Definition: RunData.cpp:49
Namespace for enums, constants, structures, and functions specific to belief propagation processing.
constexpr unsigned int kDefaultItersBp
Default number of BP iterations at each scale/level.
Definition: BpSettings.h:71
constexpr float kDefaultSigmaBp
Default sigma value for smoothing input images.
Definition: BpSettings.h:74
constexpr std::string_view kDataCostCapHeader
Definition: BpSettings.h:62
constexpr std::string_view kBpSettingsLambdaHeader
Definition: BpSettings.h:63
constexpr std::string_view kNumDispValsHeader
Definition: BpSettings.h:58
constexpr std::string_view kNumBpLevelsHeader
Definition: BpSettings.h:59
constexpr std::string_view kDiscCostCapHeader
Definition: BpSettings.h:61
constexpr float kDefaultLambdaBp
Default weighing of data cost.
Definition: BpSettings.h:77
constexpr unsigned int kDefaultLevelsBp
Default values for BP settings. Number of scales/levels in the pyramid to run BP.
Definition: BpSettings.h:68
constexpr std::string_view kNumBpItersHeader
Definition: BpSettings.h:60
constexpr std::string_view kBpSettingsSigmaHeader
Definition: BpSettings.h:64
constexpr float kDefaultDataKBp
Default truncation of data cost.
Definition: BpSettings.h:80
Structure to store the belief propagation settings including the number of levels and iterations.
Definition: BpSettings.h:87
RunData AsRunData() const
Retrieve bp settings as RunData object containing description headers with corresponding values for e...
Definition: BpSettings.h:109
unsigned int num_iterations
Definition: BpSettings.h:90
unsigned int num_disp_vals
Number of disparity values must be set for each stereo set.
Definition: BpSettings.h:101
unsigned int num_levels
Definition: BpSettings.h:89
float disc_k_bp
Discontinuity cost cap set to high value by default but is expected to be dependent on number of disp...
Definition: BpSettings.h:98