refactored stitching module
authorAlexey Spizhevoy <no@email>
Mon, 5 Sep 2011 11:52:30 +0000 (11:52 +0000)
committerAlexey Spizhevoy <no@email>
Mon, 5 Sep 2011 11:52:30 +0000 (11:52 +0000)
modules/stitching/src/autocalib.cpp
modules/stitching/src/blenders.cpp
modules/stitching/src/camera.cpp
modules/stitching/src/exposure_compensate.cpp
modules/stitching/src/matchers.cpp
modules/stitching/src/motion_estimators.cpp
modules/stitching/src/seam_finders.cpp
modules/stitching/src/util.cpp
modules/stitching/src/warpers.cpp

index 109eb01..806fe3d 100644 (file)
 #include "precomp.hpp"\r
 \r
 using namespace std;\r
+using namespace cv;\r
 \r
-namespace cv\r
+namespace\r
 {\r
+    template<typename _Tp> static inline bool\r
+    decomposeCholesky(_Tp* A, size_t astep, int m)\r
+    {\r
+        if (!Cholesky(A, astep, m, 0, 0, 0))\r
+            return false;\r
+        astep /= sizeof(A[0]);\r
+        for (int i = 0; i < m; ++i)\r
+            A[i*astep + i] = (_Tp)(1./A[i*astep + i]);\r
+        return true;\r
+    }\r
+} // namespace\r
 \r
-void focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok, bool &f1_ok)\r
+\r
+void cv::focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok, bool &f1_ok)\r
 {\r
     CV_Assert(H.type() == CV_64F && H.size() == Size(3, 3));\r
 \r
@@ -77,8 +90,8 @@ void focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok, boo
 }\r
 \r
 \r
-void estimateFocal(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches, \r
-                   vector<double> &focals)\r
+void cv::estimateFocal(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches,\r
+                       vector<double> &focals)\r
 {\r
     const int num_images = static_cast<int>(features.size());\r
     focals.resize(num_images);\r
@@ -118,22 +131,7 @@ void estimateFocal(const vector<ImageFeatures> &features, const vector<MatchesIn
 }\r
 \r
 \r
-namespace\r
-{\r
-    template<typename _Tp> static inline bool\r
-    decomposeCholesky(_Tp* A, size_t astep, int m)\r
-    {\r
-        if (!Cholesky(A, astep, m, 0, 0, 0))\r
-            return false;\r
-        astep /= sizeof(A[0]);\r
-        for (int i = 0; i < m; ++i)\r
-            A[i*astep + i] = (_Tp)(1./A[i*astep + i]);\r
-        return true;\r
-    }\r
-} // namespace\r
-\r
-\r
-bool calibrateRotatingCamera(const vector<Mat> &Hs, Mat &K)\r
+bool cv::calibrateRotatingCamera(const vector<Mat> &Hs, Mat &K)\r
 {\r
     int m = static_cast<int>(Hs.size());\r
     CV_Assert(m >= 1);\r
@@ -183,5 +181,3 @@ bool calibrateRotatingCamera(const vector<Mat> &Hs, Mat &K)
     K = W.t();\r
     return true;\r
 }\r
-\r
-} // namespace cv\r
index ea1d203..9806d9b 100644 (file)
 #include "precomp.hpp"\r
 \r
 using namespace std;\r
-\r
-namespace cv\r
-{\r
+using namespace cv;\r
 \r
 static const float WEIGHT_EPS = 1e-5f;\r
 \r
-Ptr<Blender> Blender::createDefault(int type, bool try_gpu)\r
+Ptr<Blender> cv::Blender::createDefault(int type, bool try_gpu)\r
 {\r
     if (type == NO)\r
         return new Blender();\r
@@ -61,13 +59,13 @@ Ptr<Blender> Blender::createDefault(int type, bool try_gpu)
 }\r
 \r
 \r
-void Blender::prepare(const vector<Point> &corners, const vector<Size> &sizes)\r
+void cv::Blender::prepare(const vector<Point> &corners, const vector<Size> &sizes)\r
 {\r
     prepare(resultRoi(corners, sizes));\r
 }\r
 \r
 \r
-void Blender::prepare(Rect dst_roi)\r
+void cv::Blender::prepare(Rect dst_roi)\r
 {\r
     dst_.create(dst_roi.size(), CV_16SC3);\r
     dst_.setTo(Scalar::all(0));\r
@@ -77,7 +75,7 @@ void Blender::prepare(Rect dst_roi)
 }\r
 \r
 \r
-void Blender::feed(const Mat &img, const Mat &mask, Point tl) \r
+void cv::Blender::feed(const Mat &img, const Mat &mask, Point tl)\r
 {\r
     CV_Assert(img.type() == CV_16SC3);\r
     CV_Assert(mask.type() == CV_8U);\r
@@ -101,7 +99,7 @@ void Blender::feed(const Mat &img, const Mat &mask, Point tl)
 }\r
 \r
 \r
-void Blender::blend(Mat &dst, Mat &dst_mask)\r
+void cv::Blender::blend(Mat &dst, Mat &dst_mask)\r
 {\r
     dst_.setTo(Scalar::all(0), dst_mask_ == 0);\r
     dst = dst_;\r
@@ -111,7 +109,7 @@ void Blender::blend(Mat &dst, Mat &dst_mask)
 }\r
 \r
 \r
-void FeatherBlender::prepare(Rect dst_roi)\r
+void cv::FeatherBlender::prepare(Rect dst_roi)\r
 {\r
     Blender::prepare(dst_roi);\r
     dst_weight_map_.create(dst_roi.size(), CV_32F);\r
@@ -119,7 +117,7 @@ void FeatherBlender::prepare(Rect dst_roi)
 }\r
 \r
 \r
-void FeatherBlender::feed(const Mat &img, const Mat &mask, Point tl)\r
+void cv::FeatherBlender::feed(const Mat &img, const Mat &mask, Point tl)\r
 {\r
     CV_Assert(img.type() == CV_16SC3);\r
     CV_Assert(mask.type() == CV_8U);\r
@@ -146,7 +144,7 @@ void FeatherBlender::feed(const Mat &img, const Mat &mask, Point tl)
 }\r
 \r
 \r
-void FeatherBlender::blend(Mat &dst, Mat &dst_mask)\r
+void cv::FeatherBlender::blend(Mat &dst, Mat &dst_mask)\r
 {\r
     normalizeUsingWeightMap(dst_weight_map_, dst_);\r
     dst_mask_ = dst_weight_map_ > WEIGHT_EPS;\r
@@ -154,14 +152,14 @@ void FeatherBlender::blend(Mat &dst, Mat &dst_mask)
 }\r
 \r
 \r
-MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands)\r
+cv::MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands)\r
 {\r
     setNumBands(num_bands);\r
     can_use_gpu_ = try_gpu && gpu::getCudaEnabledDeviceCount();\r
 }\r
 \r
 \r
