40 #include <pcl/conversions.h> 98 ratio_filter_ = ratio_filter;
109 peak_filter_ = peak_filter;
119 is_pre_proc_ = is_pre_proc;
130 is_lr_check_ = is_lr_check;
143 lr_check_th_ = lr_check_th;
154 compute (
unsigned char* ref_img,
unsigned char* trg_img,
int width,
int height) = 0;
171 medianFilter (
int radius);
254 preProcessing (
unsigned char *img,
unsigned char *pp_img) = 0;
257 imgFlip (
unsigned char * & img) = 0;
260 compute_impl (
unsigned char* ref_img,
unsigned char* trg_img) = 0;
268 int den = (s1+s3-2*s2);
270 return (static_cast<short int> (16*dbest + (((s1 - s3)*8) / den)));
272 return (static_cast<short int> (dbest*16));
278 float den = (s1+s3-2*s2);
280 return (static_cast<short int> (16*dbest + floor(.5 + (((s1 - s3)*8) / den))));
282 return (static_cast<short int> (dbest*16));
286 doStereoRatioFilter (
int *acc,
short int dbest,
int sad_min,
int ratio_filter,
int maxdisp,
int precision = 100)
288 int sad_second_min = std::numeric_limits<int>::max ();
290 for (
int d = 0; d < dbest - 1; d++)
291 if (acc[d] < sad_second_min)
292 sad_second_min = acc[d];
294 for (
int d = dbest + 2; d < maxdisp; d++)
295 if (acc[d] < sad_second_min)
296 sad_second_min = acc[d];
298 if (sad_min * precision > (precision - ratio_filter) * sad_second_min)
305 doStereoRatioFilter (
float *acc,
short int dbest,
float sad_min,
int ratio_filter,
int maxdisp,
int precision = 100)
307 float sad_second_min = std::numeric_limits<float>::max ();
309 for (
int d = 0; d < dbest - 1; d++)
310 if (acc[d] < sad_second_min)
311 sad_second_min = acc[d];
313 for (
int d = dbest + 2; d < maxdisp; d++)
314 if (acc[d] < sad_second_min)
315 sad_second_min = acc[d];
317 if (sad_min * static_cast<float> (precision) > static_cast<float> (precision - ratio_filter) * sad_second_min)
326 int da = (dbest>1) ? ( acc[dbest-2] - acc[dbest] ) : (acc[dbest+2] - acc[dbest]);
327 int db = (dbest<maxdisp-2) ? (acc[dbest+2] - acc[dbest]) : (acc[dbest-2] - acc[dbest]);
329 if (da + db < peak_filter)
338 float da = (dbest>1) ? ( acc[dbest-2] - acc[dbest] ) : (acc[dbest+2] - acc[dbest]);
339 float db = (dbest<maxdisp-2) ? (acc[dbest+2] - acc[dbest]) : (acc[dbest-2] - acc[dbest]);
341 if (da + db < peak_filter)
371 compute (
unsigned char* ref_img,
unsigned char* trg_img,
int width,
int height);
384 compute_impl (
unsigned char* ref_img,
unsigned char* trg_img) = 0;
387 preProcessing (
unsigned char *img,
unsigned char *pp_img);
390 imgFlip (
unsigned char * & img);
424 compute_impl (
unsigned char* ref_img,
unsigned char* trg_img);
485 smoothness_weak_ = smoothness_weak;
494 smoothness_strong_ = smoothness_strong;
499 compute_impl (
unsigned char* ref_img,
unsigned char* trg_img);
508 int smoothness_strong_;
509 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 bandwith 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.
short int doStereoRatioFilter(float *acc, short int dbest, float sad_min, int ratio_filter, int maxdisp, int precision=100)
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
void setGammaS(int gamma_s)
setter for the spatial bandwith 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.
boost::shared_ptr< PointCloud< PointT > > Ptr
short int doStereoRatioFilter(int *acc, short int dbest, int sad_min, int ratio_filter, int maxdisp, int precision=100)
virtual ~BlockBasedStereoMatching(void)
virtual ~AdaptiveCostSOStereoMatching(void)
Defines all the PCL implemented PointT point type structures.
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.
int x_off_
Horizontal displacemente (x offset) used for stereo processing.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
short int doStereoPeakFilter(float *acc, short int dbest, int peak_filter, int maxdisp)
int max_disp_
Disparity range used for stereo processing.
void setRadius(int radius)
setter for the radius (half length) of the column used for cost aggregation
unsigned char * pp_trg_img_
short int doStereoPeakFilter(int *acc, short int dbest, int peak_filter, int maxdisp)
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 .