40 #include <pcl/conversions.h>
41 #include <pcl/point_types.h>
55 const auto sad_min_1st_part_it = std::min_element(acc, acc + dbest - 1);
56 const auto sad_min_2nd_part_it = std::min_element(acc + dbest + 2, acc + maxdisp);
58 const auto sad_second_min = std::min(*sad_min_1st_part_it, *sad_min_2nd_part_it);
60 if ((sad_min * precision) > ((precision - ratio_filter) * sad_second_min)) {
75 const auto da_condition = (dbest > 1);
76 const auto db_condition = (dbest < maxdisp - 2);
77 const auto da_index = dbest + 2 - (da_condition << 2);
78 const auto db_index = dbest - 2 + (db_condition << 2);
80 const auto da = acc[da_index] - acc[dbest];
81 const auto db = acc[db_index] - acc[dbest];
82 if ((da + db) < peak_filter) {
123 max_disp_ = max_disp;
146 ratio_filter_ = ratio_filter;
157 peak_filter_ = peak_filter;
168 is_pre_proc_ = is_pre_proc;
181 is_lr_check_ = is_lr_check;
194 lr_check_th_ = lr_check_th;
206 compute(
unsigned char* ref_img,
unsigned char* trg_img,
int width,
int height) = 0;
228 medianFilter(
int radius);
246 getPointCloud(
float u_c,
270 getPointCloud(
float u_c,
332 preProcessing(
unsigned char* img,
unsigned char* pp_img) = 0;
335 imgFlip(
unsigned char*& img) = 0;
338 compute_impl(
unsigned char* ref_img,
unsigned char* trg_img) = 0;
346 int den = (s1 + s3 - 2 * s2);
348 return (static_cast<short int>(16 * dbest + (((s1 - s3) * 8) / den)));
349 return (static_cast<short int>(dbest * 16));
355 float den = (s1 + s3 - 2 * s2);
357 return (static_cast<short int>(16 * dbest +
358 std::floor(.5 + (((s1 - s3) * 8) / den))));
359 return (static_cast<short int>(dbest * 16));
387 compute(
unsigned char* ref_img,
388 unsigned char* trg_img,
390 int height)
override;
407 compute_impl(
unsigned char* ref_img,
unsigned char* trg_img)
override = 0;
410 preProcessing(
unsigned char* img,
unsigned char* pp_img)
override;
413 imgFlip(
unsigned char*& img)
override;
445 compute_impl(
unsigned char* ref_img,
unsigned char* trg_img)
override;
508 smoothness_weak_ = smoothness_weak;
517 smoothness_strong_ = smoothness_strong;
522 compute_impl(
unsigned char* ref_img,
unsigned char* trg_img)
override;
531 int smoothness_strong_;
532 int smoothness_weak_;
void setMaxDisparity(int max_disp)
setter for number of disparity candidates (disparity range)
short int computeStereoSubpixel(int dbest, int s1, int s2, int s3)
void setSmoothWeak(int smoothness_weak)
"weak" smoothness penalty used within 2-pass Scanline Optimization
void setGammaC(int gamma_c)
setter for the color bandwidth used for cost aggregation based on adaptive weights ...
short int * disp_map_
The internal disparity map.
void setLeftRightCheck(bool is_lr_check)
setter for the left-right consistency check stage, that eliminates inconsistent/wrong disparity value...
Block based (or fixed window) Stereo Matching class.
void setLeftRightCheckThreshold(int lr_check_th)
setter for the left-right consistency check threshold
Stereo Matching abstract class for Grayscale images.
int ratio_filter_
Threshold for the ratio filter, .
short int * disp_map_trg_
Disparity map used for left-right check.
int lr_check_th_
Threshold for the left-right consistency check, typically either 0 or 1.
void setPreProcessing(bool is_pre_proc)
setter for the pre processing step
short int doStereoRatioFilter(const T *const acc, short int dbest, T sad_min, int ratio_filter, int maxdisp, int precision=100)
void setGammaS(int gamma_s)
setter for the spatial bandwidth used for cost aggregation based on adaptive weights ...
void setRatioFilter(int ratio_filter)
setter for the value of the ratio filter
void setSmoothStrong(int smoothness_strong)
"strong" smoothness penalty used within 2-pass Scanline Optimization
void setXOffset(int x_off)
setter for horizontal offset, i.e.
Stereo Matching abstract class.
~AdaptiveCostSOStereoMatching()
shared_ptr< PointCloud< PointT > > Ptr
bool is_pre_proc_
toggle for the activation of the pre-processing stage
void setPeakFilter(int peak_filter)
setter for the value of the peak filter
bool is_lr_check_
toggle for the activation of the left-right consistency check stage
Adaptive Cost 2-pass Scanline Optimization Stereo Matching class.
~BlockBasedStereoMatching()
int x_off_
Horizontal displacemente (x offset) used for stereo processing.
short int doStereoPeakFilter(const T *const acc, short int dbest, int peak_filter, int maxdisp)
int max_disp_
Disparity range used for stereo processing.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
void setRadius(int radius)
setter for the radius (half length) of the column used for cost aggregation
unsigned char * pp_trg_img_
void setRadius(int radius)
setter for the radius of the squared window
int height_
number of pixels per row of the input stereo pair .
unsigned char * pp_ref_img_
Local aligned copies used for pre processing.
short int computeStereoSubpixel(int dbest, float s1, float s2, float s3)
int peak_filter_
Threshold for the peak filter, .
unsigned char * ref_img_
Local aligned copies of the cloud data.
int width_
number of pixels per column of the input stereo pair .