-void MultiBandBlender::prepare(Rect dst_roi)\r
+void cv::MultiBandBlender::prepare(Rect dst_roi)\r
 {\r
     dst_roi_final_ = dst_roi;\r
 \r
@@ -194,7 +192,7 @@ void MultiBandBlender::prepare(Rect dst_roi)
 }\r
 \r
 \r
-void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl)\r
+void cv::MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl)\r
 {\r
     CV_Assert(img.type() == CV_16SC3);\r
     CV_Assert(mask.type() == CV_8U);\r
@@ -279,7 +277,7 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl)
 }\r
 \r
 \r
-void MultiBandBlender::blend(Mat &dst, Mat &dst_mask)\r
+void cv::MultiBandBlender::blend(Mat &dst, Mat &dst_mask)\r
 {\r
     for (int i = 0; i <= num_bands_; ++i)\r
         normalizeUsingWeightMap(dst_band_weights_[i], dst_pyr_laplace_[i]);\r
@@ -300,7 +298,7 @@ void MultiBandBlender::blend(Mat &dst, Mat &dst_mask)
 //////////////////////////////////////////////////////////////////////////////\r
 // Auxiliary functions\r
 \r
-void normalizeUsingWeightMap(const Mat& weight, Mat& src)\r
+void cv::normalizeUsingWeightMap(const Mat& weight, Mat& src)\r
 {\r
     CV_Assert(weight.type() == CV_32F);\r
     CV_Assert(src.type() == CV_16SC3);\r
@@ -319,7 +317,7 @@ void normalizeUsingWeightMap(const Mat& weight, Mat& src)
 }\r
 \r
 \r
-void createWeightMap(const Mat &mask, float sharpness, Mat &weight)\r
+void cv::createWeightMap(const Mat &mask, float sharpness, Mat &weight)\r
 {\r
     CV_Assert(mask.type() == CV_8U);\r
     distanceTransform(mask, weight, CV_DIST_L1, 3);\r
@@ -327,7 +325,7 @@ void createWeightMap(const Mat &mask, float sharpness, Mat &weight)
 }\r
 \r
 \r
-void createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr)\r
+void cv::createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr)\r
 {\r
     pyr.resize(num_levels + 1);\r
     pyr[0] = img;\r
@@ -342,7 +340,7 @@ void createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr)
 }\r
 \r
 \r
-void createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)\r
+void cv::createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)\r
 {\r
     pyr.resize(num_levels + 1);\r
 \r
@@ -363,7 +361,7 @@ void createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
 }\r
 \r
 \r
-void restoreImageFromLaplacePyr(vector<Mat> &pyr)\r
+void cv::restoreImageFromLaplacePyr(vector<Mat> &pyr)\r
 {\r
     if (pyr.size() == 0)\r
         return;\r
@@ -374,5 +372,3 @@ void restoreImageFromLaplacePyr(vector<Mat> &pyr)
         add(tmp, pyr[i - 1], pyr[i - 1]);\r
     }\r
 }\r
-\r
-} // namespace cv\r
index 4c7cea6..18ef6d2 100644 (file)
@@ -1,20 +1,16 @@
 #include "precomp.hpp"
 
 using namespace std;
+using namespace cv;
 
