#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
}\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
}\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
K = W.t();\r
return true;\r
}\r
-\r
-} // namespace cv\r
#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
}\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
}\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
}\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
}\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
}\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
}\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
}\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
}\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
}\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
//////////////////////////////////////////////////////////////////////////////\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
}\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
}\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
}\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
}\r
\r
\r
-void restoreImageFromLaplacePyr(vector<Mat> &pyr)\r
+void cv::restoreImageFromLaplacePyr(vector<Mat> &pyr)\r
{\r
if (pyr.size() == 0)\r
return;\r
add(tmp, pyr[i - 1], pyr[i - 1]);\r
}\r
}\r
-\r
-} // namespace cv\r
#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
#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
}\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
}\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
}\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
}\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
}\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
}\r
}\r
}\r
-\r
-} // namespace cv\r
#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
} // 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
}\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
\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
\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
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
}\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
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
#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
\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
}\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
}\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
//////////////////////////////////////////////////////////////////////////////\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
\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
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
}\r
\r
\r
-void findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise_matches,\r
- Graph &span_tree, vector<int> ¢ers)\r
+void cv::findMaxSpanningTree(int num_images, const vector<MatchesInfo> &pairwise_matches,\r
+ Graph &span_tree, vector<int> ¢ers)\r
{\r
Graph graph(num_images);\r
vector<GraphEdge> edges;\r
centers.push_back(i);\r
CV_Assert(centers.size() > 0 && centers.size() <= 2);\r
}\r
-\r
-} // namespace cv\r
#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
}\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
}\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
}\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
};\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
}\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
}\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
}\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
}\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
#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
}\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
}\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
}\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
}\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
}\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
}\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
}\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
}\r
}\r
}\r
-\r
-} // namespace cv\r
#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
}\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
}\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
}\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
}\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
}\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
}\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
return dst_tl;\r
}\r
\r
-} // namespace cv\r