From a25372da025b6a0aa42ddfd6b1bc4cb6690d1a32 Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Fri, 13 Dec 2019 15:39:33 -0800 Subject: [PATCH] Move inline implementation into class Save on some vertical space. Signed-off-by: Jacob Perron --- .../stereo_image_proc/stereo_processor.hpp | 368 ++++++++---------- 1 file changed, 158 insertions(+), 210 deletions(-) diff --git a/stereo_image_proc/include/stereo_image_proc/stereo_processor.hpp b/stereo_image_proc/include/stereo_image_proc/stereo_processor.hpp index 991a8d1e4..3cef016bf 100644 --- a/stereo_image_proc/include/stereo_image_proc/stereo_processor.hpp +++ b/stereo_image_proc/include/stereo_image_proc/stereo_processor.hpp @@ -85,66 +85,188 @@ class StereoProcessor ALL = LEFT_ALL | RIGHT_ALL | STEREO_ALL }; - inline - StereoType getStereoType() const + inline StereoType getStereoType() const { return current_stereo_algorithm_; } - inline - void setStereoType(StereoType type) + inline void setStereoType(StereoType type) { current_stereo_algorithm_ = type; } - int getInterpolation() const; - void setInterpolation(int interp); + inline int getInterpolation() const + { + return mono_processor_.interpolation_; + } + + inline void setInterpolation(int interp) + { + mono_processor_.interpolation_ = interp; + } + + inline int getPreFilterCap() const + { + if (current_stereo_algorithm_ == BM) { + return block_matcher_->getPreFilterCap(); + } + return sg_block_matcher_->getPreFilterCap(); + } + + inline void setPreFilterCap(int param) + { + block_matcher_->setPreFilterCap(param); + sg_block_matcher_->setPreFilterCap(param); + } + + inline int getCorrelationWindowSize() const + { + if (current_stereo_algorithm_ == BM) { + return block_matcher_->getBlockSize(); + } + return sg_block_matcher_->getBlockSize(); + } + + inline void setCorrelationWindowSize(int param) + { + block_matcher_->setBlockSize(param); + sg_block_matcher_->setBlockSize(param); + } + + inline int getMinDisparity() const + { + if (current_stereo_algorithm_ == BM) { + return block_matcher_->getMinDisparity(); + } + return sg_block_matcher_->getMinDisparity(); + } + + inline void setMinDisparity(int param) + { + block_matcher_->setMinDisparity(param); + sg_block_matcher_->setMinDisparity(param); + } + + inline int getDisparityRange() const + { + if (current_stereo_algorithm_ == BM) { + return block_matcher_->getNumDisparities(); + } + return sg_block_matcher_->getNumDisparities(); + } + + inline void setDisparityRange(int param) + { + block_matcher_->setNumDisparities(param); + sg_block_matcher_->setNumDisparities(param); + } + + inline float getUniquenessRatio() const + { + if (current_stereo_algorithm_ == BM) { + return block_matcher_->getUniquenessRatio(); + } + return sg_block_matcher_->getUniquenessRatio(); + } + + inline void setUniquenessRatio(float param) + { + block_matcher_->setUniquenessRatio(param); + sg_block_matcher_->setUniquenessRatio(param); + } - // Disparity pre-filtering parameters + inline int getSpeckleSize() const + { + if (current_stereo_algorithm_ == BM) { + return block_matcher_->getBlockSize(); + } + return sg_block_matcher_->getBlockSize(); + } - int getPreFilterSize() const; - void setPreFilterSize(int size); + inline void setSpeckleSize(int param) + { + block_matcher_->setBlockSize(param); + sg_block_matcher_->setBlockSize(param); + } - int getPreFilterCap() const; - void setPreFilterCap(int cap); + inline int getSpeckleRange() const + { + if (current_stereo_algorithm_ == BM) { + return block_matcher_->getSpeckleRange(); + } + return sg_block_matcher_->getSpeckleRange(); + } - // Disparity correlation parameters + inline void setSpeckleRange(int param) + { + block_matcher_->setSpeckleRange(param); + sg_block_matcher_->setSpeckleRange(param); + } - int getCorrelationWindowSize() const; - void setCorrelationWindowSize(int size); + // BM only - int getMinDisparity() const; - void setMinDisparity(int min_d); + inline int getPreFilterSize() const + { + return block_matcher_->getPreFilterSize(); + } + + inline void setPreFilterSize(int param) + { + block_matcher_->setPreFilterSize(param); + } - int getDisparityRange() const; - void setDisparityRange(int range); // Number of pixels to search + inline int getTextureThreshold() const + { + return block_matcher_->getTextureThreshold(); + } - // Disparity post-filtering parameters + inline void setTextureThreshold(int param) + { + block_matcher_->setTextureThreshold(param); + } - int getTextureThreshold() const; - void setTextureThreshold(int threshold); + // SGBM specific - float getUniquenessRatio() const; - void setUniquenessRatio(float ratio); + // getSgbmMode can return MODE_SGBM = 0, MODE_HH = 1. FullDP == 1 was MODE_HH so we're good + inline int getSgbmMode() const + { + return sg_block_matcher_->getMode(); + } - int getSpeckleSize() const; - void setSpeckleSize(int size); + inline void setSgbmMode(int param) + { + sg_block_matcher_->setMode(param); + } - int getSpeckleRange() const; - void setSpeckleRange(int range); + inline int getP1() const + { + return sg_block_matcher_->getP1(); + } - // SGBM only - int getSgbmMode() const; - void setSgbmMode(int fullDP); + inline void setP1(int param) + { + sg_block_matcher_->setP1(param); + } - int getP1() const; - void setP1(int P1); + inline int getP2() const + { + return sg_block_matcher_->getP2(); + } - int getP2() const; - void setP2(int P2); + inline void setP2(int param) + { + sg_block_matcher_->setP2(param); + } - int getDisp12MaxDiff() const; - void setDisp12MaxDiff(int disp12MaxDiff); + inline int getDisp12MaxDiff() const + { + return sg_block_matcher_->getDisp12MaxDiff(); + } + + inline void setDisp12MaxDiff(int param) + { + sg_block_matcher_->setDisp12MaxDiff(param); + } // Do all the work! bool process( @@ -187,180 +309,6 @@ class StereoProcessor mutable cv::Mat_ dense_points_; }; - -inline int StereoProcessor::getInterpolation() const -{ - return mono_processor_.interpolation_; -} - -inline void StereoProcessor::setInterpolation(int interp) -{ - mono_processor_.interpolation_ = interp; -} - -inline int StereoProcessor::getPreFilterCap() const -{ - if (current_stereo_algorithm_ == BM) { - return block_matcher_->getPreFilterCap(); - } - return sg_block_matcher_->getPreFilterCap(); -} - -inline void StereoProcessor::setPreFilterCap(int param) -{ - block_matcher_->setPreFilterCap(param); - sg_block_matcher_->setPreFilterCap(param); -} - -inline int StereoProcessor::getCorrelationWindowSize() const -{ - if (current_stereo_algorithm_ == BM) { - return block_matcher_->getBlockSize(); - } - return sg_block_matcher_->getBlockSize(); -} - -inline void StereoProcessor::setCorrelationWindowSize(int param) -{ - block_matcher_->setBlockSize(param); - sg_block_matcher_->setBlockSize(param); -} - -inline int StereoProcessor::getMinDisparity() const -{ - if (current_stereo_algorithm_ == BM) { - return block_matcher_->getMinDisparity(); - } - return sg_block_matcher_->getMinDisparity(); -} - -inline void StereoProcessor::setMinDisparity(int param) -{ - block_matcher_->setMinDisparity(param); - sg_block_matcher_->setMinDisparity(param); -} - -inline int StereoProcessor::getDisparityRange() const -{ - if (current_stereo_algorithm_ == BM) { - return block_matcher_->getNumDisparities(); - } - return sg_block_matcher_->getNumDisparities(); -} - -inline void StereoProcessor::setDisparityRange(int param) -{ - block_matcher_->setNumDisparities(param); - sg_block_matcher_->setNumDisparities(param); -} - -inline float StereoProcessor::getUniquenessRatio() const -{ - if (current_stereo_algorithm_ == BM) { - return block_matcher_->getUniquenessRatio(); - } - return sg_block_matcher_->getUniquenessRatio(); -} - -inline void StereoProcessor::setUniquenessRatio(float param) -{ - block_matcher_->setUniquenessRatio(param); - sg_block_matcher_->setUniquenessRatio(param); -} - -inline int StereoProcessor::getSpeckleSize() const -{ - if (current_stereo_algorithm_ == BM) { - return block_matcher_->getBlockSize(); - } - return sg_block_matcher_->getBlockSize(); -} - -inline void StereoProcessor::setSpeckleSize(int param) -{ - block_matcher_->setBlockSize(param); - sg_block_matcher_->setBlockSize(param); -} - -inline int StereoProcessor::getSpeckleRange() const -{ - if (current_stereo_algorithm_ == BM) { - return block_matcher_->getSpeckleRange(); - } - return sg_block_matcher_->getSpeckleRange(); -} - -inline void StereoProcessor::setSpeckleRange(int param) -{ - block_matcher_->setSpeckleRange(param); - sg_block_matcher_->setSpeckleRange(param); -} - -// BM only - -inline int StereoProcessor::getPreFilterSize() const -{ - return block_matcher_->getPreFilterSize(); -} - -inline void StereoProcessor::setPreFilterSize(int param) -{ - block_matcher_->setPreFilterSize(param); -} - -inline int StereoProcessor::getTextureThreshold() const -{ - return block_matcher_->getTextureThreshold(); -} - -inline void StereoProcessor::setTextureThreshold(int param) -{ - block_matcher_->setTextureThreshold(param); -} - -// SGBM specific - -// getSgbmMode can return MODE_SGBM = 0, MODE_HH = 1. FullDP == 1 was MODE_HH so we're good -inline int StereoProcessor::getSgbmMode() const -{ - return sg_block_matcher_->getMode(); -} - -inline void StereoProcessor::setSgbmMode(int param) -{ - sg_block_matcher_->setMode(param); -} - -inline int StereoProcessor::getP1() const -{ - return sg_block_matcher_->getP1(); -} - -inline void StereoProcessor::setP1(int param) -{ - sg_block_matcher_->setP1(param); -} - -inline int StereoProcessor::getP2() const -{ - return sg_block_matcher_->getP2(); -} - -inline void StereoProcessor::setP2(int param) -{ - sg_block_matcher_->setP2(param); -} - -inline int StereoProcessor::getDisp12MaxDiff() const -{ - return sg_block_matcher_->getDisp12MaxDiff(); -} - -inline void StereoProcessor::setDisp12MaxDiff(int param) -{ - sg_block_matcher_->setDisp12MaxDiff(param); -} - } // namespace stereo_image_proc #endif // STEREO_IMAGE_PROC__STEREO_PROCESSOR_HPP_