-namespace cv
-{
-
-CameraParams::CameraParams() : focal(1), R(Mat::eye(3, 3, CV_64F)), t(Mat::zeros(3, 1, CV_64F)) {}
+cv::CameraParams::CameraParams() : focal(1), R(Mat::eye(3, 3, CV_64F)), t(Mat::zeros(3, 1, CV_64F)) {}
 
-CameraParams::CameraParams(const CameraParams &other) { *this = other; }
+cv::CameraParams::CameraParams(const CameraParams &other) { *this = other; }
 
-const CameraParams& CameraParams::operator =(const CameraParams &other)
+const cv::CameraParams& CameraParams::operator =(const CameraParams &other)
 {
     focal = other.focal;
     R = other.R.clone();
     t = other.t.clone();
     return *this;
 }
-
-} // namespace cv
index 017b0df..1eefe52 100644 (file)
 #include "precomp.hpp"\r
 \r
 using namespace std;\r
+using namespace cv;\r
 using namespace cv::gpu;\r
 \r
-namespace cv\r
-{\r
-\r
-Ptr<ExposureCompensator> ExposureCompensator::createDefault(int type)\r
+Ptr<ExposureCompensator> cv::ExposureCompensator::createDefault(int type)\r
 {\r
     if (type == NO)\r
         return new NoExposureCompensator();\r
@@ -60,8 +58,8 @@ Ptr<ExposureCompensator> ExposureCompensator::createDefault(int type)
 }\r
 \r
 \r
-void ExposureCompensator::feed(const vector<Point> &corners, const vector<Mat> &images, \r
-                               const vector<Mat> &masks)\r
+void cv::ExposureCompensator::feed(const vector<Point> &corners, const vector<Mat> &images,\r
+                                   const vector<Mat> &masks)\r
 {\r
     vector<pair<Mat,uchar> > level_masks;\r
     for (size_t i = 0; i < masks.size(); ++i)\r
@@ -70,8 +68,8 @@ void ExposureCompensator::feed(const vector<Point> &corners, const vector<Mat> &
 }\r
 \r
 \r
-void GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &images, \r
-                           const vector<pair<Mat,uchar> > &masks)\r
+void cv::GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &images,\r
+                               const vector<pair<Mat,uchar> > &masks)\r
 {\r
     LOGLN("Exposure compensation...");\r
     int64 t = getTickCount();\r
@@ -145,13 +143,13 @@ void GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &imag
 }\r
 \r
 \r
-void GainCompensator::apply(int index, Point /*corner*/, Mat &image, const Mat &/*mask*/)\r
+void cv::GainCompensator::apply(int index, Point /*corner*/, Mat &image, const Mat &/*mask*/)\r
 {\r
     image *= gains_(index, 0);\r
 }\r
 \r
 \r
-vector<double> GainCompensator::gains() const\r
+vector<double> cv::GainCompensator::gains() const\r
 {\r
     vector<double> gains_vec(gains_.rows);\r
     for (int i = 0; i < gains_.rows; ++i)\r
@@ -160,8 +158,8 @@ vector<double> GainCompensator::gains() const
 }\r
 \r
 \r
-void BlocksGainCompensator::feed(const vector<Point> &corners, const vector<Mat> &images, \r
-                                const vector<pair<Mat,uchar> > &masks)\r
+void cv::BlocksGainCompensator::feed(const vector<Point> &corners, const vector<Mat> &images,\r
+                                     const vector<pair<Mat,uchar> > &masks)\r
 {\r
     CV_Assert(corners.size() == images.size() && images.size() == masks.size());\r
 \r
@@ -220,7 +218,7 @@ void BlocksGainCompensator::feed(const vector<Point> &corners, const vector<Mat>
 }\r
 \r
 \r
-void BlocksGainCompensator::apply(int index, Point /*corner*/, Mat &image, const Mat &/*mask*/)\r
+void cv::BlocksGainCompensator::apply(int index, Point /*corner*/, Mat &image, const Mat &/*mask*/)\r
 {\r
     CV_Assert(image.type() == CV_8UC3);\r
 \r
@@ -242,5 +240,3 @@ void BlocksGainCompensator::apply(int index, Point /*corner*/, Mat &image, const
         }\r
     }\r
 }\r
-\r
-} // namespace cv\r
index d1ed016..0b202b9 100644 (file)
 #include "precomp.hpp"\r
 \r
 using namespace std;\r
+using namespace cv;\r
 using namespace cv::gpu;\r
 \r
