pcl::StereoMatching Class Referenceabstract

Stereo Matching abstract class. More...

`#include <pcl/stereo/stereo_matching.h>`

Inheritance diagram for pcl::StereoMatching:

## Public Member Functions

| StereoMatching (void)
virtual | ~StereoMatching (void)
void | setMaxDisparity (int max_disp)
| setter for number of disparity candidates (disparity range) More...
void | setXOffset (int x_off)
| setter for horizontal offset, i.e. More...
void | setRatioFilter (int ratio_filter)
| setter for the value of the ratio filter More...
void | setPeakFilter (int peak_filter)
| setter for the value of the peak filter More...
void | setPreProcessing (bool is_pre_proc)
| setter for the pre processing step More...
void | setLeftRightCheck (bool is_lr_check)
| setter for the left-right consistency check stage, that eliminates inconsistent/wrong disparity values from the disparity map at approx. More...
void | setLeftRightCheckThreshold (int lr_check_th)
| setter for the left-right consistency check threshold More...
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 More...
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 More...
void | medianFilter (int radius)
| median filter applied on the previously computed disparity map Note: the "compute" method must have been previously called at least once in order for this function to have any effect More...
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 information Note: the "compute" method must have been previously called at least once in order for this function to have any effect More...
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 information Note: the "compute" method must have been previously called at least once in order for this function to have any effect More...
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 version of the disparity map by means of the pcl::ImageViewer invalid disparity values are shown in green Note: the "compute" method must have been previously called at least once in order for this function to have any effect More...

## Protected Member Functions

virtual void | preProcessing (unsigned char *img, unsigned char *pp_img)=0
virtual void | imgFlip (unsigned char *&img)=0
virtual void | compute_impl (unsigned char *ref_img, unsigned char *trg_img)=0
void | leftRightCheck ()
short int | computeStereoSubpixel (int dbest, int s1, int s2, int s3)
short int | computeStereoSubpixel (int dbest, float s1, float s2, float s3)
short int | doStereoRatioFilter (int *acc, short int dbest, int sad_min, int ratio_filter, int maxdisp, int precision=100)
short int | doStereoRatioFilter (float *acc, short int dbest, float sad_min, int ratio_filter, int maxdisp, int precision=100)
short int | doStereoPeakFilter (int *acc, short int dbest, int peak_filter, int maxdisp)
short int | doStereoPeakFilter (float *acc, short int dbest, int peak_filter, int maxdisp)

## Protected Attributes

short int * | disp_map_
| The internal disparity map. More...
unsigned char * | ref_img_
| Local aligned copies of the cloud data. More...
unsigned char * | trg_img_
short int * | disp_map_trg_
| Disparity map used for left-right check. More...
unsigned char * | pp_ref_img_
| Local aligned copies used for pre processing. More...
unsigned char * | pp_trg_img_
int | width_
| number of pixels per column of the input stereo pair . More...
int | height_
| number of pixels per row of the input stereo pair . More...
int | max_disp_
| Disparity range used for stereo processing. More...
int | x_off_
| Horizontal displacemente (x offset) used for stereo processing. More...
int | ratio_filter_
| Threshold for the ratio filter, . More...
int | peak_filter_
| Threshold for the peak filter, . More...
bool | is_pre_proc_
| toggle for the activation of the pre-processing stage More...
bool | is_lr_check_
| toggle for the activation of the left-right consistency check stage More...
int | lr_check_th_
| Threshold for the left-right consistency check, typically either 0 or 1. More...

## Detailed Description

Stereo Matching abstract class.

The class performs stereo matching on a rectified stereo pair Includes the following functionalities:

- preprocessing of the image pair, to improve robustness against photometric distortions (wrt. to a spatially constant additive photometric factor)
- postprocessing: filtering of wrong disparities via Peak Filter (eliminating ambiguities due to low-textured regions) and Ratio Filter (eliminating generic matching ambiguities, similar to that present in OpenCV Block Matching Stereo)
- postprocessing: Left-Right consistency check (eliminates wrong disparities at the cost of twice the stereo matching computation)
- postprocessing: subpixel refinement of computed disparities, to reduce the depth quantization effect
- postprocessing: smoothing of the disparity map via median filter
- after stereo matching a PCL point cloud can be computed, given the stereo intrinsic (focal, principal point coordinates) and extrinsic (baseline) calibration parameters

