util2d.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, 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 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON 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
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef UTIL2D_H_
29 #define UTIL2D_H_
30 
32 
33 #include <opencv2/core/core.hpp>
34 #include <rtabmap/core/Transform.h>
36 #include <vector>
37 
38 namespace rtabmap
39 {
40 
41 namespace util2d
42 {
43 
44 // SSD: Sum of Squared Differences
45 float RTABMAP_EXP ssd(const cv::Mat & windowLeft, const cv::Mat & windowRight);
46 // SAD: Sum of Absolute intensity Differences
47 float RTABMAP_EXP sad(const cv::Mat & windowLeft, const cv::Mat & windowRight);
48 
49 std::vector<cv::Point2f> RTABMAP_EXP calcStereoCorrespondences(
50  const cv::Mat & leftImage,
51  const cv::Mat & rightImage,
52  const std::vector<cv::Point2f> & leftCorners,
53  std::vector<unsigned char> & status,
54  cv::Size winSize = cv::Size(6,3),
55  int maxLevel = 3,
56  int iterations = 5,
57  float minDisparity = 0.0f,
58  float maxDisparity = 64.0f,
59  bool ssdApproach = true); // SSD by default, otherwise it is SAD
60 
61 // exactly as cv::calcOpticalFlowPyrLK but it should be called with pyramid (from cv::buildOpticalFlowPyramid()) and delta drops the y error.
62 void RTABMAP_EXP calcOpticalFlowPyrLKStereo( cv::InputArray _prevImg, cv::InputArray _nextImg,
63  cv::InputArray _prevPts, cv::InputOutputArray _nextPts,
64  cv::OutputArray _status, cv::OutputArray _err,
65  cv::Size winSize = cv::Size(15,3), int maxLevel = 3,
66  cv::TermCriteria criteria = cv::TermCriteria(cv::TermCriteria::COUNT+cv::TermCriteria::EPS, 30, 0.01),
67  int flags = 0, double minEigThreshold = 1e-4 );
68 
69 
71  const cv::Mat & leftImage,
72  const cv::Mat & rightImage,
73  const ParametersMap & parameters = ParametersMap());
74 
75 cv::Mat RTABMAP_EXP depthFromDisparity(const cv::Mat & disparity,
76  float fx, float baseline,
77  int type = CV_32FC1); // CV_32FC1 or CV_16UC1
78 
80  const cv::Mat & leftImage,
81  const cv::Mat & rightImage,
82  const std::vector<cv::Point2f> & leftCorners,
83  float fx,
84  float baseline,
85  int flowWinSize = 9,
86  int flowMaxLevel = 4,
87  int flowIterations = 20,
88  double flowEps = 0.02);
89 
91  const cv::Size & disparitySize,
92  const std::vector<cv::Point2f> & leftCorners,
93  const std::vector<cv::Point2f> & rightCorners,
94  const std::vector<unsigned char> & mask);
95 
97  const cv::Mat & leftImage,
98  const std::vector<cv::Point2f> & leftCorners,
99  const std::vector<cv::Point2f> & rightCorners,
100  const std::vector<unsigned char> & mask,
101  float fx, float baseline);
102 
103 cv::Mat RTABMAP_EXP cvtDepthFromFloat(const cv::Mat & depth32F);
104 cv::Mat RTABMAP_EXP cvtDepthToFloat(const cv::Mat & depth16U);
105 
106 float RTABMAP_EXP getDepth(
107  const cv::Mat & depthImage,
108  float x, float y,
109  bool smoothing,
110  float depthErrorRatio = 0.02f, //ratio
111  bool estWithNeighborsIfNull = false);
112 
113 cv::Rect RTABMAP_EXP computeRoi(const cv::Mat & image, const std::string & roiRatios);
114 cv::Rect RTABMAP_EXP computeRoi(const cv::Size & imageSize, const std::string & roiRatios);
115 cv::Rect RTABMAP_EXP computeRoi(const cv::Mat & image, const std::vector<float> & roiRatios);
116 cv::Rect RTABMAP_EXP computeRoi(const cv::Size & imageSize, const std::vector<float> & roiRatios);
117 
118 cv::Mat RTABMAP_EXP decimate(const cv::Mat & image, int d);
119 cv::Mat RTABMAP_EXP interpolate(const cv::Mat & image, int factor, float depthErrorRatio = 0.02f);
120 
121 // Registration Depth to RGB (return registered depth image)
122 cv::Mat RTABMAP_EXP registerDepth(
123  const cv::Mat & depth,
124  const cv::Mat & depthK,
125  const cv::Size & colorSize,
126  const cv::Mat & colorK,
127  const rtabmap::Transform & transform);
128 
130  const cv::Mat & depth,
131  int maximumHoleSize = 1,
132  float errorRatio = 0.02f);
133 
135  cv::Mat & depthRegistered,
136  bool vertical,
137  bool horizontal,
138  bool fillDoubleHoles = false);
139 
141  const cv::Mat & depth,
142  float sigmaS = 15.0f,
143  float sigmaR = 0.05f,
144  bool earlyDivision = false);
145 
147  const cv::Mat & src,
148  const cv::Mat & mask,
149  float clipLowHistPercent=0,
150  float clipHighHistPercent=0);
151 
153  const std::vector<cv::Mat> & images);
154 
155 } // namespace util3d
156 } // namespace rtabmap
157 
158 #endif /* UTIL2D_H_ */
cv::Mat RTABMAP_EXP disparityFromStereoImages(const cv::Mat &leftImage, const cv::Mat &rightImage, const ParametersMap &parameters=ParametersMap())
Definition: util2d.cpp:734
d
GLM_FUNC_DECL genIType mask(genIType const &count)
cv::Mat RTABMAP_EXP depthFromStereoCorrespondences(const cv::Mat &leftImage, const std::vector< cv::Point2f > &leftCorners, const std::vector< cv::Point2f > &rightCorners, const std::vector< unsigned char > &mask, float fx, float baseline)
Definition: util2d.cpp:862
cv::Mat RTABMAP_EXP cvtDepthToFloat(const cv::Mat &depth16U)
Definition: util2d.cpp:923
f
cv::Mat RTABMAP_EXP depthFromDisparity(const cv::Mat &disparity, float fx, float baseline, int type=CV_32FC1)
Definition: util2d.cpp:758
GLM_FUNC_DECL genType e()
std::map< std::string, std::string > ParametersMap
Definition: Parameters.h:41
cv::Mat RTABMAP_EXP fastBilateralFiltering(const cv::Mat &depth, float sigmaS=15.0f, float sigmaR=0.05f, bool earlyDivision=false)
Definition: util2d.cpp:1809
cv::Mat RTABMAP_EXP registerDepth(const cv::Mat &depth, const cv::Mat &depthK, const cv::Size &colorSize, const cv::Mat &colorK, const rtabmap::Transform &transform)
Definition: util2d.cpp:1357
cv::Mat RTABMAP_EXP depthFromStereoImages(const cv::Mat &leftImage, const cv::Mat &rightImage, const std::vector< cv::Point2f > &leftCorners, float fx, float baseline, int flowWinSize=9, int flowMaxLevel=4, int flowIterations=20, double flowEps=0.02)
Definition: util2d.cpp:803
cv::Mat RTABMAP_EXP interpolate(const cv::Mat &image, int factor, float depthErrorRatio=0.02f)
Definition: util2d.cpp:1245
float RTABMAP_EXP ssd(const cv::Mat &windowLeft, const cv::Mat &windowRight)
Definition: util2d.cpp:56
#define RTABMAP_EXP
Definition: RtabmapExp.h:38
cv::Mat RTABMAP_EXP decimate(const cv::Mat &image, int d)
Definition: util2d.cpp:1196
cv::Mat RTABMAP_EXP brightnessAndContrastAuto(const cv::Mat &src, const cv::Mat &mask, float clipLowHistPercent=0, float clipHighHistPercent=0)
Automatic brightness and contrast optimization with optional histogram clipping.
Definition: util2d.cpp:1937
cv::Mat RTABMAP_EXP disparityFromStereoCorrespondences(const cv::Size &disparitySize, const std::vector< cv::Point2f > &leftCorners, const std::vector< cv::Point2f > &rightCorners, const std::vector< unsigned char > &mask)
Definition: util2d.cpp:840
cv::Rect RTABMAP_EXP computeRoi(const cv::Mat &image, const std::string &roiRatios)
Definition: util2d.cpp:1108
void RTABMAP_EXP fillRegisteredDepthHoles(cv::Mat &depthRegistered, bool vertical, bool horizontal, bool fillDoubleHoles=false)
Definition: util2d.cpp:1593
cv::Mat RTABMAP_EXP exposureFusion(const std::vector< cv::Mat > &images)
Definition: util2d.cpp:2012
cv::Mat RTABMAP_EXP fillDepthHoles(const cv::Mat &depth, int maximumHoleSize=1, float errorRatio=0.02f)
Definition: util2d.cpp:1434
float RTABMAP_EXP sad(const cv::Mat &windowLeft, const cv::Mat &windowRight)
Definition: util2d.cpp:91
cv::Mat RTABMAP_EXP cvtDepthFromFloat(const cv::Mat &depth32F)
Definition: util2d.cpp:887
float RTABMAP_EXP getDepth(const cv::Mat &depthImage, float x, float y, bool smoothing, float depthErrorRatio=0.02f, bool estWithNeighborsIfNull=false)
Definition: util2d.cpp:942
std::vector< cv::Point2f > RTABMAP_EXP calcStereoCorrespondences(const cv::Mat &leftImage, const cv::Mat &rightImage, const std::vector< cv::Point2f > &leftCorners, std::vector< unsigned char > &status, cv::Size winSize=cv::Size(6, 3), int maxLevel=3, int iterations=5, float minDisparity=0.0f, float maxDisparity=64.0f, bool ssdApproach=true)
Definition: util2d.cpp:122
void RTABMAP_EXP calcOpticalFlowPyrLKStereo(cv::InputArray _prevImg, cv::InputArray _nextImg, cv::InputArray _prevPts, cv::InputOutputArray _nextPts, cv::OutputArray _status, cv::OutputArray _err, cv::Size winSize=cv::Size(15, 3), int maxLevel=3, cv::TermCriteria criteria=cv::TermCriteria(cv::TermCriteria::COUNT+cv::TermCriteria::EPS, 30, 0.01), int flags=0, double minEigThreshold=1e-4)
Definition: util2d.cpp:367


rtabmap
Author(s): Mathieu Labbe
autogenerated on Wed Jun 5 2019 22:43:40