-namespace cv\r
-{\r
-\r
-void FeaturesFinder::operator ()(const Mat &image, ImageFeatures &features) \r
+void cv::FeaturesFinder::operator ()(const Mat &image, ImageFeatures &features)\r
 { \r
     find(image, features);\r
     features.img_size = image.size();\r
     //features.img = image.clone();\r
 }\r
 \r
-} // namespace cv\r
-\r
 \r
 namespace\r
 {\r
-    using namespace cv;\r
-\r
     class CpuSurfFeaturesFinder : public FeaturesFinder\r
     {\r
     public:\r
@@ -155,10 +149,7 @@ namespace
 } // namespace\r
 \r
 \r
-namespace cv\r
-{\r
-\r
-SurfFeaturesFinder::SurfFeaturesFinder(bool try_use_gpu, double hess_thresh, int num_octaves, int num_layers, \r
+cv::SurfFeaturesFinder::SurfFeaturesFinder(bool try_use_gpu, double hess_thresh, int num_octaves, int num_layers,\r
                                        int num_octaves_descr, int num_layers_descr)\r
 {\r
     if (try_use_gpu && getCudaEnabledDeviceCount() > 0)\r
@@ -168,12 +159,12 @@ SurfFeaturesFinder::SurfFeaturesFinder(bool try_use_gpu, double hess_thresh, int
 }\r
 \r
 \r
-void SurfFeaturesFinder::find(const Mat &image, ImageFeatures &features)\r
+void cv::SurfFeaturesFinder::find(const Mat &image, ImageFeatures &features)\r
 {\r
     (*impl_)(image, features);\r
 }\r
 \r
-void SurfFeaturesFinder::releaseMemory()\r
+void cv::SurfFeaturesFinder::releaseMemory()\r
 {\r
     impl_->releaseMemory();\r
 }\r
@@ -181,11 +172,11 @@ void SurfFeaturesFinder::releaseMemory()
 \r
 //////////////////////////////////////////////////////////////////////////////\r
 \r
-MatchesInfo::MatchesInfo() : src_img_idx(-1), dst_img_idx(-1), num_inliers(0), confidence(0) {}\r
+cv::MatchesInfo::MatchesInfo() : src_img_idx(-1), dst_img_idx(-1), num_inliers(0), confidence(0) {}\r
 \r
-MatchesInfo::MatchesInfo(const MatchesInfo &other) { *this = other; }\r
+cv::MatchesInfo::MatchesInfo(const MatchesInfo &other) { *this = other; }\r
 \r
-const MatchesInfo& MatchesInfo::operator =(const MatchesInfo &other)\r
+const cv::MatchesInfo& MatchesInfo::operator =(const MatchesInfo &other)\r
 {\r
     src_img_idx = other.src_img_idx;\r
     dst_img_idx = other.dst_img_idx;\r
@@ -200,65 +191,69 @@ const MatchesInfo& MatchesInfo::operator =(const MatchesInfo &other)
 \r
 //////////////////////////////////////////////////////////////////////////////\r
 \r
-struct DistIdxPair\r
+namespace\r
 {\r
-    bool operator<(const DistIdxPair &other) const { return dist < other.dist; }\r
-    double dist;\r
-    int idx;\r
-};\r
-\r
 \r
-struct MatchPairsBody\r
-{\r
-    MatchPairsBody(const MatchPairsBody& other)\r
-            : matcher(other.matcher), features(other.features), \r
-              pairwise_matches(other.pairwise_matches), near_pairs(other.near_pairs) {}\r
+    struct DistIdxPair\r
+    {\r
+        bool operator<(const DistIdxPair &other) const { return dist < other.dist; }\r
+        double dist;\r
+        int idx;\r
+    };\r
 \r
-    MatchPairsBody(FeaturesMatcher &matcher, const vector<ImageFeatures> &features, \r
-                   vector<MatchesInfo> &pairwise_matches, vector<pair<int,int> > &near_pairs)\r
-            : matcher(matcher), features(features), \r
-              pairwise_matches(pairwise_matches), near_pairs(near_pairs) {}\r
 \r
-    void operator ()(const BlockedRange &r) const \r
+    struct MatchPairsBody\r
     {\r
-        const int num_images = static_cast<int>(features.size());\r
-        for (int i = r.begin(); i < r.end(); ++i)\r
+        MatchPairsBody(const MatchPairsBody& other)\r
+                : matcher(other.matcher), features(other.features),\r
+                  pairwise_matches(other.pairwise_matches), near_pairs(other.near_pairs) {}\r
+\r
+        MatchPairsBody(FeaturesMatcher &matcher, const vector<ImageFeatures> &features,\r
+                       vector<MatchesInfo> &pairwise_matches, vector<pair<int,int> > &near_pairs)\r
+                : matcher(matcher), features(features),\r
+                  pairwise_matches(pairwise_matches), near_pairs(near_pairs) {}\r
+\r
+        void operator ()(const BlockedRange &r) const\r
         {\r
-            int from = near_pairs[i].first;\r
-            int to = near_pairs[i].second;\r
-            int pair_idx = from*num_images + to;\r
+            const int num_images = static_cast<int>(features.size());\r
+            for (int i = r.begin(); i < r.end(); ++i)\r
+            {\r
+                int from = near_pairs[i].first;\r
+                int to = near_pairs[i].second;\r
+                int pair_idx = from*num_images + to;\r
 \r
-            matcher(features[from], features[to], pairwise_matches[pair_idx]);\r
-            pairwise_matches[pair_idx].src_img_idx = from;\r
-            pairwise_matches[pair_idx].dst_img_idx = to;\r
+                matcher(features[from], features[to], pairwise_matches[pair_idx]);\r
+                pairwise_matches[pair_idx].src_img_idx = from;\r
+                pairwise_matches[pair_idx].dst_img_idx = to;\r
 \r
-            size_t dual_pair_idx = to*num_images + from;\r
+                size_t dual_pair_idx = to*num_images + from;\r
 \r
-            pairwise_matches[dual_pair_idx] = pairwise_matches[pair_idx];\r
-            pairwise_matches[dual_pair_idx].src_img_idx = to;\r
-            pairwise_matches[dual_pair_idx].dst_img_idx = from;\r
+                pairwise_matches[dual_pair_idx] = pairwise_matches[pair_idx];\r
+                pairwise_matches[dual_pair_idx].src_img_idx = to;\r
+                pairwise_matches[dual_pair_idx].dst_img_idx = from;\r
 \r
-            if (!pairwise_matches[pair_idx].H.empty())\r
-                pairwise_matches[dual_pair_idx].H = pairwise_matches[pair_idx].H.inv();\r
+                if (!pairwise_matches[pair_idx].H.empty())\r
+                    pairwise_matches[dual_pair_idx].H = pairwise_matches[pair_idx].H.inv();\r
 \r
-            for (size_t j = 0; j < pairwise_matches[dual_pair_idx].matches.size(); ++j)\r
-                std::swap(pairwise_matches[dual_pair_idx].matches[j].queryIdx,\r
-                          pairwise_matches[dual_pair_idx].matches[j].trainIdx);\r
-            LOG(".");\r
+                for (size_t j = 0; j < pairwise_matches[dual_pair_idx].matches.size(); ++j)\r
+                    std::swap(pairwise_matches[dual_pair_idx].matches[j].queryIdx,\r
+                              pairwise_matches[dual_pair_idx].matches[j].trainIdx);\r
+                LOG(".");\r
+            }\r
         }\r
-    }\r
 \r
-    FeaturesMatcher &matcher;\r
-    const vector<ImageFeatures> &features;\r
-    vector<MatchesInfo> &pairwise_matches;\r
-    vector<pair<int,int> > &near_pairs;\r
+        FeaturesMatcher &matcher;\r
+        const vector<ImageFeatures> &features;\r
+        vector<MatchesInfo> &pairwise_matches;\r
+        vector<pair<int,int> > &near_pairs;\r
 \r
-private:\r
-    void operator =(const MatchPairsBody&);\r
-};\r
+    private:\r
+        void operator =(const MatchPairsBody&);\r
+    };\r
+} // namespace\r
 \r
 \r
-void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<MatchesInfo> &pairwise_matches)\r
+void cv::FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<MatchesInfo> &pairwise_matches)\r
 {\r
     const int num_images = static_cast<int>(features.size());\r
 \r
@@ -408,10 +403,10 @@ namespace
         vector< vector<DMatch> >().swap(pair_matches);\r
     }\r
 \r
-} // anonymous namespace\r
+} // namespace\r
 \r
 \r
-BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf, int num_matches_thresh1, int num_matches_thresh2)\r
+cv::BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf, int num_matches_thresh1, int num_matches_thresh2)\r
 {\r
     if (try_use_gpu && getCudaEnabledDeviceCount() > 0)\r
         impl_ = new GpuMatcher(match_conf);\r
@@ -424,7 +419,7 @@ BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf,
 }\r
 \r
 \r
-void BestOf2NearestMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2,\r
+void cv::BestOf2NearestMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2,\r
                                   MatchesInfo &matches_info)\r
 {\r
     (*impl_)(features1, features2, matches_info);\r
@@ -502,9 +497,7 @@ void BestOf2NearestMatcher::match(const ImageFeatures &features1, const ImageFea
     matches_info.H = findHomography(src_points, dst_points, CV_RANSAC);\r
 }\r
 \r
-void BestOf2NearestMatcher::releaseMemory()\r
+void cv::BestOf2NearestMatcher::releaseMemory()\r
 {\r
     impl_->releaseMemory();\r
 }\r
-\r
-} // namespace cv\r
index eb89128..5b29dd8 100644 (file)
 #include "precomp.hpp"\r
 \r
 using namespace std;\r
+using namespace cv;\r
 \r
-namespace cv\r
+namespace\r
 {\r
 \r
-struct IncDistance\r
-{\r
-    IncDistance(vector<int> &dists) : dists(&dists[0]) {}\r
-    void operator ()(const GraphEdge &edge) { dists[edge.to] = dists[edge.from] + 1; }\r
-    int* dists;\r
-};\r
-\r
+    struct IncDistance\r
+    {\r
+        IncDistance(vector<int> &dists) : dists(&dists[0]) {}\r
+        void operator ()(const GraphEdge &edge) { dists[edge.to] = dists[edge.from] + 1; }\r
+        int* dists;\r
+    };\r
 \r
-struct CalcRotation\r
-{\r
-    CalcRotation(int num_images, const vector<MatchesInfo> &pairwise_matches, vector<CameraParams> &cameras)\r
-        : num_images(num_images), pairwise_matches(&pairwise_matches[0]), cameras(&cameras[0]) {}\r
 \r
-    void operator ()(const GraphEdge &edge)\r
+    struct CalcRotation\r
     {\r
-        int pair_idx = edge.from * num_images + edge.to;\r
+        CalcRotation(int num_images, const vector<MatchesInfo> &pairwise_matches, vector<CameraParams> &cameras)\r
+            : num_images(num_images), pairwise_matches(&pairwise_matches[0]), cameras(&cameras[0]) {}\r
 \r
-        double f_from = cameras[edge.from].focal;\r
-        double f_to = cameras[edge.to].focal;\r
+        void operator ()(const GraphEdge &edge)\r
+        {\r
+            int pair_idx = edge.from * num_images + edge.to;\r
 \r
-        Mat K_from = Mat::eye(3, 3, CV_64F);\r
-        K_from.at<double>(0, 0) = f_from;\r
-        K_from.at<double>(1, 1) = f_from;\r
+            double f_from = cameras[edge.from].focal;\r
+            double f_to = cameras[edge.to].focal;\r
 \r
-        Mat K_to = Mat::eye(3, 3, CV_64F);\r
-        K_to.at<double>(0, 0) = f_to;\r
-        K_to.at<double>(1, 1) = f_to;\r
+            Mat K_from = Mat::eye(3, 3, CV_64F);\r
+            K_from.at<double>(0, 0) = f_from;\r
+            K_from.at<double>(1, 1) = f_from;\r
 \r
-        Mat R = K_from.inv() * pairwise_matches[pair_idx].H.inv() * K_to;\r
-        cameras[edge.to].R = cameras[edge.from].R * R;\r
-    }\r
+            Mat K_to = Mat::eye(3, 3, CV_64F);\r
+            K_to.at<double>(0, 0) = f_to;\r
+            K_to.at<double>(1, 1) = f_to;\r
+\r
+            Mat R = K_from.inv() * pairwise_matches[pair_idx].H.inv() * K_to;\r
+            cameras[edge.to].R = cameras[edge.from].R * R;\r
+        }\r
 \r
-    int num_images;\r
-    const MatchesInfo* pairwise_matches;\r
-    CameraParams* cameras;\r
-};\r
+        int num_images;\r
+        const MatchesInfo* pairwise_matches;\r
+        CameraParams* cameras;\r
+    };\r
 \r