Author
  Federico Tombari (feder.nosp@m.ico..nosp@m.tomba.nosp@m.ri@u.nosp@m.nibo..nosp@m.it)

Definition at line 63 of file stereo_matching.h.

## Constructor & Destructor Documentation

## StereoMatching()

pcl::StereoMatching::StereoMatching | ( | void |  | ) |

## ~StereoMatching()

virtual pcl::StereoMatching::~StereoMatching | ( | void |  | ) |

virtual

## Member Function Documentation

## compute() [1/2]

virtual void pcl::StereoMatching::compute | ( | unsigned char * | ref_img,
|  | unsigned char * | trg_img,
|  | int | width,
|  | int | height
| ) |  |

pure virtual

stereo processing, it computes a disparity map stored internally by the class

Parameters

  [in] | ref_img | reference array of image pixels (left image)
  [in] | trg_img | target array of image pixels (right image)
  [in] | width | number of elements per row for both input arrays
  [in] | height | number of elements per column for both input arrays

Implemented in pcl::GrayStereoMatching.

## compute() [2/2]

virtual void pcl::StereoMatching::compute | ( | pcl::PointCloud< pcl::RGB > & | ref,
|  | pcl::PointCloud< pcl::RGB > & | trg
| ) |  |

pure virtual

stereo processing, it computes a disparity map stored internally by the class

Parameters

  [in] | ref | point cloud of pcl::RGB type containing the pixels of the reference image (left image)
  [in] | trg | point cloud of pcl::RGB type containing the pixels of the target image (right image)

Implemented in pcl::GrayStereoMatching.

## compute_impl()

virtual void pcl::StereoMatching::compute_impl | ( | unsigned char * | ref_img,
|  | unsigned char * | trg_img
| ) |  |

protected pure virtual

Implemented in pcl::GrayStereoMatching.

## computeStereoSubpixel() [1/2]

short int pcl::StereoMatching::computeStereoSubpixel | ( | int | dbest,
|  | int | s1,
|  | int | s2,
|  | int | s3
| ) |  |

inline protected

Definition at line 266 of file stereo_matching.h.

## computeStereoSubpixel() [2/2]

short int pcl::StereoMatching::computeStereoSubpixel | ( | int | dbest,
|  | float | s1,
|  | float | s2,
|  | float | s3
| ) |  |

inline protected

Definition at line 276 of file stereo_matching.h.

## doStereoPeakFilter() [1/2]

short int pcl::StereoMatching::doStereoPeakFilter | ( | int * | acc,
|  | short int | dbest,
|  | int | peak_filter,
|  | int | maxdisp
| ) |  |

inline protected

Definition at line 324 of file stereo_matching.h.

## doStereoPeakFilter() [2/2]

short int pcl::StereoMatching::doStereoPeakFilter | ( | float * | acc,
|  | short int | dbest,
|  | int | peak_filter,
|  | int | maxdisp
| ) |  |

inline protected

Definition at line 336 of file stereo_matching.h.

## doStereoRatioFilter() [1/2]

short int pcl::StereoMatching::doStereoRatioFilter | ( | int * | acc,
|  | short int | dbest,
|  | int | sad_min,
|  | int | ratio_filter,
|  | int | maxdisp,
|  | int | precision = `100`
| ) |  |

inline protected

Definition at line 286 of file stereo_matching.h.

## doStereoRatioFilter() [2/2]

short int pcl::StereoMatching::doStereoRatioFilter | ( | float * | acc,
|  | short int | dbest,
|  | float | sad_min,
|  | int | ratio_filter,
|  | int | maxdisp,
|  | int | precision = `100`
| ) |  |

inline protected

Definition at line 305 of file stereo_matching.h.

## getPointCloud() [1/2]

