|
43 | 43 | namespace cv {
|
44 | 44 | namespace ximgproc {
|
45 | 45 |
|
| 46 | +//! @addtogroup ximgproc_filters |
| 47 | +//! @{ |
| 48 | + |
| 49 | +/** @brief Main interface for all disparity map filters. |
| 50 | + */ |
46 | 51 | class CV_EXPORTS_W DisparityFilter : public Algorithm
|
47 | 52 | {
|
48 | 53 | public:
|
49 |
| - CV_WRAP virtual void filter(InputArray disparity_map, InputArray left_view, OutputArray filtered_disparity_map,Rect ROI) = 0; |
50 |
| -}; |
51 | 54 |
|
52 |
| -///////////////////////////////////////////////////////////////////////////////////////////////// |
| 55 | + /** @brief Apply filtering to the disparity map. |
53 | 56 |
|
54 |
| -class CV_EXPORTS_W DisparityDTFilter : public DisparityFilter |
55 |
| -{ |
56 |
| -public: |
57 |
| - CV_WRAP virtual double getSigmaSpatial() = 0; |
58 |
| - CV_WRAP virtual void setSigmaSpatial(double _sigmaSpatial) = 0; |
59 |
| - CV_WRAP virtual double getSigmaColor() = 0; |
60 |
| - CV_WRAP virtual void setSigmaColor(double _sigmaColor) = 0; |
61 |
| -}; |
| 57 | + @param disparity_map_left disparity map of the left view, 1 channel, CV_16S type. Implicitly assumes that disparity |
| 58 | + values are scaled by 16 (one-pixel disparity corresponds to the value of 16 in the disparity map). Disparity map |
| 59 | + can have any resolution, it will be automatically resized to fit left_view resolution. |
62 | 60 |
|
63 |
| -CV_EXPORTS_W |
64 |
| -Ptr<DisparityDTFilter> createDisparityDTFilter(); |
| 61 | + @param left_view left view of the original stereo-pair to guide the filtering process, 8-bit single-channel |
| 62 | + or three-channel image. |
65 | 63 |
|
66 |
| -class CV_EXPORTS_W DisparityGuidedFilter : public DisparityFilter |
67 |
| -{ |
68 |
| -public: |
69 |
| - CV_WRAP virtual double getEps() = 0; |
70 |
| - CV_WRAP virtual void setEps(double _eps) = 0; |
71 |
| - CV_WRAP virtual int getRadius() = 0; |
72 |
| - CV_WRAP virtual void setRadius(int _radius) = 0; |
73 |
| -}; |
| 64 | + @param filtered_disparity_map output disparity map. |
74 | 65 |
|
75 |
| -CV_EXPORTS_W |
76 |
| -Ptr<DisparityGuidedFilter> createDisparityGuidedFilter(); |
| 66 | + @param ROI region of the disparity map to filter. |
77 | 67 |
|
| 68 | + @param disparity_map_right optional argument, some implementations might also use the disparity map |
| 69 | + of the right view to compute confidence maps, for instance. |
| 70 | +
|
| 71 | + @param right_view optional argument, some implementations might also use the right view of the original |
| 72 | + stereo-pair. |
| 73 | + */ |
| 74 | + CV_WRAP virtual void filter(InputArray disparity_map_left, InputArray left_view, OutputArray filtered_disparity_map, Rect ROI, InputArray disparity_map_right = Mat(), InputArray right_view = Mat()) = 0; |
| 75 | +}; |
| 76 | + |
| 77 | +/** @brief Disparity map filter based on Weighted Least Squares filter (in form of Fast Global Smoother that |
| 78 | +is a lot faster than traditional Weighted Least Squares filter implementations) and optional use of |
| 79 | +left-right-consistency-based confidence to refine the results in half-occlusions and uniform areas. |
| 80 | + */ |
78 | 81 | class CV_EXPORTS_W DisparityWLSFilter : public DisparityFilter
|
79 | 82 | {
|
| 83 | +public: |
| 84 | + /** filter parameters */ |
| 85 | + |
| 86 | + /** @brief Lambda is a parameter defining the amount of regularization during filtering. Larger values force |
| 87 | + filtered disparity map edges to adhere more to source image edges. Typical value is 8000. |
| 88 | + */ |
80 | 89 | CV_WRAP virtual double getLambda() = 0;
|
| 90 | + /** @see getLambda */ |
81 | 91 | CV_WRAP virtual void setLambda(double _lambda) = 0;
|
| 92 | + /** @brief SigmaColor is a parameter defining how sensitive the filtering process is to source image edges. |
| 93 | + Large values can lead to disparity leakage through low-contrast edges. Small values can make the filter too |
| 94 | + sensitive to noise and textures in the source image. Typical values range from 0.8 to 2.0. |
| 95 | + */ |
82 | 96 | CV_WRAP virtual double getSigmaColor() = 0;
|
| 97 | + /** @see getSigmaColor */ |
83 | 98 | CV_WRAP virtual void setSigmaColor(double _sigma_color) = 0;
|
| 99 | + |
| 100 | + /** confidence-related parameters */ |
| 101 | + |
| 102 | + /** @brief LRCthresh is a threshold of disparity difference used in left-right-consistency check during |
| 103 | + confidence map computation. The default value of 24 (1.5 pixels) is virtually always good enough. |
| 104 | + */ |
| 105 | + CV_WRAP virtual int getLRCthresh() = 0; |
| 106 | + /** @see getLRCthresh */ |
| 107 | + CV_WRAP virtual void setLRCthresh(int _LRC_thresh) = 0; |
| 108 | + /** @brief DepthDiscontinuityRadius is a parameter used in confidence computation. It defines the size of |
| 109 | + low-confidence regions around depth discontinuities. For typical window sizes used in stereo matching the |
| 110 | + optimal value is around 5. |
| 111 | + */ |
| 112 | + CV_WRAP virtual int getDepthDiscontinuityRadius() = 0; |
| 113 | + /** @see getDepthDiscontinuityRadius */ |
| 114 | + CV_WRAP virtual void setDepthDiscontinuityRadius(int _disc_radius) = 0; |
| 115 | + /** @brief Get the confidence map that was used in the last filter call. It is a CV_32F one-channel image |
| 116 | + with values ranging from 0.0 (totally untrusted regions of the raw disparity map) to 255.0 (regions containing |
| 117 | + correct disparity values with a high degree of confidence). |
| 118 | + */ |
| 119 | + CV_WRAP virtual Mat getConfidenceMap() = 0; |
| 120 | + |
84 | 121 | };
|
85 | 122 |
|
| 123 | +/** @brief Factory method, create instance of DisparityWLSFilter and execute the initialization routines. |
| 124 | +
|
| 125 | +@param use_confidence filtering with confidence requires two disparity maps (for the left and right views) and is |
| 126 | +approximately two times slower. However, quality is typically significantly better. |
| 127 | +*/ |
86 | 128 | CV_EXPORTS_W
|
87 |
| -Ptr<DisparityWLSFilter> createDisparityWLSFilter(); |
| 129 | +Ptr<DisparityWLSFilter> createDisparityWLSFilter(bool use_confidence); |
| 130 | + |
| 131 | +////////////////////////////////////////////////////////////////////////// |
| 132 | +////////////////////////////////////////////////////////////////////////// |
| 133 | + |
| 134 | +/** @brief Function for reading ground truth disparity maps. Supports basic Middlebury |
| 135 | +and MPI-Sintel formats. Note that the resulting disparity map is scaled by 16. |
| 136 | +
|
| 137 | +@param src_path path to the image, containing ground-truth disparity map |
| 138 | +
|
| 139 | +@param dst output disparity map, CV_16S depth |
| 140 | +
|
| 141 | +@result returns zero if successfully read the ground truth |
| 142 | + */ |
| 143 | +CV_EXPORTS |
| 144 | +int readGT(String src_path,OutputArray dst); |
| 145 | + |
| 146 | +/** @brief Function for computing mean square error for disparity maps |
| 147 | +
|
| 148 | +@param GT ground truth disparity map |
| 149 | +
|
| 150 | +@param src disparity map to evaluate |
| 151 | +
|
| 152 | +@param ROI region of interest |
| 153 | +
|
| 154 | +@result returns mean square error between GT and src |
| 155 | + */ |
| 156 | +CV_EXPORTS |
| 157 | +double computeMSE(InputArray GT, InputArray src, Rect ROI); |
| 158 | + |
| 159 | +/** @brief Function for computing the percent of "bad" pixels in the disparity map |
| 160 | +(pixels where error is higher than a specified threshold) |
| 161 | +
|
| 162 | +@param GT ground truth disparity map |
| 163 | +
|
| 164 | +@param src disparity map to evaluate |
| 165 | +
|
| 166 | +@param ROI region of interest |
| 167 | +
|
| 168 | +@param thresh threshold used to determine "bad" pixels |
| 169 | +
|
| 170 | +@result returns mean square error between GT and src |
| 171 | + */ |
| 172 | +CV_EXPORTS |
| 173 | +double computeBadPixelPercent(InputArray GT, InputArray src, Rect ROI, int thresh=24/*1.5 pixels*/); |
| 174 | + |
| 175 | +/** @brief Function for creating a disparity map visualization (clamped CV_8U image) |
| 176 | +
|
| 177 | +@param src input disparity map (CV_16S depth) |
| 178 | +
|
| 179 | +@param dst output visualization |
| 180 | +
|
| 181 | +@param scale disparity map will be multiplied by this value for visualization |
| 182 | + */ |
| 183 | +CV_EXPORTS |
| 184 | +void getDisparityVis(InputArray src,OutputArray dst,double scale=1.0); |
88 | 185 |
|
| 186 | +//! @} |
89 | 187 | }
|
90 | 188 | }
|
91 | 189 | #endif
|
|
0 commit comments