+} // namespace\r
 \r
-void HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches, \r
-                                        vector<CameraParams> &cameras)\r
+\r
+void cv::HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches,\r
+                                            vector<CameraParams> &cameras)\r
 {\r
     LOGLN("Estimating rotations...");\r
     int64 t = getTickCount();\r
@@ -132,8 +135,8 @@ void HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, c
 \r
 //////////////////////////////////////////////////////////////////////////////\r
 \r
-void BundleAdjuster::estimate(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches, \r
-                              vector<CameraParams> &cameras)\r
+void cv::BundleAdjuster::estimate(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches,\r
+                                  vector<CameraParams> &cameras)\r
 {\r
     if (cost_space_ == NO)\r
         return;\r
@@ -247,7 +250,7 @@ void BundleAdjuster::estimate(const vector<ImageFeatures> &features, const vecto
 }\r
 \r
 \r
-void BundleAdjuster::calcError(Mat &err)\r
+void cv::BundleAdjuster::calcError(Mat &err)\r
 {\r
     err.create(total_num_matches_ * 3, 1, CV_64F);\r
 \r
@@ -311,14 +314,19 @@ void BundleAdjuster::calcError(Mat &err)
 }\r
 \r
 \r
-void calcDeriv(const Mat &err1, const Mat &err2, double h, Mat res)\r
+namespace\r
 {\r
-    for (int i = 0; i < err1.rows; ++i)\r
-        res.at<double>(i, 0) = (err2.at<double>(i, 0) - err1.at<double>(i, 0)) / h;\r
-}\r
 \r
+    void calcDeriv(const Mat &err1, const Mat &err2, double h, Mat res)\r
+    {\r
+        for (int i = 0; i < err1.rows; ++i)\r
+            res.at<double>(i, 0) = (err2.at<double>(i, 0) - err1.at<double>(i, 0)) / h;\r
+    }\r
 \r
-void BundleAdjuster::calcJacobian()\r
+} // namespace\r
+\r
+\r
+void cv::BundleAdjuster::calcJacobian()\r
 {\r
     J_.create(total_num_matches_ * 3, num_images_ * 4, CV_64F);\r
 \r
@@ -366,7 +374,7 @@ void BundleAdjuster::calcJacobian()
 //////////////////////////////////////////////////////////////////////////////\r
 \r
 // TODO replace SVD with eigen\r
-void waveCorrect(vector<Mat> &rmats)\r
+void cv::waveCorrect(vector<Mat> &rmats)\r
 {\r
     LOGLN("Wave correcting...");\r
     int64 t = getTickCount();\r
@@ -407,8 +415,8 @@ void waveCorrect(vector<Mat> &rmats)
 \r
 //////////////////////////////////////////////////////////////////////////////\r
 \r
-string matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pairwise_matches,\r
-                            float conf_threshold)\r
+string cv::matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pairwise_matches,\r
+                                float conf_threshold)\r
 {\r
     stringstream str;\r
     str << "graph matches_graph{\n";\r
@@ -473,8 +481,8 @@ string matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pairwis
     return str.str();\r
 }\r
 \r
-vector<int> leaveBiggestComponent(vector<ImageFeatures> &features,  vector<MatchesInfo> &pairwise_matches, \r
-                                  float conf_threshold)\r
+vector<int> cv::leaveBiggestComponent(vector<ImageFeatures> &features,  vector<MatchesInfo> &pairwise_matches,\r
+                                      float conf_threshold)\r
 {\r
     const int num_images = static_cast<int>(features.size());\r
 \r
@@ -531,8 +539,8 @@ vector<int> leaveBiggestComponent(vector<ImageFeatures> &features,  vector<Match
 }\r
 \r
 \r
-void findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise_matches,\r
-                         Graph &span_tree, vector<int> &centers)\r
+void cv::findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise_matches,\r
+                             Graph &span_tree, vector<int> &centers)\r
 {\r
     Graph graph(num_images);\r
     vector<GraphEdge> edges;\r
@@ -600,5 +608,3 @@ void findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise_mat
             centers.push_back(i);\r
     CV_Assert(centers.size() > 0 && centers.size() <= 2);\r
 }\r