virtual bool pcl::StereoMatching::getPointCloud | ( | float | u_c,
|  | float | v_c,
|  | float | focal,
|  | float | baseline,
|  | pcl::PointCloud< pcl::PointXYZ >::Ptr | cloud
| ) |  |

virtual

computation of the 3D point cloud from the previously computed disparity map without color information Note: the "compute" method must have been previously called at least once in order for this function to have any effect

Parameters

  [in] | u_c | horizontal coordinate of the principal point (calibration parameter)
  [in] | v_c | vertical coordinate of the principal point (calibration parameter)
  [in] | focal | focal length in pixels (calibration parameter)
  [in] | baseline | distance between the two cameras (calibration parameter); the measure unit used to specify this parameter will be the same as the 3D points in the output point cloud
  [out] | cloud | output 3D point cloud; it is organized and non-dense, with NaNs where 3D points are invalid

## getPointCloud() [2/2]

virtual bool pcl::StereoMatching::getPointCloud | ( | float | u_c,
|  | float | v_c,
|  | float | focal,
|  | float | baseline,
|  | pcl::PointCloud< pcl::PointXYZRGB >::Ptr | cloud,
|  | pcl::PointCloud< pcl::RGB >::Ptr | texture
| ) |  |

virtual

computation of the 3D point cloud from the previously computed disparity map including color information Note: the "compute" method must have been previously called at least once in order for this function to have any effect

Parameters

  [in] | u_c | horizontal coordinate of the principal point (calibration parameter)
  [in] | v_c | vertical coordinate of the principal point (calibration parameter)
  [in] | focal | focal length in pixels (calibration parameter)
  [in] | baseline | distance between the two cameras (calibration parameter); the measure unit used to specify this parameter will be the same as the 3D points in the output point cloud
  [out] | cloud | output 3D point cloud; it is organized and non-dense, with NaNs where 3D points are invalid
  [in] | texture | 3D cloud (same size of the output cloud) used to associate to each 3D point of the output cloud a color triplet

## getVisualMap()

void pcl::StereoMatching::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 version of the disparity map by means of the pcl::ImageViewer invalid disparity values are shown in green Note: the "compute" method must have been previously called at least once in order for this function to have any effect

Parameters

  [out] | vMap | output cloud

## imgFlip()

virtual void pcl::StereoMatching::imgFlip | ( | unsigned char *& | img | ) |

protected pure virtual

Implemented in pcl::GrayStereoMatching.

## leftRightCheck()

void pcl::StereoMatching::leftRightCheck | ( |  | ) |

protected

## medianFilter()

void pcl::StereoMatching::medianFilter | ( | int | radius | ) |

median filter applied on the previously computed disparity map Note: the "compute" method must have been previously called at least once in order for this function to have any effect

Parameters

  [in] | radius | radius of the squared window used to compute the median filter; the window side is equal to 2*radius + 1

## preProcessing()

virtual void pcl::StereoMatching::preProcessing | ( | unsigned char * | img,
|  | unsigned char * | pp_img
| ) |  |

protected pure virtual

Implemented in pcl::GrayStereoMatching.

## setLeftRightCheck()

void pcl::StereoMatching::setLeftRightCheck | ( | bool | is_lr_check | ) |

inline

setter for the left-right consistency check stage, that eliminates inconsistent/wrong disparity values from the disparity map at approx.

twice the processing cost of the selected stereo algorithm

Parameters

  [in] | is_lr_check | setting the boolean to true activates the left-right consistency check

Definition at line 128 of file stereo_matching.h.

## setLeftRightCheckThreshold()

void pcl::StereoMatching::setLeftRightCheckThreshold | ( | int | lr_check_th | ) |

inline

setter for the left-right consistency check threshold

Parameters

  [in] | lr_check_th | sets the value of the left-right consistency check threshold only has some influence if the left-right check is active typically has either the value 0 ("strong" consistency check, more points being filtered) or 1 ("weak" consistency check, less points being filtered)

Definition at line 141 of file stereo_matching.h.

## setMaxDisparity()

void pcl::StereoMatching::setMaxDisparity | ( | int | max_disp | ) |

inline

setter for number of disparity candidates (disparity range)

