openCV library for Renesas RZ/A
Dependents: RZ_A2M_Mbed_samples
include/opencv2/stitching/detail/motion_estimators.hpp@0:0e0631af0305, 2021-01-29 (annotated)
- Committer:
- RyoheiHagimoto
- Date:
- Fri Jan 29 04:53:38 2021 +0000
- Revision:
- 0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RyoheiHagimoto | 0:0e0631af0305 | 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2 | // |
RyoheiHagimoto | 0:0e0631af0305 | 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. |
RyoheiHagimoto | 0:0e0631af0305 | 4 | // |
RyoheiHagimoto | 0:0e0631af0305 | 5 | // By downloading, copying, installing or using the software you agree to this license. |
RyoheiHagimoto | 0:0e0631af0305 | 6 | // If you do not agree to this license, do not download, install, |
RyoheiHagimoto | 0:0e0631af0305 | 7 | // copy or use the software. |
RyoheiHagimoto | 0:0e0631af0305 | 8 | // |
RyoheiHagimoto | 0:0e0631af0305 | 9 | // |
RyoheiHagimoto | 0:0e0631af0305 | 10 | // License Agreement |
RyoheiHagimoto | 0:0e0631af0305 | 11 | // For Open Source Computer Vision Library |
RyoheiHagimoto | 0:0e0631af0305 | 12 | // |
RyoheiHagimoto | 0:0e0631af0305 | 13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 14 | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 15 | // Third party copyrights are property of their respective owners. |
RyoheiHagimoto | 0:0e0631af0305 | 16 | // |
RyoheiHagimoto | 0:0e0631af0305 | 17 | // Redistribution and use in source and binary forms, with or without modification, |
RyoheiHagimoto | 0:0e0631af0305 | 18 | // are permitted provided that the following conditions are met: |
RyoheiHagimoto | 0:0e0631af0305 | 19 | // |
RyoheiHagimoto | 0:0e0631af0305 | 20 | // * Redistribution's of source code must retain the above copyright notice, |
RyoheiHagimoto | 0:0e0631af0305 | 21 | // this list of conditions and the following disclaimer. |
RyoheiHagimoto | 0:0e0631af0305 | 22 | // |
RyoheiHagimoto | 0:0e0631af0305 | 23 | // * Redistribution's in binary form must reproduce the above copyright notice, |
RyoheiHagimoto | 0:0e0631af0305 | 24 | // this list of conditions and the following disclaimer in the documentation |
RyoheiHagimoto | 0:0e0631af0305 | 25 | // and/or other materials provided with the distribution. |
RyoheiHagimoto | 0:0e0631af0305 | 26 | // |
RyoheiHagimoto | 0:0e0631af0305 | 27 | // * The name of the copyright holders may not be used to endorse or promote products |
RyoheiHagimoto | 0:0e0631af0305 | 28 | // derived from this software without specific prior written permission. |
RyoheiHagimoto | 0:0e0631af0305 | 29 | // |
RyoheiHagimoto | 0:0e0631af0305 | 30 | // This software is provided by the copyright holders and contributors "as is" and |
RyoheiHagimoto | 0:0e0631af0305 | 31 | // any express or implied warranties, including, but not limited to, the implied |
RyoheiHagimoto | 0:0e0631af0305 | 32 | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
RyoheiHagimoto | 0:0e0631af0305 | 33 | // In no event shall the Intel Corporation or contributors be liable for any direct, |
RyoheiHagimoto | 0:0e0631af0305 | 34 | // indirect, incidental, special, exemplary, or consequential damages |
RyoheiHagimoto | 0:0e0631af0305 | 35 | // (including, but not limited to, procurement of substitute goods or services; |
RyoheiHagimoto | 0:0e0631af0305 | 36 | // loss of use, data, or profits; or business interruption) however caused |
RyoheiHagimoto | 0:0e0631af0305 | 37 | // and on any theory of liability, whether in contract, strict liability, |
RyoheiHagimoto | 0:0e0631af0305 | 38 | // or tort (including negligence or otherwise) arising in any way out of |
RyoheiHagimoto | 0:0e0631af0305 | 39 | // the use of this software, even if advised of the possibility of such damage. |
RyoheiHagimoto | 0:0e0631af0305 | 40 | // |
RyoheiHagimoto | 0:0e0631af0305 | 41 | //M*/ |
RyoheiHagimoto | 0:0e0631af0305 | 42 | |
RyoheiHagimoto | 0:0e0631af0305 | 43 | #ifndef OPENCV_STITCHING_MOTION_ESTIMATORS_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 44 | #define OPENCV_STITCHING_MOTION_ESTIMATORS_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 45 | |
RyoheiHagimoto | 0:0e0631af0305 | 46 | #include "opencv2/core.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 47 | #include "matchers.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 48 | #include "util.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 49 | #include "camera.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 50 | |
RyoheiHagimoto | 0:0e0631af0305 | 51 | namespace cv { |
RyoheiHagimoto | 0:0e0631af0305 | 52 | namespace detail { |
RyoheiHagimoto | 0:0e0631af0305 | 53 | |
RyoheiHagimoto | 0:0e0631af0305 | 54 | //! @addtogroup stitching_rotation |
RyoheiHagimoto | 0:0e0631af0305 | 55 | //! @{ |
RyoheiHagimoto | 0:0e0631af0305 | 56 | |
RyoheiHagimoto | 0:0e0631af0305 | 57 | /** @brief Rotation estimator base class. |
RyoheiHagimoto | 0:0e0631af0305 | 58 | |
RyoheiHagimoto | 0:0e0631af0305 | 59 | It takes features of all images, pairwise matches between all images and estimates rotations of all |
RyoheiHagimoto | 0:0e0631af0305 | 60 | cameras. |
RyoheiHagimoto | 0:0e0631af0305 | 61 | |
RyoheiHagimoto | 0:0e0631af0305 | 62 | @note The coordinate system origin is implementation-dependent, but you can always normalize the |
RyoheiHagimoto | 0:0e0631af0305 | 63 | rotations in respect to the first camera, for instance. : |
RyoheiHagimoto | 0:0e0631af0305 | 64 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 65 | class CV_EXPORTS Estimator |
RyoheiHagimoto | 0:0e0631af0305 | 66 | { |
RyoheiHagimoto | 0:0e0631af0305 | 67 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 68 | virtual ~Estimator() {} |
RyoheiHagimoto | 0:0e0631af0305 | 69 | |
RyoheiHagimoto | 0:0e0631af0305 | 70 | /** @brief Estimates camera parameters. |
RyoheiHagimoto | 0:0e0631af0305 | 71 | |
RyoheiHagimoto | 0:0e0631af0305 | 72 | @param features Features of images |
RyoheiHagimoto | 0:0e0631af0305 | 73 | @param pairwise_matches Pairwise matches of images |
RyoheiHagimoto | 0:0e0631af0305 | 74 | @param cameras Estimated camera parameters |
RyoheiHagimoto | 0:0e0631af0305 | 75 | @return True in case of success, false otherwise |
RyoheiHagimoto | 0:0e0631af0305 | 76 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 77 | bool operator ()(const std::vector<ImageFeatures> &features, |
RyoheiHagimoto | 0:0e0631af0305 | 78 | const std::vector<MatchesInfo> &pairwise_matches, |
RyoheiHagimoto | 0:0e0631af0305 | 79 | std::vector<CameraParams> &cameras) |
RyoheiHagimoto | 0:0e0631af0305 | 80 | { return estimate(features, pairwise_matches, cameras); } |
RyoheiHagimoto | 0:0e0631af0305 | 81 | |
RyoheiHagimoto | 0:0e0631af0305 | 82 | protected: |
RyoheiHagimoto | 0:0e0631af0305 | 83 | /** @brief This method must implement camera parameters estimation logic in order to make the wrapper |
RyoheiHagimoto | 0:0e0631af0305 | 84 | detail::Estimator::operator()_ work. |
RyoheiHagimoto | 0:0e0631af0305 | 85 | |
RyoheiHagimoto | 0:0e0631af0305 | 86 | @param features Features of images |
RyoheiHagimoto | 0:0e0631af0305 | 87 | @param pairwise_matches Pairwise matches of images |
RyoheiHagimoto | 0:0e0631af0305 | 88 | @param cameras Estimated camera parameters |
RyoheiHagimoto | 0:0e0631af0305 | 89 | @return True in case of success, false otherwise |
RyoheiHagimoto | 0:0e0631af0305 | 90 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 91 | virtual bool estimate(const std::vector<ImageFeatures> &features, |
RyoheiHagimoto | 0:0e0631af0305 | 92 | const std::vector<MatchesInfo> &pairwise_matches, |
RyoheiHagimoto | 0:0e0631af0305 | 93 | std::vector<CameraParams> &cameras) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 94 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 95 | |
RyoheiHagimoto | 0:0e0631af0305 | 96 | /** @brief Homography based rotation estimator. |
RyoheiHagimoto | 0:0e0631af0305 | 97 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 98 | class CV_EXPORTS HomographyBasedEstimator : public Estimator |
RyoheiHagimoto | 0:0e0631af0305 | 99 | { |
RyoheiHagimoto | 0:0e0631af0305 | 100 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 101 | HomographyBasedEstimator(bool is_focals_estimated = false) |
RyoheiHagimoto | 0:0e0631af0305 | 102 | : is_focals_estimated_(is_focals_estimated) {} |
RyoheiHagimoto | 0:0e0631af0305 | 103 | |
RyoheiHagimoto | 0:0e0631af0305 | 104 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 105 | virtual bool estimate(const std::vector<ImageFeatures> &features, |
RyoheiHagimoto | 0:0e0631af0305 | 106 | const std::vector<MatchesInfo> &pairwise_matches, |
RyoheiHagimoto | 0:0e0631af0305 | 107 | std::vector<CameraParams> &cameras); |
RyoheiHagimoto | 0:0e0631af0305 | 108 | |
RyoheiHagimoto | 0:0e0631af0305 | 109 | bool is_focals_estimated_; |
RyoheiHagimoto | 0:0e0631af0305 | 110 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 111 | |
RyoheiHagimoto | 0:0e0631af0305 | 112 | /** @brief Affine transformation based estimator. |
RyoheiHagimoto | 0:0e0631af0305 | 113 | |
RyoheiHagimoto | 0:0e0631af0305 | 114 | This estimator uses pairwise tranformations estimated by matcher to estimate |
RyoheiHagimoto | 0:0e0631af0305 | 115 | final transformation for each camera. |
RyoheiHagimoto | 0:0e0631af0305 | 116 | |
RyoheiHagimoto | 0:0e0631af0305 | 117 | @sa cv::detail::HomographyBasedEstimator |
RyoheiHagimoto | 0:0e0631af0305 | 118 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 119 | class CV_EXPORTS AffineBasedEstimator : public Estimator |
RyoheiHagimoto | 0:0e0631af0305 | 120 | { |
RyoheiHagimoto | 0:0e0631af0305 | 121 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 122 | virtual bool estimate(const std::vector<ImageFeatures> &features, |
RyoheiHagimoto | 0:0e0631af0305 | 123 | const std::vector<MatchesInfo> &pairwise_matches, |
RyoheiHagimoto | 0:0e0631af0305 | 124 | std::vector<CameraParams> &cameras); |
RyoheiHagimoto | 0:0e0631af0305 | 125 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 126 | |
RyoheiHagimoto | 0:0e0631af0305 | 127 | /** @brief Base class for all camera parameters refinement methods. |
RyoheiHagimoto | 0:0e0631af0305 | 128 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 129 | class CV_EXPORTS BundleAdjusterBase : public Estimator |
RyoheiHagimoto | 0:0e0631af0305 | 130 | { |
RyoheiHagimoto | 0:0e0631af0305 | 131 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 132 | const Mat refinementMask() const { return refinement_mask_.clone(); } |
RyoheiHagimoto | 0:0e0631af0305 | 133 | void setRefinementMask(const Mat &mask) |
RyoheiHagimoto | 0:0e0631af0305 | 134 | { |
RyoheiHagimoto | 0:0e0631af0305 | 135 | CV_Assert(mask.type() == CV_8U && mask.size() == Size(3, 3)); |
RyoheiHagimoto | 0:0e0631af0305 | 136 | refinement_mask_ = mask.clone(); |
RyoheiHagimoto | 0:0e0631af0305 | 137 | } |
RyoheiHagimoto | 0:0e0631af0305 | 138 | |
RyoheiHagimoto | 0:0e0631af0305 | 139 | double confThresh() const { return conf_thresh_; } |
RyoheiHagimoto | 0:0e0631af0305 | 140 | void setConfThresh(double conf_thresh) { conf_thresh_ = conf_thresh; } |
RyoheiHagimoto | 0:0e0631af0305 | 141 | |
RyoheiHagimoto | 0:0e0631af0305 | 142 | TermCriteria termCriteria() { return term_criteria_; } |
RyoheiHagimoto | 0:0e0631af0305 | 143 | void setTermCriteria(const TermCriteria& term_criteria) { term_criteria_ = term_criteria; } |
RyoheiHagimoto | 0:0e0631af0305 | 144 | |
RyoheiHagimoto | 0:0e0631af0305 | 145 | protected: |
RyoheiHagimoto | 0:0e0631af0305 | 146 | /** @brief Construct a bundle adjuster base instance. |
RyoheiHagimoto | 0:0e0631af0305 | 147 | |
RyoheiHagimoto | 0:0e0631af0305 | 148 | @param num_params_per_cam Number of parameters per camera |
RyoheiHagimoto | 0:0e0631af0305 | 149 | @param num_errs_per_measurement Number of error terms (components) per match |
RyoheiHagimoto | 0:0e0631af0305 | 150 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 151 | BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement) |
RyoheiHagimoto | 0:0e0631af0305 | 152 | : num_params_per_cam_(num_params_per_cam), |
RyoheiHagimoto | 0:0e0631af0305 | 153 | num_errs_per_measurement_(num_errs_per_measurement) |
RyoheiHagimoto | 0:0e0631af0305 | 154 | { |
RyoheiHagimoto | 0:0e0631af0305 | 155 | setRefinementMask(Mat::ones(3, 3, CV_8U)); |
RyoheiHagimoto | 0:0e0631af0305 | 156 | setConfThresh(1.); |
RyoheiHagimoto | 0:0e0631af0305 | 157 | setTermCriteria(TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 1000, DBL_EPSILON)); |
RyoheiHagimoto | 0:0e0631af0305 | 158 | } |
RyoheiHagimoto | 0:0e0631af0305 | 159 | |
RyoheiHagimoto | 0:0e0631af0305 | 160 | // Runs bundle adjustment |
RyoheiHagimoto | 0:0e0631af0305 | 161 | virtual bool estimate(const std::vector<ImageFeatures> &features, |
RyoheiHagimoto | 0:0e0631af0305 | 162 | const std::vector<MatchesInfo> &pairwise_matches, |
RyoheiHagimoto | 0:0e0631af0305 | 163 | std::vector<CameraParams> &cameras); |
RyoheiHagimoto | 0:0e0631af0305 | 164 | |
RyoheiHagimoto | 0:0e0631af0305 | 165 | /** @brief Sets initial camera parameter to refine. |
RyoheiHagimoto | 0:0e0631af0305 | 166 | |
RyoheiHagimoto | 0:0e0631af0305 | 167 | @param cameras Camera parameters |
RyoheiHagimoto | 0:0e0631af0305 | 168 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 169 | virtual void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 170 | /** @brief Gets the refined camera parameters. |
RyoheiHagimoto | 0:0e0631af0305 | 171 | |
RyoheiHagimoto | 0:0e0631af0305 | 172 | @param cameras Refined camera parameters |
RyoheiHagimoto | 0:0e0631af0305 | 173 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 174 | virtual void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 175 | /** @brief Calculates error vector. |
RyoheiHagimoto | 0:0e0631af0305 | 176 | |
RyoheiHagimoto | 0:0e0631af0305 | 177 | @param err Error column-vector of length total_num_matches \* num_errs_per_measurement |
RyoheiHagimoto | 0:0e0631af0305 | 178 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 179 | virtual void calcError(Mat &err) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 180 | /** @brief Calculates the cost function jacobian. |
RyoheiHagimoto | 0:0e0631af0305 | 181 | |
RyoheiHagimoto | 0:0e0631af0305 | 182 | @param jac Jacobian matrix of dimensions |
RyoheiHagimoto | 0:0e0631af0305 | 183 | (total_num_matches \* num_errs_per_measurement) x (num_images \* num_params_per_cam) |
RyoheiHagimoto | 0:0e0631af0305 | 184 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 185 | virtual void calcJacobian(Mat &jac) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 186 | |
RyoheiHagimoto | 0:0e0631af0305 | 187 | // 3x3 8U mask, where 0 means don't refine respective parameter, != 0 means refine |
RyoheiHagimoto | 0:0e0631af0305 | 188 | Mat refinement_mask_; |
RyoheiHagimoto | 0:0e0631af0305 | 189 | |
RyoheiHagimoto | 0:0e0631af0305 | 190 | int num_images_; |
RyoheiHagimoto | 0:0e0631af0305 | 191 | int total_num_matches_; |
RyoheiHagimoto | 0:0e0631af0305 | 192 | |
RyoheiHagimoto | 0:0e0631af0305 | 193 | int num_params_per_cam_; |
RyoheiHagimoto | 0:0e0631af0305 | 194 | int num_errs_per_measurement_; |
RyoheiHagimoto | 0:0e0631af0305 | 195 | |
RyoheiHagimoto | 0:0e0631af0305 | 196 | const ImageFeatures *features_; |
RyoheiHagimoto | 0:0e0631af0305 | 197 | const MatchesInfo *pairwise_matches_; |
RyoheiHagimoto | 0:0e0631af0305 | 198 | |
RyoheiHagimoto | 0:0e0631af0305 | 199 | // Threshold to filter out poorly matched image pairs |
RyoheiHagimoto | 0:0e0631af0305 | 200 | double conf_thresh_; |
RyoheiHagimoto | 0:0e0631af0305 | 201 | |
RyoheiHagimoto | 0:0e0631af0305 | 202 | //Levenberg–Marquardt algorithm termination criteria |
RyoheiHagimoto | 0:0e0631af0305 | 203 | TermCriteria term_criteria_; |
RyoheiHagimoto | 0:0e0631af0305 | 204 | |
RyoheiHagimoto | 0:0e0631af0305 | 205 | // Camera parameters matrix (CV_64F) |
RyoheiHagimoto | 0:0e0631af0305 | 206 | Mat cam_params_; |
RyoheiHagimoto | 0:0e0631af0305 | 207 | |
RyoheiHagimoto | 0:0e0631af0305 | 208 | // Connected images pairs |
RyoheiHagimoto | 0:0e0631af0305 | 209 | std::vector<std::pair<int,int> > edges_; |
RyoheiHagimoto | 0:0e0631af0305 | 210 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 211 | |
RyoheiHagimoto | 0:0e0631af0305 | 212 | |
RyoheiHagimoto | 0:0e0631af0305 | 213 | /** @brief Stub bundle adjuster that does nothing. |
RyoheiHagimoto | 0:0e0631af0305 | 214 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 215 | class CV_EXPORTS NoBundleAdjuster : public BundleAdjusterBase |
RyoheiHagimoto | 0:0e0631af0305 | 216 | { |
RyoheiHagimoto | 0:0e0631af0305 | 217 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 218 | NoBundleAdjuster() : BundleAdjusterBase(0, 0) {} |
RyoheiHagimoto | 0:0e0631af0305 | 219 | |
RyoheiHagimoto | 0:0e0631af0305 | 220 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 221 | bool estimate(const std::vector<ImageFeatures> &, const std::vector<MatchesInfo> &, |
RyoheiHagimoto | 0:0e0631af0305 | 222 | std::vector<CameraParams> &) |
RyoheiHagimoto | 0:0e0631af0305 | 223 | { |
RyoheiHagimoto | 0:0e0631af0305 | 224 | return true; |
RyoheiHagimoto | 0:0e0631af0305 | 225 | } |
RyoheiHagimoto | 0:0e0631af0305 | 226 | void setUpInitialCameraParams(const std::vector<CameraParams> &) {} |
RyoheiHagimoto | 0:0e0631af0305 | 227 | void obtainRefinedCameraParams(std::vector<CameraParams> &) const {} |
RyoheiHagimoto | 0:0e0631af0305 | 228 | void calcError(Mat &) {} |
RyoheiHagimoto | 0:0e0631af0305 | 229 | void calcJacobian(Mat &) {} |
RyoheiHagimoto | 0:0e0631af0305 | 230 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 231 | |
RyoheiHagimoto | 0:0e0631af0305 | 232 | |
RyoheiHagimoto | 0:0e0631af0305 | 233 | /** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the reprojection |
RyoheiHagimoto | 0:0e0631af0305 | 234 | error squares |
RyoheiHagimoto | 0:0e0631af0305 | 235 | |
RyoheiHagimoto | 0:0e0631af0305 | 236 | It can estimate focal length, aspect ratio, principal point. |
RyoheiHagimoto | 0:0e0631af0305 | 237 | You can affect only on them via the refinement mask. |
RyoheiHagimoto | 0:0e0631af0305 | 238 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 239 | class CV_EXPORTS BundleAdjusterReproj : public BundleAdjusterBase |
RyoheiHagimoto | 0:0e0631af0305 | 240 | { |
RyoheiHagimoto | 0:0e0631af0305 | 241 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 242 | BundleAdjusterReproj() : BundleAdjusterBase(7, 2) {} |
RyoheiHagimoto | 0:0e0631af0305 | 243 | |
RyoheiHagimoto | 0:0e0631af0305 | 244 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 245 | void setUpInitialCameraParams(const std::vector<CameraParams> &cameras); |
RyoheiHagimoto | 0:0e0631af0305 | 246 | void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const; |
RyoheiHagimoto | 0:0e0631af0305 | 247 | void calcError(Mat &err); |
RyoheiHagimoto | 0:0e0631af0305 | 248 | void calcJacobian(Mat &jac); |
RyoheiHagimoto | 0:0e0631af0305 | 249 | |
RyoheiHagimoto | 0:0e0631af0305 | 250 | Mat err1_, err2_; |
RyoheiHagimoto | 0:0e0631af0305 | 251 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 252 | |
RyoheiHagimoto | 0:0e0631af0305 | 253 | |
RyoheiHagimoto | 0:0e0631af0305 | 254 | /** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the distances |
RyoheiHagimoto | 0:0e0631af0305 | 255 | between the rays passing through the camera center and a feature. : |
RyoheiHagimoto | 0:0e0631af0305 | 256 | |
RyoheiHagimoto | 0:0e0631af0305 | 257 | It can estimate focal length. It ignores the refinement mask for now. |
RyoheiHagimoto | 0:0e0631af0305 | 258 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 259 | class CV_EXPORTS BundleAdjusterRay : public BundleAdjusterBase |
RyoheiHagimoto | 0:0e0631af0305 | 260 | { |
RyoheiHagimoto | 0:0e0631af0305 | 261 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 262 | BundleAdjusterRay() : BundleAdjusterBase(4, 3) {} |
RyoheiHagimoto | 0:0e0631af0305 | 263 | |
RyoheiHagimoto | 0:0e0631af0305 | 264 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 265 | void setUpInitialCameraParams(const std::vector<CameraParams> &cameras); |
RyoheiHagimoto | 0:0e0631af0305 | 266 | void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const; |
RyoheiHagimoto | 0:0e0631af0305 | 267 | void calcError(Mat &err); |
RyoheiHagimoto | 0:0e0631af0305 | 268 | void calcJacobian(Mat &jac); |
RyoheiHagimoto | 0:0e0631af0305 | 269 | |
RyoheiHagimoto | 0:0e0631af0305 | 270 | Mat err1_, err2_; |
RyoheiHagimoto | 0:0e0631af0305 | 271 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 272 | |
RyoheiHagimoto | 0:0e0631af0305 | 273 | |
RyoheiHagimoto | 0:0e0631af0305 | 274 | /** @brief Bundle adjuster that expects affine transformation |
RyoheiHagimoto | 0:0e0631af0305 | 275 | represented in homogeneous coordinates in R for each camera param. Implements |
RyoheiHagimoto | 0:0e0631af0305 | 276 | camera parameters refinement algorithm which minimizes sum of the reprojection |
RyoheiHagimoto | 0:0e0631af0305 | 277 | error squares |
RyoheiHagimoto | 0:0e0631af0305 | 278 | |
RyoheiHagimoto | 0:0e0631af0305 | 279 | It estimates all transformation parameters. Refinement mask is ignored. |
RyoheiHagimoto | 0:0e0631af0305 | 280 | |
RyoheiHagimoto | 0:0e0631af0305 | 281 | @sa AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffinePartial |
RyoheiHagimoto | 0:0e0631af0305 | 282 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 283 | class CV_EXPORTS BundleAdjusterAffine : public BundleAdjusterBase |
RyoheiHagimoto | 0:0e0631af0305 | 284 | { |
RyoheiHagimoto | 0:0e0631af0305 | 285 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 286 | BundleAdjusterAffine() : BundleAdjusterBase(6, 2) {} |
RyoheiHagimoto | 0:0e0631af0305 | 287 | |
RyoheiHagimoto | 0:0e0631af0305 | 288 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 289 | void setUpInitialCameraParams(const std::vector<CameraParams> &cameras); |
RyoheiHagimoto | 0:0e0631af0305 | 290 | void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const; |
RyoheiHagimoto | 0:0e0631af0305 | 291 | void calcError(Mat &err); |
RyoheiHagimoto | 0:0e0631af0305 | 292 | void calcJacobian(Mat &jac); |
RyoheiHagimoto | 0:0e0631af0305 | 293 | |
RyoheiHagimoto | 0:0e0631af0305 | 294 | Mat err1_, err2_; |
RyoheiHagimoto | 0:0e0631af0305 | 295 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 296 | |
RyoheiHagimoto | 0:0e0631af0305 | 297 | |
RyoheiHagimoto | 0:0e0631af0305 | 298 | /** @brief Bundle adjuster that expects affine transformation with 4 DOF |
RyoheiHagimoto | 0:0e0631af0305 | 299 | represented in homogeneous coordinates in R for each camera param. Implements |
RyoheiHagimoto | 0:0e0631af0305 | 300 | camera parameters refinement algorithm which minimizes sum of the reprojection |
RyoheiHagimoto | 0:0e0631af0305 | 301 | error squares |
RyoheiHagimoto | 0:0e0631af0305 | 302 | |
RyoheiHagimoto | 0:0e0631af0305 | 303 | It estimates all transformation parameters. Refinement mask is ignored. |
RyoheiHagimoto | 0:0e0631af0305 | 304 | |
RyoheiHagimoto | 0:0e0631af0305 | 305 | @sa AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffine |
RyoheiHagimoto | 0:0e0631af0305 | 306 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 307 | class CV_EXPORTS BundleAdjusterAffinePartial : public BundleAdjusterBase |
RyoheiHagimoto | 0:0e0631af0305 | 308 | { |
RyoheiHagimoto | 0:0e0631af0305 | 309 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 310 | BundleAdjusterAffinePartial() : BundleAdjusterBase(4, 2) {} |
RyoheiHagimoto | 0:0e0631af0305 | 311 | |
RyoheiHagimoto | 0:0e0631af0305 | 312 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 313 | void setUpInitialCameraParams(const std::vector<CameraParams> &cameras); |
RyoheiHagimoto | 0:0e0631af0305 | 314 | void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const; |
RyoheiHagimoto | 0:0e0631af0305 | 315 | void calcError(Mat &err); |
RyoheiHagimoto | 0:0e0631af0305 | 316 | void calcJacobian(Mat &jac); |
RyoheiHagimoto | 0:0e0631af0305 | 317 | |
RyoheiHagimoto | 0:0e0631af0305 | 318 | Mat err1_, err2_; |
RyoheiHagimoto | 0:0e0631af0305 | 319 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 320 | |
RyoheiHagimoto | 0:0e0631af0305 | 321 | |
RyoheiHagimoto | 0:0e0631af0305 | 322 | enum WaveCorrectKind |
RyoheiHagimoto | 0:0e0631af0305 | 323 | { |
RyoheiHagimoto | 0:0e0631af0305 | 324 | WAVE_CORRECT_HORIZ, |
RyoheiHagimoto | 0:0e0631af0305 | 325 | WAVE_CORRECT_VERT |
RyoheiHagimoto | 0:0e0631af0305 | 326 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 327 | |
RyoheiHagimoto | 0:0e0631af0305 | 328 | /** @brief Tries to make panorama more horizontal (or vertical). |
RyoheiHagimoto | 0:0e0631af0305 | 329 | |
RyoheiHagimoto | 0:0e0631af0305 | 330 | @param rmats Camera rotation matrices. |
RyoheiHagimoto | 0:0e0631af0305 | 331 | @param kind Correction kind, see detail::WaveCorrectKind. |
RyoheiHagimoto | 0:0e0631af0305 | 332 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 333 | void CV_EXPORTS waveCorrect(std::vector<Mat> &rmats, WaveCorrectKind kind); |
RyoheiHagimoto | 0:0e0631af0305 | 334 | |
RyoheiHagimoto | 0:0e0631af0305 | 335 | |
RyoheiHagimoto | 0:0e0631af0305 | 336 | ////////////////////////////////////////////////////////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 337 | // Auxiliary functions |
RyoheiHagimoto | 0:0e0631af0305 | 338 | |
RyoheiHagimoto | 0:0e0631af0305 | 339 | // Returns matches graph representation in DOT language |
RyoheiHagimoto | 0:0e0631af0305 | 340 | String CV_EXPORTS matchesGraphAsString(std::vector<String> &pathes, std::vector<MatchesInfo> &pairwise_matches, |
RyoheiHagimoto | 0:0e0631af0305 | 341 | float conf_threshold); |
RyoheiHagimoto | 0:0e0631af0305 | 342 | |
RyoheiHagimoto | 0:0e0631af0305 | 343 | std::vector<int> CV_EXPORTS leaveBiggestComponent( |
RyoheiHagimoto | 0:0e0631af0305 | 344 | std::vector<ImageFeatures> &features, |
RyoheiHagimoto | 0:0e0631af0305 | 345 | std::vector<MatchesInfo> &pairwise_matches, |
RyoheiHagimoto | 0:0e0631af0305 | 346 | float conf_threshold); |
RyoheiHagimoto | 0:0e0631af0305 | 347 | |
RyoheiHagimoto | 0:0e0631af0305 | 348 | void CV_EXPORTS findMaxSpanningTree( |
RyoheiHagimoto | 0:0e0631af0305 | 349 | int num_images, const std::vector<MatchesInfo> &pairwise_matches, |
RyoheiHagimoto | 0:0e0631af0305 | 350 | Graph &span_tree, std::vector<int> ¢ers); |
RyoheiHagimoto | 0:0e0631af0305 | 351 | |
RyoheiHagimoto | 0:0e0631af0305 | 352 | //! @} stitching_rotation |
RyoheiHagimoto | 0:0e0631af0305 | 353 | |
RyoheiHagimoto | 0:0e0631af0305 | 354 | } // namespace detail |
RyoheiHagimoto | 0:0e0631af0305 | 355 | } // namespace cv |
RyoheiHagimoto | 0:0e0631af0305 | 356 | |
RyoheiHagimoto | 0:0e0631af0305 | 357 | #endif // OPENCV_STITCHING_MOTION_ESTIMATORS_HPP |