-\r
-} // namespace cv\r
index 7535ff0..68a777c 100644 (file)
 #include "precomp.hpp"\r
 \r
 using namespace std;\r
+using namespace cv;\r
 \r
-namespace cv\r
-{\r
-\r
-Ptr<SeamFinder> SeamFinder::createDefault(int type)\r
+Ptr<SeamFinder> cv::SeamFinder::createDefault(int type)\r
 {\r
     if (type == NO)\r
         return new NoSeamFinder();\r
@@ -61,8 +59,8 @@ Ptr<SeamFinder> SeamFinder::createDefault(int type)
 }\r
 \r
 \r
-void PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners,\r
-                              vector<Mat> &masks)\r
+void cv::PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners,\r
+                                  vector<Mat> &masks)\r
 {\r
     LOGLN("Finding seams...");\r
     int64 t = getTickCount();\r
@@ -88,7 +86,7 @@ void PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &corne
 }\r
 \r
 \r
-void VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi)\r
+void cv::VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi)\r
 {\r
     const int gap = 10;\r
     Mat submask1(roi.height + 2 * gap, roi.width + 2 * gap, CV_8U);\r
@@ -142,7 +140,7 @@ void VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi)
 }\r
 \r
 \r
-class GraphCutSeamFinder::Impl : public PairwiseSeamFinder\r
+class cv::GraphCutSeamFinder::Impl : public PairwiseSeamFinder\r
 {\r
 public:\r
     Impl(int cost_type, float terminal_cost, float bad_region_penalty)\r
@@ -165,8 +163,8 @@ private:
 };\r
 \r
 \r
-void GraphCutSeamFinder::Impl::find(const vector<Mat> &src, const vector<Point> &corners, \r
-                                    vector<Mat> &masks)\r
+void cv::GraphCutSeamFinder::Impl::find(const vector<Mat> &src, const vector<Point> &corners,\r
+                                        vector<Mat> &masks)\r
 {\r
     // Compute gradients\r
     dx_.resize(src.size());\r
@@ -196,8 +194,8 @@ void GraphCutSeamFinder::Impl::find(const vector<Mat> &src, const vector<Point>
 }\r
 \r
 \r
-void GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const Mat &img2, \r
-                                                    const Mat &mask1, const Mat &mask2, GCGraph<float> &graph)\r
+void cv::GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const Mat &img2,\r
+                                                        const Mat &mask1, const Mat &mask2, GCGraph<float> &graph)\r
 {\r
     const Size img_size = img1.size();\r
 \r
@@ -244,7 +242,7 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const Mat &
 }\r
 \r
 \r
-void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(\r
+void cv::GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(\r
         const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2, \r
         const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2, \r
         GCGraph<float> &graph)\r
@@ -298,7 +296,7 @@ void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
 }\r
 \r
 \r
-void GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect roi)\r
+void cv::GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect roi)\r
 {\r
     Mat img1 = images_[first], img2 = images_[second];\r
     Mat dx1 = dx_[first], dx2 = dx_[second];\r
@@ -396,14 +394,12 @@ void GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect roi)
 }\r
 \r
 \r
-GraphCutSeamFinder::GraphCutSeamFinder(int cost_type, float terminal_cost, float bad_region_penalty)\r
+cv::GraphCutSeamFinder::GraphCutSeamFinder(int cost_type, float terminal_cost, float bad_region_penalty)\r
     : impl_(new Impl(cost_type, terminal_cost, bad_region_penalty)) {}\r
 \r
 \r
-void GraphCutSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners,\r
+void cv::GraphCutSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners,\r
                               vector<Mat> &masks)\r
 {\r
     impl_->find(src, corners, masks);\r
 }\r
-\r
-} // namespace cv\r
index 73ba838..7311b0b 100644 (file)
 #include "precomp.hpp"\r
 \r
 using namespace std;\r
+using namespace cv;\r
 \r
-namespace cv\r
-{\r
-\r
-void DisjointSets::createOneElemSets(int n)\r
+void cv::DisjointSets::createOneElemSets(int n)\r
 {\r
     rank_.assign(n, 0);\r
     size.assign(n, 1);\r
@@ -56,7 +54,7 @@ void DisjointSets::createOneElemSets(int n)
 }\r
 \r
 \r
-int DisjointSets::findSetByElem(int elem)\r
+int cv::DisjointSets::findSetByElem(int elem)\r
 {\r
     int set = elem;\r
     while (set != parent[set])\r
@@ -72,7 +70,7 @@ int DisjointSets::findSetByElem(int elem)
 }\r
 \r
 \r
-int DisjointSets::mergeSets(int set1, int set2)\r
+int cv::DisjointSets::mergeSets(int set1, int set2)\r
 {\r
     if (rank_[set1] < rank_[set2]) \r
     {\r
@@ -93,13 +91,13 @@ int DisjointSets::mergeSets(int set1, int set2)
 }\r
 \r
 \r
-void Graph::addEdge(int from, int to, float weight)\r
+void cv::Graph::addEdge(int from, int to, float weight)\r
 {\r
     edges_[from].push_back(GraphEdge(from, to, weight));\r
 }\r
 \r
 \r
-bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi)\r
+bool cv::overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi)\r
 {\r
     int x_tl = max(tl1.x, tl2.x);\r
     int y_tl = max(tl1.y, tl2.y);\r
@@ -114,7 +112,7 @@ bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi)
 }\r
 \r
 \r
