Commit 95a3ffd0 authored by Alexey Spizhevoy's avatar Alexey Spizhevoy

put all old stitching API into detail namespace

parent bf0081a8
...@@ -144,7 +144,7 @@ macro(define_opencv_module name) ...@@ -144,7 +144,7 @@ macro(define_opencv_module name)
file(GLOB lib_srcs "src/*.cpp") file(GLOB lib_srcs "src/*.cpp")
file(GLOB lib_int_hdrs "src/*.h*") file(GLOB lib_int_hdrs "src/*.h*")
file(GLOB lib_hdrs "include/opencv2/${name}/*.h*") file(GLOB lib_hdrs "include/opencv2/${name}/*.h*" "include/opencv2/${name}/detail/*.h*")
if(COMMAND get_module_external_sources) if(COMMAND get_module_external_sources)
get_module_external_sources(${name}) get_module_external_sources(${name})
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#include "matchers.hpp" #include "matchers.hpp"
namespace cv namespace cv {
{ namespace detail {
// See "Construction of Panoramic Image Mosaics with Global and Local Alignment" // See "Construction of Panoramic Image Mosaics with Global and Local Alignment"
// by Heung-Yeung Shum and Richard Szeliski. // by Heung-Yeung Shum and Richard Szeliski.
...@@ -58,6 +58,7 @@ void CV_EXPORTS estimateFocal(const std::vector<ImageFeatures> &features, ...@@ -58,6 +58,7 @@ void CV_EXPORTS estimateFocal(const std::vector<ImageFeatures> &features,
bool CV_EXPORTS calibrateRotatingCamera(const std::vector<Mat> &Hs, Mat &K); bool CV_EXPORTS calibrateRotatingCamera(const std::vector<Mat> &Hs, Mat &K);
} // namespace detail
} // namespace cv } // namespace cv
#endif // __OPENCV_STITCHING_AUTOCALIB_HPP__ #endif // __OPENCV_STITCHING_AUTOCALIB_HPP__
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
namespace cv namespace cv {
{ namespace detail {
// Simple blender which puts one image over another // Simple blender which puts one image over another
class CV_EXPORTS Blender class CV_EXPORTS Blender
...@@ -119,6 +119,7 @@ void CV_EXPORTS createLaplacePyrGpu(const Mat &img, int num_levels, std::vector< ...@@ -119,6 +119,7 @@ void CV_EXPORTS createLaplacePyrGpu(const Mat &img, int num_levels, std::vector<
// Restores source image // Restores source image
void CV_EXPORTS restoreImageFromLaplacePyr(std::vector<Mat>& pyr); void CV_EXPORTS restoreImageFromLaplacePyr(std::vector<Mat>& pyr);
} // namespace detail
} // namespace cv } // namespace cv
#endif // __OPENCV_STITCHING_BLENDERS_HPP__ #endif // __OPENCV_STITCHING_BLENDERS_HPP__
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
namespace cv namespace cv {
{ namespace detail {
struct CV_EXPORTS CameraParams struct CV_EXPORTS CameraParams
{ {
...@@ -58,6 +58,7 @@ struct CV_EXPORTS CameraParams ...@@ -58,6 +58,7 @@ struct CV_EXPORTS CameraParams
Mat t; // Translation Mat t; // Translation
}; };
} // namespace detail
} // namespace cv } // namespace cv
#endif // #ifndef __OPENCV_STITCHING_CAMERA_HPP__ #endif // #ifndef __OPENCV_STITCHING_CAMERA_HPP__
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
namespace cv namespace cv {
{ namespace detail {
class CV_EXPORTS ExposureCompensator class CV_EXPORTS ExposureCompensator
{ {
...@@ -99,6 +99,7 @@ private: ...@@ -99,6 +99,7 @@ private:
std::vector<Mat_<float> > gain_maps_; std::vector<Mat_<float> > gain_maps_;
}; };
} // namespace detail
} // namespace cv } // namespace cv
#endif // __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__ #endif // __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp" #include "opencv2/features2d/features2d.hpp"
namespace cv namespace cv {
{ namespace detail {
struct CV_EXPORTS ImageFeatures struct CV_EXPORTS ImageFeatures
{ {
...@@ -140,6 +140,7 @@ protected: ...@@ -140,6 +140,7 @@ protected:
cv::Ptr<FeaturesMatcher> impl_; cv::Ptr<FeaturesMatcher> impl_;
}; };
} // namespace detail
} // namespace cv } // namespace cv
#endif // __OPENCV_STITCHING_MATCHERS_HPP__ #endif // __OPENCV_STITCHING_MATCHERS_HPP__
...@@ -47,8 +47,8 @@ ...@@ -47,8 +47,8 @@
#include "util.hpp" #include "util.hpp"
#include "camera.hpp" #include "camera.hpp"
namespace cv namespace cv {
{ namespace detail {
class CV_EXPORTS Estimator class CV_EXPORTS Estimator
{ {
...@@ -126,6 +126,7 @@ std::vector<int> CV_EXPORTS leaveBiggestComponent(std::vector<ImageFeatures> &fe ...@@ -126,6 +126,7 @@ std::vector<int> CV_EXPORTS leaveBiggestComponent(std::vector<ImageFeatures> &fe
void CV_EXPORTS findMaxSpanningTree(int num_images, const std::vector<MatchesInfo> &pairwise_matches, void CV_EXPORTS findMaxSpanningTree(int num_images, const std::vector<MatchesInfo> &pairwise_matches,
Graph &span_tree, std::vector<int> &centers); Graph &span_tree, std::vector<int> &centers);
} // namespace detail
} // namespace cv } // namespace cv
#endif // __OPENCV_STITCHING_MOTION_ESTIMATORS_HPP__ #endif // __OPENCV_STITCHING_MOTION_ESTIMATORS_HPP__
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
namespace cv namespace cv {
{ namespace detail {
class CV_EXPORTS SeamFinder class CV_EXPORTS SeamFinder
{ {
...@@ -103,6 +103,7 @@ private: ...@@ -103,6 +103,7 @@ private:
Ptr<Impl> impl_; Ptr<Impl> impl_;
}; };
} // namespace detail
} // namespace cv } // namespace cv
#endif // __OPENCV_STITCHING_SEAM_FINDERS_HPP__ #endif // __OPENCV_STITCHING_SEAM_FINDERS_HPP__
...@@ -56,8 +56,8 @@ ...@@ -56,8 +56,8 @@
#define LOGLN(msg) LOG(msg << std::endl) #define LOGLN(msg) LOG(msg << std::endl)
namespace cv namespace cv {
{ namespace detail {
class CV_EXPORTS DisjointSets class CV_EXPORTS DisjointSets
{ {
...@@ -114,6 +114,7 @@ Point CV_EXPORTS resultTl(const std::vector<Point> &corners); ...@@ -114,6 +114,7 @@ Point CV_EXPORTS resultTl(const std::vector<Point> &corners);
// Returns random 'count' element subset of the {0,1,...,size-1} set // Returns random 'count' element subset of the {0,1,...,size-1} set
void CV_EXPORTS selectRandomSubset(int count, int size, std::vector<int> &subset); void CV_EXPORTS selectRandomSubset(int count, int size, std::vector<int> &subset);
} // namespace detail
} // namespace cv } // namespace cv
#include "util_inl.hpp" #include "util_inl.hpp"
......
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#include "util.hpp" // Make your IDE see declarations #include "util.hpp" // Make your IDE see declarations
namespace cv namespace cv {
{ namespace detail {
template <typename B> template <typename B>
B Graph::forEach(B body) const B Graph::forEach(B body) const
...@@ -120,6 +120,7 @@ static inline int sqr(int x) { return x * x; } ...@@ -120,6 +120,7 @@ static inline int sqr(int x) { return x * x; }
static inline float sqr(float x) { return x * x; } static inline float sqr(float x) { return x * x; }
static inline double sqr(double x) { return x * x; } static inline double sqr(double x) { return x * x; }
} // namespace detail
} // namespace cv } // namespace cv
#endif // __OPENCV_STITCHING_UTIL_INL_HPP__ #endif // __OPENCV_STITCHING_UTIL_INL_HPP__
...@@ -46,8 +46,8 @@ ...@@ -46,8 +46,8 @@
#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/gpu/gpu.hpp" #include "opencv2/gpu/gpu.hpp"
namespace cv namespace cv {
{ namespace detail {
class CV_EXPORTS Warper class CV_EXPORTS Warper
{ {
...@@ -194,6 +194,7 @@ private: ...@@ -194,6 +194,7 @@ private:
gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_; gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
}; };
} // namespace detail
} // namespace cv } // namespace cv
#include "warpers_inl.hpp" #include "warpers_inl.hpp"
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#include "warpers.hpp" // Make your IDE see declarations #include "warpers.hpp" // Make your IDE see declarations
namespace cv namespace cv {
{ namespace detail {
template <class P> template <class P>
Point WarperBase<P>::warp(const Mat &src, float focal, const Mat &R, Mat &dst, Point WarperBase<P>::warp(const Mat &src, float focal, const Mat &R, Mat &dst,
...@@ -256,6 +256,7 @@ void CylindricalProjector::mapBackward(float u, float v, float &x, float &y) ...@@ -256,6 +256,7 @@ void CylindricalProjector::mapBackward(float u, float v, float &x, float &y)
y = focal * y / z + size.height * 0.5f; y = focal * y / z + size.height * 0.5f;
} }
} // namespace detail
} // namespace cv } // namespace cv
#endif // __OPENCV_STITCHING_WARPERS_INL_HPP__ #endif // __OPENCV_STITCHING_WARPERS_INL_HPP__
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_STITCHING_HPP__
#define __OPENCV_STITCHING_HPP__
#include "opencv2/stitching/autocalib.hpp"
#include "opencv2/stitching/blenders.hpp"
#include "opencv2/stitching/camera.hpp"
#include "opencv2/stitching/exposure_compensate.hpp"
#include "opencv2/stitching/matchers.hpp"
#include "opencv2/stitching/motion_estimators.hpp"
#include "opencv2/stitching/seam_finders.hpp"
#include "opencv2/stitching/util.hpp"
#include "opencv2/stitching/warpers.hpp"
#endif // __OPENCV_STITCHING_HPP__
...@@ -39,27 +39,32 @@ ...@@ -39,27 +39,32 @@
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
using namespace std; using namespace std;
using namespace cv; using namespace cv;
namespace namespace {
template<typename _Tp> static inline bool
decomposeCholesky(_Tp* A, size_t astep, int m)
{ {
template<typename _Tp> static inline bool if (!Cholesky(A, astep, m, 0, 0, 0))
decomposeCholesky(_Tp* A, size_t astep, int m) return false;
{ astep /= sizeof(A[0]);
if (!Cholesky(A, astep, m, 0, 0, 0)) for (int i = 0; i < m; ++i)
return false; A[i*astep + i] = (_Tp)(1./A[i*astep + i]);
astep /= sizeof(A[0]); return true;
for (int i = 0; i < m; ++i) }
A[i*astep + i] = (_Tp)(1./A[i*astep + i]);
return true;
}
} // namespace } // namespace
void cv::focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok, bool &f1_ok) namespace cv {
namespace detail {
void focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok, bool &f1_ok)
{ {
CV_Assert(H.type() == CV_64F && H.size() == Size(3, 3)); CV_Assert(H.type() == CV_64F && H.size() == Size(3, 3));
...@@ -90,7 +95,7 @@ void cv::focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok, ...@@ -90,7 +95,7 @@ void cv::focalsFromHomography(const Mat& H, double &f0, double &f1, bool &f0_ok,
} }
void cv::estimateFocal(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches, void estimateFocal(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches,
vector<double> &focals) vector<double> &focals)
{ {
const int num_images = static_cast<int>(features.size()); const int num_images = static_cast<int>(features.size());
...@@ -131,7 +136,7 @@ void cv::estimateFocal(const vector<ImageFeatures> &features, const vector<Match ...@@ -131,7 +136,7 @@ void cv::estimateFocal(const vector<ImageFeatures> &features, const vector<Match
} }
bool cv::calibrateRotatingCamera(const vector<Mat> &Hs, Mat &K) bool calibrateRotatingCamera(const vector<Mat> &Hs, Mat &K)
{ {
int m = static_cast<int>(Hs.size()); int m = static_cast<int>(Hs.size());
CV_Assert(m >= 1); CV_Assert(m >= 1);
...@@ -181,3 +186,6 @@ bool cv::calibrateRotatingCamera(const vector<Mat> &Hs, Mat &K) ...@@ -181,3 +186,6 @@ bool cv::calibrateRotatingCamera(const vector<Mat> &Hs, Mat &K)
K = W.t(); K = W.t();
return true; return true;
} }
} // namespace detail
} // namespace cv
...@@ -39,14 +39,17 @@ ...@@ -39,14 +39,17 @@
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
using namespace std; using namespace std;
using namespace cv;
namespace cv {
namespace detail {
static const float WEIGHT_EPS = 1e-5f; static const float WEIGHT_EPS = 1e-5f;
Ptr<Blender> cv::Blender::createDefault(int type, bool try_gpu) Ptr<Blender> Blender::createDefault(int type, bool try_gpu)
{ {
if (type == NO) if (type == NO)
return new Blender(); return new Blender();
...@@ -59,13 +62,13 @@ Ptr<Blender> cv::Blender::createDefault(int type, bool try_gpu) ...@@ -59,13 +62,13 @@ Ptr<Blender> cv::Blender::createDefault(int type, bool try_gpu)
} }
void cv::Blender::prepare(const vector<Point> &corners, const vector<Size> &sizes) void Blender::prepare(const vector<Point> &corners, const vector<Size> &sizes)
{ {
prepare(resultRoi(corners, sizes)); prepare(resultRoi(corners, sizes));
} }
void cv::Blender::prepare(Rect dst_roi) void Blender::prepare(Rect dst_roi)
{ {
dst_.create(dst_roi.size(), CV_16SC3); dst_.create(dst_roi.size(), CV_16SC3);
dst_.setTo(Scalar::all(0)); dst_.setTo(Scalar::all(0));
...@@ -75,7 +78,7 @@ void cv::Blender::prepare(Rect dst_roi) ...@@ -75,7 +78,7 @@ void cv::Blender::prepare(Rect dst_roi)
} }
void cv::Blender::feed(const Mat &img, const Mat &mask, Point tl) void Blender::feed(const Mat &img, const Mat &mask, Point tl)
{ {
CV_Assert(img.type() == CV_16SC3); CV_Assert(img.type() == CV_16SC3);
CV_Assert(mask.type() == CV_8U); CV_Assert(mask.type() == CV_8U);
...@@ -99,7 +102,7 @@ void cv::Blender::feed(const Mat &img, const Mat &mask, Point tl) ...@@ -99,7 +102,7 @@ void cv::Blender::feed(const Mat &img, const Mat &mask, Point tl)
} }
void cv::Blender::blend(Mat &dst, Mat &dst_mask) void Blender::blend(Mat &dst, Mat &dst_mask)
{ {
dst_.setTo(Scalar::all(0), dst_mask_ == 0); dst_.setTo(Scalar::all(0), dst_mask_ == 0);
dst = dst_; dst = dst_;
...@@ -109,7 +112,7 @@ void cv::Blender::blend(Mat &dst, Mat &dst_mask) ...@@ -109,7 +112,7 @@ void cv::Blender::blend(Mat &dst, Mat &dst_mask)
} }
void cv::FeatherBlender::prepare(Rect dst_roi) void FeatherBlender::prepare(Rect dst_roi)
{ {
Blender::prepare(dst_roi); Blender::prepare(dst_roi);
dst_weight_map_.create(dst_roi.size(), CV_32F); dst_weight_map_.create(dst_roi.size(), CV_32F);
...@@ -117,7 +120,7 @@ void cv::FeatherBlender::prepare(Rect dst_roi) ...@@ -117,7 +120,7 @@ void cv::FeatherBlender::prepare(Rect dst_roi)
} }
void cv::FeatherBlender::feed(const Mat &img, const Mat &mask, Point tl) void FeatherBlender::feed(const Mat &img, const Mat &mask, Point tl)
{ {
CV_Assert(img.type() == CV_16SC3); CV_Assert(img.type() == CV_16SC3);
CV_Assert(mask.type() == CV_8U); CV_Assert(mask.type() == CV_8U);
...@@ -144,7 +147,7 @@ void cv::FeatherBlender::feed(const Mat &img, const Mat &mask, Point tl) ...@@ -144,7 +147,7 @@ void cv::FeatherBlender::feed(const Mat &img, const Mat &mask, Point tl)
} }
void cv::FeatherBlender::blend(Mat &dst, Mat &dst_mask) void FeatherBlender::blend(Mat &dst, Mat &dst_mask)
{ {
normalizeUsingWeightMap(dst_weight_map_, dst_); normalizeUsingWeightMap(dst_weight_map_, dst_);
dst_mask_ = dst_weight_map_ > WEIGHT_EPS; dst_mask_ = dst_weight_map_ > WEIGHT_EPS;
...@@ -152,14 +155,14 @@ void cv::FeatherBlender::blend(Mat &dst, Mat &dst_mask) ...@@ -152,14 +155,14 @@ void cv::FeatherBlender::blend(Mat &dst, Mat &dst_mask)
} }
cv::MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands) MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands)
{ {
setNumBands(num_bands); setNumBands(num_bands);
can_use_gpu_ = try_gpu && gpu::getCudaEnabledDeviceCount(); can_use_gpu_ = try_gpu && gpu::getCudaEnabledDeviceCount();
} }
void cv::MultiBandBlender::prepare(Rect dst_roi) void MultiBandBlender::prepare(Rect dst_roi)
{ {
dst_roi_final_ = dst_roi; dst_roi_final_ = dst_roi;
...@@ -192,7 +195,7 @@ void cv::MultiBandBlender::prepare(Rect dst_roi) ...@@ -192,7 +195,7 @@ void cv::MultiBandBlender::prepare(Rect dst_roi)
} }
void cv::MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl) void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl)
{ {
CV_Assert(img.type() == CV_16SC3); CV_Assert(img.type() == CV_16SC3);
CV_Assert(mask.type() == CV_8U); CV_Assert(mask.type() == CV_8U);
...@@ -277,7 +280,7 @@ void cv::MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl) ...@@ -277,7 +280,7 @@ void cv::MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl)
} }
void cv::MultiBandBlender::blend(Mat &dst, Mat &dst_mask) void MultiBandBlender::blend(Mat &dst, Mat &dst_mask)
{ {
for (int i = 0; i <= num_bands_; ++i) for (int i = 0; i <= num_bands_; ++i)
normalizeUsingWeightMap(dst_band_weights_[i], dst_pyr_laplace_[i]); normalizeUsingWeightMap(dst_band_weights_[i], dst_pyr_laplace_[i]);
...@@ -298,7 +301,7 @@ void cv::MultiBandBlender::blend(Mat &dst, Mat &dst_mask) ...@@ -298,7 +301,7 @@ void cv::MultiBandBlender::blend(Mat &dst, Mat &dst_mask)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Auxiliary functions // Auxiliary functions
void cv::normalizeUsingWeightMap(const Mat& weight, Mat& src) void normalizeUsingWeightMap(const Mat& weight, Mat& src)
{ {
CV_Assert(weight.type() == CV_32F); CV_Assert(weight.type() == CV_32F);
CV_Assert(src.type() == CV_16SC3); CV_Assert(src.type() == CV_16SC3);
...@@ -317,7 +320,7 @@ void cv::normalizeUsingWeightMap(const Mat& weight, Mat& src) ...@@ -317,7 +320,7 @@ void cv::normalizeUsingWeightMap(const Mat& weight, Mat& src)
} }
void cv::createWeightMap(const Mat &mask, float sharpness, Mat &weight) void createWeightMap(const Mat &mask, float sharpness, Mat &weight)
{ {
CV_Assert(mask.type() == CV_8U); CV_Assert(mask.type() == CV_8U);
distanceTransform(mask, weight, CV_DIST_L1, 3); distanceTransform(mask, weight, CV_DIST_L1, 3);
...@@ -325,7 +328,7 @@ void cv::createWeightMap(const Mat &mask, float sharpness, Mat &weight) ...@@ -325,7 +328,7 @@ void cv::createWeightMap(const Mat &mask, float sharpness, Mat &weight)
} }
void cv::createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr) void createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr)
{ {
pyr.resize(num_levels + 1); pyr.resize(num_levels + 1);
pyr[0] = img; pyr[0] = img;
...@@ -340,7 +343,7 @@ void cv::createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr) ...@@ -340,7 +343,7 @@ void cv::createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr)
} }
void cv::createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr) void createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
{ {
pyr.resize(num_levels + 1); pyr.resize(num_levels + 1);
...@@ -361,7 +364,7 @@ void cv::createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr) ...@@ -361,7 +364,7 @@ void cv::createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
} }
void cv::restoreImageFromLaplacePyr(vector<Mat> &pyr) void restoreImageFromLaplacePyr(vector<Mat> &pyr)
{ {
if (pyr.size() == 0) if (pyr.size() == 0)
return; return;
...@@ -372,3 +375,6 @@ void cv::restoreImageFromLaplacePyr(vector<Mat> &pyr) ...@@ -372,3 +375,6 @@ void cv::restoreImageFromLaplacePyr(vector<Mat> &pyr)
add(tmp, pyr[i - 1], pyr[i - 1]); add(tmp, pyr[i - 1], pyr[i - 1]);
} }
} }
} // namespace detail
} // namespace cv
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp" #include "precomp.hpp"
using namespace std; using namespace std;
using namespace cv;
cv::CameraParams::CameraParams() : focal(1), R(Mat::eye(3, 3, CV_64F)), t(Mat::zeros(3, 1, CV_64F)) {} namespace cv {
namespace detail {
CameraParams::CameraParams() : focal(1), R(Mat::eye(3, 3, CV_64F)), t(Mat::zeros(3, 1, CV_64F)) {}
cv::CameraParams::CameraParams(const CameraParams &other) { *this = other; } CameraParams::CameraParams(const CameraParams &other) { *this = other; }
const cv::CameraParams& CameraParams::operator =(const CameraParams &other) const CameraParams& CameraParams::operator =(const CameraParams &other)
{ {
focal = other.focal; focal = other.focal;
R = other.R.clone(); R = other.R.clone();
t = other.t.clone(); t = other.t.clone();
return *this; return *this;
} }
} // namespace detail
} // namespace cv
...@@ -39,13 +39,16 @@ ...@@ -39,13 +39,16 @@
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
using namespace std; using namespace std;
using namespace cv;
using namespace cv::gpu; using namespace cv::gpu;
Ptr<ExposureCompensator> cv::ExposureCompensator::createDefault(int type) namespace cv {
namespace detail {
Ptr<ExposureCompensator> ExposureCompensator::createDefault(int type)
{ {
if (type == NO) if (type == NO)
return new NoExposureCompensator(); return new NoExposureCompensator();
...@@ -58,8 +61,8 @@ Ptr<ExposureCompensator> cv::ExposureCompensator::createDefault(int type) ...@@ -58,8 +61,8 @@ Ptr<ExposureCompensator> cv::ExposureCompensator::createDefault(int type)
} }
void cv::ExposureCompensator::feed(const vector<Point> &corners, const vector<Mat> &images, void ExposureCompensator::feed(const vector<Point> &corners, const vector<Mat> &images,
const vector<Mat> &masks) const vector<Mat> &masks)
{ {
vector<pair<Mat,uchar> > level_masks; vector<pair<Mat,uchar> > level_masks;
for (size_t i = 0; i < masks.size(); ++i) for (size_t i = 0; i < masks.size(); ++i)
...@@ -68,8 +71,8 @@ void cv::ExposureCompensator::feed(const vector<Point> &corners, const vector<Ma ...@@ -68,8 +71,8 @@ void cv::ExposureCompensator::feed(const vector<Point> &corners, const vector<Ma
} }
void cv::GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &images, void GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &images,
const vector<pair<Mat,uchar> > &masks) const vector<pair<Mat,uchar> > &masks)
{ {
LOGLN("Exposure compensation..."); LOGLN("Exposure compensation...");
int64 t = getTickCount(); int64 t = getTickCount();
...@@ -143,13 +146,13 @@ void cv::GainCompensator::feed(const vector<Point> &corners, const vector<Mat> & ...@@ -143,13 +146,13 @@ void cv::GainCompensator::feed(const vector<Point> &corners, const vector<Mat> &
} }
void cv::GainCompensator::apply(int index, Point /*corner*/, Mat &image, const Mat &/*mask*/) void GainCompensator::apply(int index, Point /*corner*/, Mat &image, const Mat &/*mask*/)
{ {
image *= gains_(index, 0); image *= gains_(index, 0);
} }
vector<double> cv::GainCompensator::gains() const vector<double> GainCompensator::gains() const
{ {
vector<double> gains_vec(gains_.rows); vector<double> gains_vec(gains_.rows);
for (int i = 0; i < gains_.rows; ++i) for (int i = 0; i < gains_.rows; ++i)
...@@ -158,7 +161,7 @@ vector<double> cv::GainCompensator::gains() const ...@@ -158,7 +161,7 @@ vector<double> cv::GainCompensator::gains() const
} }
void cv::BlocksGainCompensator::feed(const vector<Point> &corners, const vector<Mat> &images, void BlocksGainCompensator::feed(const vector<Point> &corners, const vector<Mat> &images,
const vector<pair<Mat,uchar> > &masks) const vector<pair<Mat,uchar> > &masks)
{ {
CV_Assert(corners.size() == images.size() && images.size() == masks.size()); CV_Assert(corners.size() == images.size() && images.size() == masks.size());
...@@ -218,7 +221,7 @@ void cv::BlocksGainCompensator::feed(const vector<Point> &corners, const vector< ...@@ -218,7 +221,7 @@ void cv::BlocksGainCompensator::feed(const vector<Point> &corners, const vector<
} }
void cv::BlocksGainCompensator::apply(int index, Point /*corner*/, Mat &image, const Mat &/*mask*/) void BlocksGainCompensator::apply(int index, Point /*corner*/, Mat &image, const Mat &/*mask*/)
{ {
CV_Assert(image.type() == CV_8UC3); CV_Assert(image.type() == CV_8UC3);
...@@ -240,3 +243,6 @@ void cv::BlocksGainCompensator::apply(int index, Point /*corner*/, Mat &image, c ...@@ -240,3 +243,6 @@ void cv::BlocksGainCompensator::apply(int index, Point /*corner*/, Mat &image, c
} }
} }
} }
} // namespace detail
} // namespace cv
This diff is collapsed.
...@@ -39,56 +39,69 @@ ...@@ -39,56 +39,69 @@
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
using namespace std; using namespace std;
using namespace cv; using namespace cv;
using namespace cv::detail;
namespace {
namespace struct IncDistance
{ {
IncDistance(vector<int> &dists) : dists(&dists[0]) {}
void operator ()(const GraphEdge &edge) { dists[edge.to] = dists[edge.from] + 1; }
int* dists;
};
struct IncDistance
{
IncDistance(vector<int> &dists) : dists(&dists[0]) {}
void operator ()(const GraphEdge &edge) { dists[edge.to] = dists[edge.from] + 1; }
int* dists;
};
struct CalcRotation
{
CalcRotation(int num_images, const vector<MatchesInfo> &pairwise_matches, vector<CameraParams> &cameras)
: num_images(num_images), pairwise_matches(&pairwise_matches[0]), cameras(&cameras[0]) {}
struct CalcRotation void operator ()(const GraphEdge &edge)
{ {
CalcRotation(int num_images, const vector<MatchesInfo> &pairwise_matches, vector<CameraParams> &cameras) int pair_idx = edge.from * num_images + edge.to;
: num_images(num_images), pairwise_matches(&pairwise_matches[0]), cameras(&cameras[0]) {}
void operator ()(const GraphEdge &edge) double f_from = cameras[edge.from].focal;
{ double f_to = cameras[edge.to].focal;
int pair_idx = edge.from * num_images + edge.to;
Mat K_from = Mat::eye(3, 3, CV_64F);
K_from.at<double>(0, 0) = f_from;
K_from.at<double>(1, 1) = f_from;
double f_from = cameras[edge.from].focal; Mat K_to = Mat::eye(3, 3, CV_64F);
double f_to = cameras[edge.to].focal; K_to.at<double>(0, 0) = f_to;
K_to.at<double>(1, 1) = f_to;
Mat K_from = Mat::eye(3, 3, CV_64F); Mat R = K_from.inv() * pairwise_matches[pair_idx].H.inv() * K_to;
K_from.at<double>(0, 0) = f_from; cameras[edge.to].R = cameras[edge.from].R * R;
K_from.at<double>(1, 1) = f_from; }
Mat K_to = Mat::eye(3, 3, CV_64F); int num_images;
K_to.at<double>(0, 0) = f_to; const MatchesInfo* pairwise_matches;
K_to.at<double>(1, 1) = f_to; CameraParams* cameras;
};
Mat R = K_from.inv() * pairwise_matches[pair_idx].H.inv() * K_to;
cameras[edge.to].R = cameras[edge.from].R * R;
}
int num_images; //////////////////////////////////////////////////////////////////////////////
const MatchesInfo* pairwise_matches;
CameraParams* cameras; void calcDeriv(const Mat &err1, const Mat &err2, double h, Mat res)
}; {
for (int i = 0; i < err1.rows; ++i)
res.at<double>(i, 0) = (err2.at<double>(i, 0) - err1.at<double>(i, 0)) / h;
}
} // namespace } // namespace
void cv::HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches, namespace cv {
vector<CameraParams> &cameras) namespace detail {
void HomographyBasedEstimator::estimate(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches,
vector<CameraParams> &cameras)
{ {
LOGLN("Estimating rotations..."); LOGLN("Estimating rotations...");
int64 t = getTickCount(); int64 t = getTickCount();
...@@ -135,8 +148,8 @@ void cv::HomographyBasedEstimator::estimate(const vector<ImageFeatures> &feature ...@@ -135,8 +148,8 @@ void cv::HomographyBasedEstimator::estimate(const vector<ImageFeatures> &feature
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void cv::BundleAdjuster::estimate(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches, void BundleAdjuster::estimate(const vector<ImageFeatures> &features, const vector<MatchesInfo> &pairwise_matches,
vector<CameraParams> &cameras) vector<CameraParams> &cameras)
{ {
if (cost_space_ == NO) if (cost_space_ == NO)
return; return;
...@@ -250,7 +263,7 @@ void cv::BundleAdjuster::estimate(const vector<ImageFeatures> &features, const v ...@@ -250,7 +263,7 @@ void cv::BundleAdjuster::estimate(const vector<ImageFeatures> &features, const v
} }
void cv::BundleAdjuster::calcError(Mat &err) void BundleAdjuster::calcError(Mat &err)
{ {
err.create(total_num_matches_ * 3, 1, CV_64F); err.create(total_num_matches_ * 3, 1, CV_64F);
...@@ -314,19 +327,7 @@ void cv::BundleAdjuster::calcError(Mat &err) ...@@ -314,19 +327,7 @@ void cv::BundleAdjuster::calcError(Mat &err)
} }
namespace void BundleAdjuster::calcJacobian()
{
void calcDeriv(const Mat &err1, const Mat &err2, double h, Mat res)
{
for (int i = 0; i < err1.rows; ++i)
res.at<double>(i, 0) = (err2.at<double>(i, 0) - err1.at<double>(i, 0)) / h;
}
} // namespace
void cv::BundleAdjuster::calcJacobian()
{ {
J_.create(total_num_matches_ * 3, num_images_ * 4, CV_64F); J_.create(total_num_matches_ * 3, num_images_ * 4, CV_64F);
...@@ -374,7 +375,7 @@ void cv::BundleAdjuster::calcJacobian() ...@@ -374,7 +375,7 @@ void cv::BundleAdjuster::calcJacobian()
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// TODO replace SVD with eigen // TODO replace SVD with eigen
void cv::waveCorrect(vector<Mat> &rmats) void waveCorrect(vector<Mat> &rmats)
{ {
LOGLN("Wave correcting..."); LOGLN("Wave correcting...");
int64 t = getTickCount(); int64 t = getTickCount();
...@@ -415,7 +416,7 @@ void cv::waveCorrect(vector<Mat> &rmats) ...@@ -415,7 +416,7 @@ void cv::waveCorrect(vector<Mat> &rmats)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
string cv::matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pairwise_matches, string matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pairwise_matches,
float conf_threshold) float conf_threshold)
{ {
stringstream str; stringstream str;
...@@ -481,7 +482,7 @@ string cv::matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pai ...@@ -481,7 +482,7 @@ string cv::matchesGraphAsString(vector<string> &pathes, vector<MatchesInfo> &pai
return str.str(); return str.str();
} }
vector<int> cv::leaveBiggestComponent(vector<ImageFeatures> &features, vector<MatchesInfo> &pairwise_matches, vector<int> leaveBiggestComponent(vector<ImageFeatures> &features, vector<MatchesInfo> &pairwise_matches,
float conf_threshold) float conf_threshold)
{ {
const int num_images = static_cast<int>(features.size()); const int num_images = static_cast<int>(features.size());
...@@ -539,7 +540,7 @@ vector<int> cv::leaveBiggestComponent(vector<ImageFeatures> &features, vector<M ...@@ -539,7 +540,7 @@ vector<int> cv::leaveBiggestComponent(vector<ImageFeatures> &features, vector<M
} }
void cv::findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise_matches, void findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise_matches,
Graph &span_tree, vector<int> &centers) Graph &span_tree, vector<int> &centers)
{ {
Graph graph(num_images); Graph graph(num_images);
...@@ -608,3 +609,7 @@ void cv::findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise ...@@ -608,3 +609,7 @@ void cv::findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise
centers.push_back(i); centers.push_back(i);
CV_Assert(centers.size() > 0 && centers.size() <= 2); CV_Assert(centers.size() > 0 && centers.size() <= 2);
} }
} // namespace detail
} // namespace cv
...@@ -52,15 +52,15 @@ ...@@ -52,15 +52,15 @@
#include <set> #include <set>
#include <functional> #include <functional>
#include <sstream> #include <sstream>
#include "opencv2/stitching/autocalib.hpp" #include "opencv2/stitching/detail/autocalib.hpp"
#include "opencv2/stitching/blenders.hpp" #include "opencv2/stitching/detail/blenders.hpp"
#include "opencv2/stitching/camera.hpp" #include "opencv2/stitching/detail/camera.hpp"
#include "opencv2/stitching/exposure_compensate.hpp" #include "opencv2/stitching/detail/exposure_compensate.hpp"
#include "opencv2/stitching/matchers.hpp" #include "opencv2/stitching/detail/matchers.hpp"
#include "opencv2/stitching/motion_estimators.hpp" #include "opencv2/stitching/detail/motion_estimators.hpp"
#include "opencv2/stitching/seam_finders.hpp" #include "opencv2/stitching/detail/seam_finders.hpp"
#include "opencv2/stitching/util.hpp" #include "opencv2/stitching/detail/util.hpp"
#include "opencv2/stitching/warpers.hpp" #include "opencv2/stitching/detail/warpers.hpp"
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
#include "opencv2/core/internal.hpp" #include "opencv2/core/internal.hpp"
#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/imgproc/imgproc.hpp"
......
...@@ -39,12 +39,15 @@ ...@@ -39,12 +39,15 @@
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
using namespace std; using namespace std;
using namespace cv;
Ptr<SeamFinder> cv::SeamFinder::createDefault(int type) namespace cv {
namespace detail {
Ptr<SeamFinder> SeamFinder::createDefault(int type)
{ {
if (type == NO) if (type == NO)
return new NoSeamFinder(); return new NoSeamFinder();
...@@ -59,7 +62,7 @@ Ptr<SeamFinder> cv::SeamFinder::createDefault(int type) ...@@ -59,7 +62,7 @@ Ptr<SeamFinder> cv::SeamFinder::createDefault(int type)
} }
void cv::PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners, void PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners,
vector<Mat> &masks) vector<Mat> &masks)
{ {
LOGLN("Finding seams..."); LOGLN("Finding seams...");
...@@ -86,7 +89,7 @@ void cv::PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &c ...@@ -86,7 +89,7 @@ void cv::PairwiseSeamFinder::find(const vector<Mat> &src, const vector<Point> &c
} }
void cv::VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi) void VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi)
{ {
const int gap = 10; const int gap = 10;
Mat submask1(roi.height + 2 * gap, roi.width + 2 * gap, CV_8U); Mat submask1(roi.height + 2 * gap, roi.width + 2 * gap, CV_8U);
...@@ -140,7 +143,7 @@ void cv::VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi) ...@@ -140,7 +143,7 @@ void cv::VoronoiSeamFinder::findInPair(size_t first, size_t second, Rect roi)
} }
class cv::GraphCutSeamFinder::Impl : public PairwiseSeamFinder class GraphCutSeamFinder::Impl : public PairwiseSeamFinder
{ {
public: public:
Impl(int cost_type, float terminal_cost, float bad_region_penalty) Impl(int cost_type, float terminal_cost, float bad_region_penalty)
...@@ -163,7 +166,7 @@ private: ...@@ -163,7 +166,7 @@ private:
}; };
void cv::GraphCutSeamFinder::Impl::find(const vector<Mat> &src, const vector<Point> &corners, void GraphCutSeamFinder::Impl::find(const vector<Mat> &src, const vector<Point> &corners,
vector<Mat> &masks) vector<Mat> &masks)
{ {
// Compute gradients // Compute gradients
...@@ -194,7 +197,7 @@ void cv::GraphCutSeamFinder::Impl::find(const vector<Mat> &src, const vector<Poi ...@@ -194,7 +197,7 @@ void cv::GraphCutSeamFinder::Impl::find(const vector<Mat> &src, const vector<Poi
} }
void cv::GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const Mat &img2, void GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const Mat &img2,
const Mat &mask1, const Mat &mask2, GCGraph<float> &graph) const Mat &mask1, const Mat &mask2, GCGraph<float> &graph)
{ {
const Size img_size = img1.size(); const Size img_size = img1.size();
...@@ -242,7 +245,7 @@ void cv::GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const M ...@@ -242,7 +245,7 @@ void cv::GraphCutSeamFinder::Impl::setGraphWeightsColor(const Mat &img1, const M
} }
void cv::GraphCutSeamFinder::Impl::setGraphWeightsColorGrad( void GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2, const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,
const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2, const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,
GCGraph<float> &graph) GCGraph<float> &graph)
...@@ -296,7 +299,7 @@ void cv::GraphCutSeamFinder::Impl::setGraphWeightsColorGrad( ...@@ -296,7 +299,7 @@ void cv::GraphCutSeamFinder::Impl::setGraphWeightsColorGrad(
} }
void cv::GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect roi) void GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect roi)
{ {
Mat img1 = images_[first], img2 = images_[second]; Mat img1 = images_[first], img2 = images_[second];
Mat dx1 = dx_[first], dx2 = dx_[second]; Mat dx1 = dx_[first], dx2 = dx_[second];
...@@ -394,12 +397,16 @@ void cv::GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect ...@@ -394,12 +397,16 @@ void cv::GraphCutSeamFinder::Impl::findInPair(size_t first, size_t second, Rect
} }
cv::GraphCutSeamFinder::GraphCutSeamFinder(int cost_type, float terminal_cost, float bad_region_penalty) GraphCutSeamFinder::GraphCutSeamFinder(int cost_type, float terminal_cost, float bad_region_penalty)
: impl_(new Impl(cost_type, terminal_cost, bad_region_penalty)) {} : impl_(new Impl(cost_type, terminal_cost, bad_region_penalty)) {}
void cv::GraphCutSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners, void GraphCutSeamFinder::find(const vector<Mat> &src, const vector<Point> &corners,
vector<Mat> &masks) vector<Mat> &masks)
{ {
impl_->find(src, corners, masks); impl_->find(src, corners, masks);
} }
} // namespace detail
} // namespace cv
...@@ -42,9 +42,11 @@ ...@@ -42,9 +42,11 @@
#include "precomp.hpp" #include "precomp.hpp"
using namespace std; using namespace std;
using namespace cv;
void cv::DisjointSets::createOneElemSets(int n) namespace cv {
namespace detail {
void DisjointSets::createOneElemSets(int n)
{ {
rank_.assign(n, 0); rank_.assign(n, 0);
size.assign(n, 1); size.assign(n, 1);
...@@ -54,7 +56,7 @@ void cv::DisjointSets::createOneElemSets(int n) ...@@ -54,7 +56,7 @@ void cv::DisjointSets::createOneElemSets(int n)
} }
int cv::DisjointSets::findSetByElem(int elem) int DisjointSets::findSetByElem(int elem)
{ {
int set = elem; int set = elem;
while (set != parent[set]) while (set != parent[set])
...@@ -70,7 +72,7 @@ int cv::DisjointSets::findSetByElem(int elem) ...@@ -70,7 +72,7 @@ int cv::DisjointSets::findSetByElem(int elem)
} }
int cv::DisjointSets::mergeSets(int set1, int set2) int DisjointSets::mergeSets(int set1, int set2)
{ {
if (rank_[set1] < rank_[set2]) if (rank_[set1] < rank_[set2])
{ {
...@@ -91,13 +93,13 @@ int cv::DisjointSets::mergeSets(int set1, int set2) ...@@ -91,13 +93,13 @@ int cv::DisjointSets::mergeSets(int set1, int set2)
} }
void cv::Graph::addEdge(int from, int to, float weight) void Graph::addEdge(int from, int to, float weight)
{ {
edges_[from].push_back(GraphEdge(from, to, weight)); edges_[from].push_back(GraphEdge(from, to, weight));
} }
bool cv::overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi) bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi)
{ {
int x_tl = max(tl1.x, tl2.x); int x_tl = max(tl1.x, tl2.x);
int y_tl = max(tl1.y, tl2.y); int y_tl = max(tl1.y, tl2.y);
...@@ -112,7 +114,7 @@ bool cv::overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi) ...@@ -112,7 +114,7 @@ bool cv::overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi)
} }
Rect cv::resultRoi(const vector<Point> &corners, const vector<Mat> &images) Rect resultRoi(const vector<Point> &corners, const vector<Mat> &images)
{ {
vector<Size> sizes(images.size()); vector<Size> sizes(images.size());
for (size_t i = 0; i < images.size(); ++i) for (size_t i = 0; i < images.size(); ++i)
...@@ -121,7 +123,7 @@ Rect cv::resultRoi(const vector<Point> &corners, const vector<Mat> &images) ...@@ -121,7 +123,7 @@ Rect cv::resultRoi(const vector<Point> &corners, const vector<Mat> &images)
} }
Rect cv::resultRoi(const vector<Point> &corners, const vector<Size> &sizes) Rect resultRoi(const vector<Point> &corners, const vector<Size> &sizes)
{ {
CV_Assert(sizes.size() == corners.size()); CV_Assert(sizes.size() == corners.size());
Point tl(numeric_limits<int>::max(), numeric_limits<int>::max()); Point tl(numeric_limits<int>::max(), numeric_limits<int>::max());
...@@ -137,7 +139,7 @@ Rect cv::resultRoi(const vector<Point> &corners, const vector<Size> &sizes) ...@@ -137,7 +139,7 @@ Rect cv::resultRoi(const vector<Point> &corners, const vector<Size> &sizes)
} }
Point cv::resultTl(const vector<Point> &corners) Point resultTl(const vector<Point> &corners)
{ {
Point tl(numeric_limits<int>::max(), numeric_limits<int>::max()); Point tl(numeric_limits<int>::max(), numeric_limits<int>::max());
for (size_t i = 0; i < corners.size(); ++i) for (size_t i = 0; i < corners.size(); ++i)
...@@ -149,7 +151,7 @@ Point cv::resultTl(const vector<Point> &corners) ...@@ -149,7 +151,7 @@ Point cv::resultTl(const vector<Point> &corners)
} }
void cv::selectRandomSubset(int count, int size, vector<int> &subset) void selectRandomSubset(int count, int size, vector<int> &subset)
{ {
subset.clear(); subset.clear();
for (int i = 0; i < size; ++i) for (int i = 0; i < size; ++i)
...@@ -161,3 +163,6 @@ void cv::selectRandomSubset(int count, int size, vector<int> &subset) ...@@ -161,3 +163,6 @@ void cv::selectRandomSubset(int count, int size, vector<int> &subset)
} }
} }
} }
} // namespace detail
} // namespace cv
...@@ -39,12 +39,15 @@ ...@@ -39,12 +39,15 @@
// the use of this software, even if advised of the possibility of such damage. // the use of this software, even if advised of the possibility of such damage.
// //
//M*/ //M*/
#include "precomp.hpp" #include "precomp.hpp"
using namespace std; using namespace std;
using namespace cv;
Ptr<Warper> cv::Warper::createByCameraFocal(float focal, int type, bool try_gpu) namespace cv {
namespace detail {
Ptr<Warper> Warper::createByCameraFocal(float focal, int type, bool try_gpu)
{ {
bool can_use_gpu = try_gpu && gpu::getCudaEnabledDeviceCount(); bool can_use_gpu = try_gpu && gpu::getCudaEnabledDeviceCount();
if (type == PLANE) if (type == PLANE)
...@@ -58,7 +61,7 @@ Ptr<Warper> cv::Warper::createByCameraFocal(float focal, int type, bool try_gpu) ...@@ -58,7 +61,7 @@ Ptr<Warper> cv::Warper::createByCameraFocal(float focal, int type, bool try_gpu)
} }
void cv::ProjectorBase::setTransformation(const Mat &R) void ProjectorBase::setTransformation(const Mat &R)
{ {
CV_Assert(R.size() == Size(3, 3)); CV_Assert(R.size() == Size(3, 3));
CV_Assert(R.type() == CV_32F); CV_Assert(R.type() == CV_32F);
...@@ -73,7 +76,7 @@ void cv::ProjectorBase::setTransformation(const Mat &R) ...@@ -73,7 +76,7 @@ void cv::ProjectorBase::setTransformation(const Mat &R)
} }
void cv::PlaneWarper::detectResultRoi(Point &dst_tl, Point &dst_br) void PlaneWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
{ {
float tl_uf = numeric_limits<float>::max(); float tl_uf = numeric_limits<float>::max();
float tl_vf = numeric_limits<float>::max(); float tl_vf = numeric_limits<float>::max();
...@@ -105,14 +108,14 @@ void cv::PlaneWarper::detectResultRoi(Point &dst_tl, Point &dst_br) ...@@ -105,14 +108,14 @@ void cv::PlaneWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
} }
Point cv::PlaneWarperGpu::warp(const Mat &src, float focal, const cv::Mat &R, cv::Mat &dst, int interp_mode, int border_mode) Point PlaneWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst, int interp_mode, int border_mode)
{ {
src_size_ = src.size(); src_size_ = src.size();
projector_.size = src.size(); projector_.size = src.size();
projector_.focal = focal; projector_.focal = focal;
projector_.setTransformation(R); projector_.setTransformation(R);
cv::Point dst_tl, dst_br; Point dst_tl, dst_br;
detectResultRoi(dst_tl, dst_br); detectResultRoi(dst_tl, dst_br);
gpu::buildWarpPlaneMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)), gpu::buildWarpPlaneMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)),
...@@ -131,7 +134,7 @@ Point cv::PlaneWarperGpu::warp(const Mat &src, float focal, const cv::Mat &R, cv ...@@ -131,7 +134,7 @@ Point cv::PlaneWarperGpu::warp(const Mat &src, float focal, const cv::Mat &R, cv
} }
void cv::SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br) void SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
{ {
detectResultRoiByBorder(dst_tl, dst_br); detectResultRoiByBorder(dst_tl, dst_br);
...@@ -175,7 +178,7 @@ void cv::SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br) ...@@ -175,7 +178,7 @@ void cv::SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
} }
Point cv::SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst, Point SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst,
int interp_mode, int border_mode) int interp_mode, int border_mode)
{ {
src_size_ = src.size(); src_size_ = src.size();
...@@ -183,7 +186,7 @@ Point cv::SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Ma ...@@ -183,7 +186,7 @@ Point cv::SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Ma
projector_.focal = focal; projector_.focal = focal;
projector_.setTransformation(R); projector_.setTransformation(R);
cv::Point dst_tl, dst_br; Point dst_tl, dst_br;
detectResultRoi(dst_tl, dst_br); detectResultRoi(dst_tl, dst_br);
gpu::buildWarpSphericalMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)), gpu::buildWarpSphericalMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)),
...@@ -202,7 +205,7 @@ Point cv::SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Ma ...@@ -202,7 +205,7 @@ Point cv::SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Ma
} }
Point cv::CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst, Point CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst,
int interp_mode, int border_mode) int interp_mode, int border_mode)
{ {
src_size_ = src.size(); src_size_ = src.size();
...@@ -210,7 +213,7 @@ Point cv::CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, ...@@ -210,7 +213,7 @@ Point cv::CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R,
projector_.focal = focal; projector_.focal = focal;
projector_.setTransformation(R); projector_.setTransformation(R);
cv::Point dst_tl, dst_br; Point dst_tl, dst_br;
detectResultRoi(dst_tl, dst_br); detectResultRoi(dst_tl, dst_br);
gpu::buildWarpCylindricalMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)), gpu::buildWarpCylindricalMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)),
...@@ -228,3 +231,5 @@ Point cv::CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, ...@@ -228,3 +231,5 @@ Point cv::CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R,
return dst_tl; return dst_tl;
} }
} // namespace detail
} // namespace cv
...@@ -49,11 +49,20 @@ ...@@ -49,11 +49,20 @@
// Matthew Brown and David G. Lowe. 2007. // Matthew Brown and David G. Lowe. 2007.
#include <fstream> #include <fstream>
#include "opencv2/stitching/stitching.hpp"
#include "opencv2/highgui/highgui.hpp" #include "opencv2/highgui/highgui.hpp"
#include "opencv2/stitching/detail/autocalib.hpp"
#include "opencv2/stitching/detail/blenders.hpp"
#include "opencv2/stitching/detail/camera.hpp"
#include "opencv2/stitching/detail/exposure_compensate.hpp"
#include "opencv2/stitching/detail/matchers.hpp"
#include "opencv2/stitching/detail/motion_estimators.hpp"
#include "opencv2/stitching/detail/seam_finders.hpp"
#include "opencv2/stitching/detail/util.hpp"
#include "opencv2/stitching/detail/warpers.hpp"
using namespace std; using namespace std;
using namespace cv; using namespace cv;
using namespace cv::detail;
void printUsage() void printUsage()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment