28 #ifndef RUNBPSTEREOSET_H_
29 #define RUNBPSTEREOSET_H_
33 #include <unordered_map>
74 template <RunData_t T,
unsigned int DISP_VALS, run_environment::AccSetting ACCELERATION>
77 const std::unique_ptr<ProcessBp<T, DISP_VALS, ACCELERATION>>&
run_bp_stereo;
92 template <RunData_t T,
unsigned int DISP_VALS, run_environment::AccSetting ACCELERATION>
112 const std::array<std::string, 2>& ref_test_image_path,
129 const std::array<std::string, 2>& ref_test_image_path,
137 template<RunData_t T,
unsigned int DISP_VALS, run_environment::AccSetting ACCELERATION>
139 const std::array<std::string, 2>& ref_test_image_path,
144 const std::array<BpImage<unsigned int>, 2> input_images{
147 const std::array<unsigned int, 2> width_height_images{
148 input_images[0].
Width(),
149 input_images[0].Height()};
152 const unsigned int tot_num_pixels_images{
153 width_height_images[0] * width_height_images[1]};
156 std::unordered_map<beliefprop::Runtime_Type, std::array<timingType, 2>>
157 runtime_start_end_timings;
165 T* bp_proc_store{
nullptr};
168 const std::size_t num_data =
178 if (run_bp_on_device.
run_bp_stereo->ErrorCheck(__FILE__, __LINE__) !=
181 BpLevel<T> bottom_bp_level(width_height_images, 0, 0, ACCELERATION);
182 const std::size_t total_data_bottom_level =
186 total_data_bottom_level,
188 if (run_bp_on_device.
run_bp_stereo->ErrorCheck(__FILE__, __LINE__) !=
193 const unsigned int num_evaluation_runs{
195 for (
unsigned int num_run = 0;
196 num_run < num_evaluation_runs;
200 std::array<float*, 2> smoothed_images{
202 tot_num_pixels_images),
204 tot_num_pixels_images)};
206 if (run_bp_on_device.
run_bp_stereo->ErrorCheck(__FILE__, __LINE__) !=
215 std::chrono::system_clock::now();
217 std::chrono::system_clock::now();
219 std::chrono::system_clock::now();
223 for (
unsigned int i = 0; i < 2; i++) {
228 if (run_bp_on_device.
run_bp_stereo->ErrorCheck(__FILE__, __LINE__) !=
238 std::chrono::system_clock::now();
242 std::chrono::system_clock::now();
247 auto bp_stereo_output =
255 if (!bp_stereo_output) {
262 const auto& [bp_disparity_map, bp_run_timings] = *bp_stereo_output;
266 std::chrono::system_clock::now();
268 std::chrono::system_clock::now();
275 tot_num_pixels_images);
279 std::chrono::system_clock::now();
282 std::ranges::for_each(runtime_start_end_timings,
283 [&detailed_bp_timings](
const auto& current_runtime_name_timing) {
285 current_runtime_name_timing.first,
286 current_runtime_name_timing.second[1] - current_runtime_name_timing.second[0]);
295 for (
auto& smoothed_image : smoothed_images) {
311 width_height_images[0]);
314 width_height_images[1]);
317 num_evaluation_runs);
325 std::move(output_disparity_map),
326 std::move(run_data)}};
File with namespace for enums, constants, structures, and functions specific to belief propagation pr...
Header file that contains information about the stereo sets used for evaluation of the bp implementat...
Declares class to define images that are used in bp processing.
Constants for timing belief propagation implementation.
Declares class to store timings of one or more segments taken during the run(s) of an implementation ...
Declares child class of BpImage to define disparity map image that is output from bp processing.
Declares class for memory management with functions defined for standard memory allocation using CPU ...
Declares child class of ParallelParams to store and process parallelization parameters to use in each...
Declares abstract class to run belief propagation on target device. Some of the class functions need ...
Declares class to store headers with data corresponding to current program run and evaluation.
Contains namespace with enums and constants for implementation run evaluation.
Declares and defines structure that stores settings for current implementation run as well as functio...
Define constraints for data type in processing.
Declares class for smoothing the images before running BP.
Class to define images that are used in bp processing.
unsigned int Width() const
T * PointerToPixelsStart() const
Class to store and retrieve properties of a bp processing level including a data type specified as a ...
std::size_t NumDataInBpArrays(unsigned int num_disparity_values) const
Get the amount of data in each BP array (data cost/messages for each checkerboard) at the current lev...
static std::size_t TotalDataForAlignedMemoryAllLevels(const std::array< unsigned int, 2 > &width_height_bottom_level, unsigned int num_possible_disparities, unsigned int num_levels, run_environment::AccSetting acceleration)
Static function to get count of total data needed for bp processing at all levels.
Class to store timings of one or more segments taken during the run(s) of an implementation or across...
std::chrono::duration< double > MedianTiming(const T run_segment_index) const
Get median timing for a specified segment that may have been run multiple times.
void AddToCurrentTimings(const DetailedTimings &in_detailed_timings)
Add instance of DetailedTimings to current DetailedTimings.
RunData AsRunData() const
Return current timing data as a RunData object for evaluation.
void AddTiming(const T timing_segment, const std::chrono::duration< double > &segment_time)
Add timing by segment index.
Abstract class for holding and processing parallelization parameters. Child class(es) specific to im...
Abstract class to set up and run belief propagation on target device using specified acceleration.
std::optional< beliefprop::BpRunOutput > ProcessStereoSet(const std::array< std::string, 2 > &ref_test_image_path, const beliefprop::BpSettings &alg_settings, const beliefprop::BpOnDevice< T, DISP_VALS, ACCELERATION > &run_bp_on_device) const
Protected function to set up, run, and evaluate bp processing on target device using pointers to acce...
virtual std::string BpRunDescription() const =0
Pure virtual function to return run description corresponding to target acceleration.
virtual std::optional< beliefprop::BpRunOutput > operator()(const std::array< std::string, 2 > &ref_test_image_path, const beliefprop::BpSettings &alg_settings, const ParallelParams ¶llel_params) const =0
Pure virtual operator() overload that must be defined in child class.
Class to store headers with data corresponding to current program run and evaluation.
void AppendData(const RunData &rundata)
Append current RunData with input RunData.
void AddDataWHeader(const std::string &header, const std::string &data)
Add string data with header describing added data.
Namespace for enums, constants, structures, and functions specific to belief propagation processing.
constexpr bool kAllocateFreeBpMemoryOutsideRuns
constexpr std::string_view kNumEvalRuns
Header for number of evaluation runs (can differ across stereo sets)
const std::unordered_map< Runtime_Type, std::string_view > kTimingNames
Mapping of runtime segment enum to header describing timing of the segment.
constexpr std::string_view kImageWidthHeader
unsigned int NumBpStereoRuns(unsigned int disparity_vals)
Get number of stereo runs when evaluating implementation Perform less stereo runs if greater number o...
constexpr std::string_view kImageHeightHeader
Structure with pointers to objects containing functions for smoothing images, processing bp,...
const std::unique_ptr< MemoryManagement< float > > & mem_management_images
const std::unique_ptr< ProcessBp< T, DISP_VALS, ACCELERATION > > & run_bp_stereo
const std::unique_ptr< MemoryManagement< T > > & mem_management_bp_run
const std::unique_ptr< SmoothImage > & smooth_image
Structure with output disparity map, runtime, and other evaluation data.
std::chrono::duration< double > run_time
DisparityMap< float > out_disparity_map
Structure to store the belief propagation settings including the number of levels and iterations.
unsigned int num_disp_vals
Number of disparity values must be set for each stereo set.