-Rect resultRoi(const vector<Point> &corners, const vector<Mat> &images)\r
+Rect cv::resultRoi(const vector<Point> &corners, const vector<Mat> &images)\r
 {\r
     vector<Size> sizes(images.size());\r
     for (size_t i = 0; i < images.size(); ++i)\r
@@ -123,7 +121,7 @@ Rect resultRoi(const vector<Point> &corners, const vector<Mat> &images)
 }\r
 \r
 \r
-Rect resultRoi(const vector<Point> &corners, const vector<Size> &sizes)\r
+Rect cv::resultRoi(const vector<Point> &corners, const vector<Size> &sizes)\r
 {\r
     CV_Assert(sizes.size() == corners.size());\r
     Point tl(numeric_limits<int>::max(), numeric_limits<int>::max());\r
@@ -139,7 +137,7 @@ Rect resultRoi(const vector<Point> &corners, const vector<Size> &sizes)
 }\r
 \r
 \r
-Point resultTl(const vector<Point> &corners)\r
+Point cv::resultTl(const vector<Point> &corners)\r
 {\r
     Point tl(numeric_limits<int>::max(), numeric_limits<int>::max());\r
     for (size_t i = 0; i < corners.size(); ++i)\r
@@ -151,7 +149,7 @@ Point resultTl(const vector<Point> &corners)
 }\r
 \r
 \r
-void selectRandomSubset(int count, int size, vector<int> &subset)\r
+void cv::selectRandomSubset(int count, int size, vector<int> &subset)\r
 {\r
     subset.clear();\r
     for (int i = 0; i < size; ++i)\r
@@ -163,5 +161,3 @@ void selectRandomSubset(int count, int size, vector<int> &subset)
         }\r
     }\r
 }\r
-\r
-} // namespace cv\r
index 638f66d..096506c 100644 (file)
 #include "precomp.hpp"\r
 \r
 using namespace std;\r
+using namespace cv;\r
 \r
-namespace cv\r
-{\r
-\r
-Ptr<Warper> Warper::createByCameraFocal(float focal, int type, bool try_gpu)\r
+Ptr<Warper> cv::Warper::createByCameraFocal(float focal, int type, bool try_gpu)\r
 {\r
     bool can_use_gpu = try_gpu && gpu::getCudaEnabledDeviceCount();\r
     if (type == PLANE)\r
@@ -60,7 +58,7 @@ Ptr<Warper> Warper::createByCameraFocal(float focal, int type, bool try_gpu)
 }\r
 \r
 \r
-void ProjectorBase::setTransformation(const Mat &R)\r
+void cv::ProjectorBase::setTransformation(const Mat &R)\r
 {\r
     CV_Assert(R.size() == Size(3, 3));\r
     CV_Assert(R.type() == CV_32F);\r
@@ -75,7 +73,7 @@ void ProjectorBase::setTransformation(const Mat &R)
 }\r
 \r
 \r
-void PlaneWarper::detectResultRoi(Point &dst_tl, Point &dst_br)\r
+void cv::PlaneWarper::detectResultRoi(Point &dst_tl, Point &dst_br)\r
 {\r
     float tl_uf = numeric_limits<float>::max();\r
     float tl_vf = numeric_limits<float>::max();\r
@@ -107,7 +105,7 @@ void PlaneWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
 }\r
 \r
 \r
-Point PlaneWarperGpu::warp(const Mat &src, float focal, const cv::Mat &R, cv::Mat &dst, int interp_mode, int border_mode)\r
+Point cv::PlaneWarperGpu::warp(const Mat &src, float focal, const cv::Mat &R, cv::Mat &dst, int interp_mode, int border_mode)\r
 {\r
     src_size_ = src.size();\r
     projector_.size = src.size();\r
@@ -133,7 +131,7 @@ Point PlaneWarperGpu::warp(const Mat &src, float focal, const cv::Mat &R, cv::Ma
 }\r
 \r
 \r
-void SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br)\r
+void cv::SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br)\r
 {\r
     detectResultRoiByBorder(dst_tl, dst_br);\r
 \r
@@ -177,8 +175,8 @@ void SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
 }\r
 \r
 \r
-Point SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst,\r
-                               int interp_mode, int border_mode)\r
+Point cv::SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst,\r
+                                   int interp_mode, int border_mode)\r
 {\r
     src_size_ = src.size();\r
     projector_.size = src.size();\r
@@ -204,8 +202,8 @@ Point SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &d
 }\r
 \r
 \r
-Point CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst,\r
-                                 int interp_mode, int border_mode)\r
+Point cv::CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst,\r
+                                     int interp_mode, int border_mode)\r
 {\r
     src_size_ = src.size();\r
     projector_.size = src.size();\r
@@ -230,4 +228,3 @@ Point CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat
     return dst_tl;\r
 }\r
 \r
-} // namespace cv\r