RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
Stereo.h
1/*
2Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Universite de Sherbrooke nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef STEREO_H_
29#define STEREO_H_
30
31#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
32
33#include <rtabmap/core/Parameters.h>
34#include <opencv2/core/core.hpp>
35
36namespace rtabmap {
37
55class RTABMAP_CORE_EXPORT Stereo {
56public:
70 static Stereo * create(const ParametersMap & parameters = ParametersMap());
71
72public:
82 Stereo(const ParametersMap & parameters = ParametersMap());
83
87 virtual ~Stereo() {}
88
104 virtual void parseParameters(const ParametersMap & parameters);
105
124 virtual std::vector<cv::Point2f> computeCorrespondences(
125 const cv::Mat & leftImage,
126 const cv::Mat & rightImage,
127 const std::vector<cv::Point2f> & leftCorners,
128 std::vector<unsigned char> & status) const;
129#ifdef HAVE_OPENCV_CUDEV
143 virtual std::vector<cv::Point2f> computeCorrespondences(
144 const cv::cuda::GpuMat & leftImage,
145 const cv::cuda::GpuMat & rightImage,
146 const std::vector<cv::Point2f> & leftCorners,
147 std::vector<unsigned char> & status) const;
148#endif
149
154 cv::Size winSize() const {return cv::Size(winWidth_, winHeight_);}
155
160 int iterations() const {return iterations_;}
161
166 int maxLevel() const {return maxLevel_;}
167
172 float minDisparity() const {return minDisparity_;}
173
178 float maxDisparity() const {return maxDisparity_;}
179
184 bool winSSD() const {return winSSD_;}
185
190 virtual bool isGpuEnabled() const {return false;}
191
192private:
193 int winWidth_;
194 int winHeight_;
195 int iterations_;
196 int maxLevel_;
197 float minDisparity_;
198 float maxDisparity_;
199 bool winSSD_;
200};
201
219class RTABMAP_CORE_EXPORT StereoOpticalFlow : public Stereo {
220public:
231
236
250 virtual void parseParameters(const ParametersMap & parameters);
251
269 virtual std::vector<cv::Point2f> computeCorrespondences(
270 const cv::Mat & leftImage,
271 const cv::Mat & rightImage,
272 const std::vector<cv::Point2f> & leftCorners,
273 std::vector<unsigned char> & status) const;
274
275#ifdef HAVE_OPENCV_CUDEV
291 virtual std::vector<cv::Point2f> computeCorrespondences(
292 const cv::cuda::GpuMat & leftImage,
293 const cv::cuda::GpuMat & rightImage,
294 const std::vector<cv::Point2f> & leftCorners,
295 std::vector<unsigned char> & status) const;
296#endif
297
302 float epsilon() const {return epsilon_;}
303
312 virtual bool isGpuEnabled() const;
313
314 bool usingMinEigenVals() const {return useMinEigenVals_;}
315 float minEigThreshold() const {return minEigThreshold_;}
316 float errorThreshold() const {return errorThreshold_;}
317
318private:
333 void updateStatus(
334 const std::vector<cv::Point2f> & leftCorners,
335 const std::vector<cv::Point2f> & rightCorners,
336 std::vector<unsigned char> & status,
337 std::vector<float> err = {}) const;
338
339private:
340 float epsilon_;
341 bool useMinEigenVals_;
342 float minEigThreshold_;
343 float errorThreshold_;
344 bool gpu_;
345};
346
347} /* namespace rtabmap */
348
349#endif /* STEREO_H_ */
Sparse stereo matching using optical flow.
Definition Stereo.h:219
virtual std::vector< cv::Point2f > computeCorrespondences(const cv::Mat &leftImage, const cv::Mat &rightImage, const std::vector< cv::Point2f > &leftCorners, std::vector< unsigned char > &status) const
Compute stereo correspondences using optical flow.
StereoOpticalFlow(const ParametersMap &parameters=ParametersMap())
Constructor.
virtual void parseParameters(const ParametersMap &parameters)
Parse parameters from a parameters map.
virtual bool isGpuEnabled() const
Check if GPU acceleration is enabled.
float epsilon() const
Get the convergence threshold (epsilon)
Definition Stereo.h:302
virtual ~StereoOpticalFlow()
Virtual destructor.
Definition Stereo.h:235
Sparse stereo matching using block matching.
Definition Stereo.h:55
Stereo(const ParametersMap &parameters=ParametersMap())
Constructor.
static Stereo * create(const ParametersMap &parameters=ParametersMap())
Factory method to create a Stereo instance.
int maxLevel() const
Get the maximum pyramid level.
Definition Stereo.h:166
virtual void parseParameters(const ParametersMap &parameters)
Parse parameters from a parameters map.
cv::Size winSize() const
Get the search window size.
Definition Stereo.h:154
float maxDisparity() const
Get the maximum disparity value.
Definition Stereo.h:178
float minDisparity() const
Get the minimum disparity value.
Definition Stereo.h:172
int iterations() const
Get the number of iterations.
Definition Stereo.h:160
virtual bool isGpuEnabled() const
Check if GPU acceleration is enabled.
Definition Stereo.h:190
virtual ~Stereo()
Virtual destructor.
Definition Stereo.h:87
bool winSSD() const
Check if SSD (Sum of Squared Differences) is used.
Definition Stereo.h:184
virtual std::vector< cv::Point2f > computeCorrespondences(const cv::Mat &leftImage, const cv::Mat &rightImage, const std::vector< cv::Point2f > &leftCorners, std::vector< unsigned char > &status) const
Compute stereo correspondences using block matching.
std::map< std::string, std::string > ParametersMap
Parameter keys mapped to their values, as used by every configurable class (see Parameters).
Definition Parameters.h:44