40 #include <pcl/point_cloud.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;
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));
388 unsigned char* trg_img,
390 int height)
override;
407 compute_impl(
unsigned char* ref_img,
unsigned char* trg_img)
override = 0;
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_;
Adaptive Cost 2-pass Scanline Optimization Stereo Matching class.
void setGammaC(int gamma_c)
setter for the color bandwidth used for cost aggregation based on adaptive weights
void setRadius(int radius)
setter for the radius (half length) of the column used for cost aggregation
void setGammaS(int gamma_s)
setter for the spatial bandwidth used for cost aggregation based on adaptive weights
void setSmoothStrong(int smoothness_strong)
"strong" smoothness penalty used within 2-pass Scanline Optimization
AdaptiveCostSOStereoMatching()
~AdaptiveCostSOStereoMatching() override=default
void setSmoothWeak(int smoothness_weak)
"weak" smoothness penalty used within 2-pass Scanline Optimization
Block based (or fixed window) Stereo Matching class.
BlockBasedStereoMatching()
void setRadius(int radius)
setter for the radius of the squared window
~BlockBasedStereoMatching() override=default
Stereo Matching abstract class for Grayscale images.
void compute(unsigned char *ref_img, unsigned char *trg_img, int width, int height) override
stereo processing, it computes a disparity map stored internally by the class
void preProcessing(unsigned char *img, unsigned char *pp_img) override
~GrayStereoMatching() override
void compute_impl(unsigned char *ref_img, unsigned char *trg_img) override=0
void imgFlip(unsigned char *&img) override
void compute(pcl::PointCloud< pcl::RGB > &ref, pcl::PointCloud< pcl::RGB > &trg) override
stereo processing, it computes a disparity map stored internally by the class
shared_ptr< PointCloud< PointT > > Ptr
Stereo Matching abstract class.
void setPeakFilter(int peak_filter)
setter for the value of the peak filter
short int computeStereoSubpixel(int dbest, float s1, float s2, float s3)
virtual void compute_impl(unsigned char *ref_img, unsigned char *trg_img)=0
void setMaxDisparity(int max_disp)
setter for number of disparity candidates (disparity range)
virtual ~StereoMatching()
unsigned char * pp_ref_img_
Local aligned copies used for pre processing.
int peak_filter_
Threshold for the peak filter, .
void setXOffset(int x_off)
setter for horizontal offset, i.e.
virtual void imgFlip(unsigned char *&img)=0
bool is_lr_check_
toggle for the activation of the left-right consistency check stage
void setLeftRightCheck(bool is_lr_check)
setter for the left-right consistency check stage, that eliminates inconsistent/wrong disparity value...
short int * disp_map_trg_
Disparity map used for left-right check.
unsigned char * ref_img_
Local aligned copies of the cloud data.
int lr_check_th_
Threshold for the left-right consistency check, typically either 0 or 1.
int width_
number of pixels per column of the input stereo pair .
virtual void compute(unsigned char *ref_img, unsigned char *trg_img, int width, int height)=0
stereo processing, it computes a disparity map stored internally by the class
unsigned char * pp_trg_img_
void setLeftRightCheckThreshold(int lr_check_th)
setter for the left-right consistency check threshold
int ratio_filter_
Threshold for the ratio filter, .
void getVisualMap(pcl::PointCloud< pcl::RGB >::Ptr vMap)
computation of a pcl::RGB cloud with scaled disparity values it can be used to display a rescaled ver...
int max_disp_
Disparity range used for stereo processing.
virtual void preProcessing(unsigned char *img, unsigned char *pp_img)=0
virtual void compute(pcl::PointCloud< pcl::RGB > &ref, pcl::PointCloud< pcl::RGB > &trg)=0
stereo processing, it computes a disparity map stored internally by the class
void setRatioFilter(int ratio_filter)
setter for the value of the ratio filter
void medianFilter(int radius)
median filter applied on the previously computed disparity map
int height_
number of pixels per row of the input stereo pair .
int x_off_
Horizontal displacemente (x offset) used for stereo processing.
void setPreProcessing(bool is_pre_proc)
setter for the pre processing step
short int computeStereoSubpixel(int dbest, int s1, int s2, int s3)
virtual bool getPointCloud(float u_c, float v_c, float focal, float baseline, pcl::PointCloud< pcl::PointXYZ >::Ptr cloud)
computation of the 3D point cloud from the previously computed disparity map without color informatio...
short int * disp_map_
The internal disparity map.
virtual bool getPointCloud(float u_c, float v_c, float focal, float baseline, pcl::PointCloud< pcl::PointXYZRGB >::Ptr cloud, pcl::PointCloud< pcl::RGB >::Ptr texture)
computation of the 3D point cloud from the previously computed disparity map including color informat...
bool is_pre_proc_
toggle for the activation of the pre-processing stage
Defines all the PCL implemented PointT point type structures.
short int doStereoRatioFilter(const T *const acc, short int dbest, T sad_min, int ratio_filter, int maxdisp, int precision=100)
short int doStereoPeakFilter(const T *const acc, short int dbest, int peak_filter, int maxdisp)