Parameters

  [in] | max_disp | number of disparity candidates (disparity range); has to be > 0

Definition at line 75 of file stereo_matching.h.

## setPeakFilter()

void pcl::StereoMatching::setPeakFilter | ( | int | peak_filter | ) |

inline

setter for the value of the peak filter

Parameters

  [in] | peak_filter | value of the peak filter; it is a number in the range [0, inf] (0: no filtering action)

Definition at line 107 of file stereo_matching.h.

## setPreProcessing()

void pcl::StereoMatching::setPreProcessing | ( | bool | is_pre_proc | ) |

inline

setter for the pre processing step

Parameters

  [in] | is_pre_proc | setting the boolean to true activates the pre-processing step for both stereo images

Definition at line 117 of file stereo_matching.h.

## setRatioFilter()

void pcl::StereoMatching::setRatioFilter | ( | int | ratio_filter | ) |

inline

setter for the value of the ratio filter

Parameters

  [in] | ratio_filter | value of the ratio filter; it is a number in the range [0, 100] (0: no filtering action; 100: all disparities are filtered)

Definition at line 96 of file stereo_matching.h.

## setXOffset()

void pcl::StereoMatching::setXOffset | ( | int | x_off | ) |

inline

setter for horizontal offset, i.e.

number of pixels to shift the disparity range over the target image

Parameters

  [in] | x_off | horizontal offset value; has to be >= 0

Definition at line 85 of file stereo_matching.h.

## Member Data Documentation

## disp_map_

short int* pcl::StereoMatching::disp_map_

protected

The internal disparity map.

Definition at line 213 of file stereo_matching.h.

## disp_map_trg_

short int* pcl::StereoMatching::disp_map_trg_

protected

Disparity map used for left-right check.

Definition at line 220 of file stereo_matching.h.

## height_

int pcl::StereoMatching::height_

protected

number of pixels per row of the input stereo pair .

Definition at line 230 of file stereo_matching.h.

## is_lr_check_

bool pcl::StereoMatching::is_lr_check_

protected

toggle for the activation of the left-right consistency check stage

Definition at line 248 of file stereo_matching.h.

## is_pre_proc_

bool pcl::StereoMatching::is_pre_proc_

protected

toggle for the activation of the pre-processing stage

Definition at line 245 of file stereo_matching.h.

## lr_check_th_

int pcl::StereoMatching::lr_check_th_

protected

Threshold for the left-right consistency check, typically either 0 or 1.

Definition at line 251 of file stereo_matching.h.

## max_disp_

int pcl::StereoMatching::max_disp_

protected

Disparity range used for stereo processing.

Definition at line 233 of file stereo_matching.h.

## peak_filter_

int pcl::StereoMatching::peak_filter_

protected

Threshold for the peak filter, .

Definition at line 242 of file stereo_matching.h.

## pp_ref_img_

unsigned char* pcl::StereoMatching::pp_ref_img_

protected

Local aligned copies used for pre processing.

Definition at line 223 of file stereo_matching.h.

## pp_trg_img_

unsigned char* pcl::StereoMatching::pp_trg_img_

protected

Definition at line 224 of file stereo_matching.h.

## ratio_filter_

int pcl::StereoMatching::ratio_filter_

protected

Threshold for the ratio filter, .

Definition at line 239 of file stereo_matching.h.

## ref_img_

unsigned char* pcl::StereoMatching::ref_img_

protected

Local aligned copies of the cloud data.

Definition at line 216 of file stereo_matching.h.

## trg_img_

unsigned char* pcl::StereoMatching::trg_img_

protected

Definition at line 217 of file stereo_matching.h.

## width_

int pcl::StereoMatching::width_

protected

number of pixels per column of the input stereo pair .

Definition at line 227 of file stereo_matching.h.

## x_off_

int pcl::StereoMatching::x_off_

protected

Horizontal displacemente (x offset) used for stereo processing.

Definition at line 236 of file stereo_matching.h.

The documentation for this class was generated from the following file:

- /build/pcl-OilVEB/pcl-1.8.1+dfsg1/stereo/include/pcl/stereo/stereo_matching.h