added first version of public stitching API, added simple sample which uses that API, old sample renamed to stitching_detailed
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_AUTOCALIB_HPP__
|
||||
#define __OPENCV_STITCHING_AUTOCALIB_HPP__
|
||||
|
||||
|
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_BLENDERS_HPP__
|
||||
#define __OPENCV_STITCHING_BLENDERS_HPP__
|
||||
|
||||
@@ -56,7 +57,7 @@ public:
|
||||
enum { NO, FEATHER, MULTI_BAND };
|
||||
static Ptr<Blender> createDefault(int type, bool try_gpu = false);
|
||||
|
||||
void prepare(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
void prepare(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
virtual void prepare(Rect dst_roi);
|
||||
virtual void feed(const Mat &img, const Mat &mask, Point tl);
|
||||
virtual void blend(Mat &dst, Mat &dst_mask);
|
||||
|
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_CAMERA_HPP__
|
||||
#define __OPENCV_STITCHING_CAMERA_HPP__
|
||||
|
||||
|
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__
|
||||
#define __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__
|
||||
|
||||
|
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_MATCHERS_HPP__
|
||||
#define __OPENCV_STITCHING_MATCHERS_HPP__
|
||||
|
||||
@@ -51,9 +52,9 @@ namespace detail {
|
||||
struct CV_EXPORTS ImageFeatures
|
||||
{
|
||||
int img_idx;
|
||||
cv::Size img_size;
|
||||
std::vector<cv::KeyPoint> keypoints;
|
||||
cv::Mat descriptors;
|
||||
Size img_size;
|
||||
std::vector<KeyPoint> keypoints;
|
||||
Mat descriptors;
|
||||
};
|
||||
|
||||
|
||||
@@ -61,12 +62,13 @@ class CV_EXPORTS FeaturesFinder
|
||||
{
|
||||
public:
|
||||
virtual ~FeaturesFinder() {}
|
||||
void operator ()(const cv::Mat &image, ImageFeatures &features);
|
||||
void operator ()(const Mat &image, ImageFeatures &features);
|
||||
|
||||
virtual void releaseMemory() {}
|
||||
// TODO put it into operator ()
|
||||
virtual void collectGarbage() {}
|
||||
|
||||
protected:
|
||||
virtual void find(const cv::Mat &image, ImageFeatures &features) = 0;
|
||||
virtual void find(const Mat &image, ImageFeatures &features) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -77,12 +79,12 @@ public:
|
||||
int num_octaves = 3, int num_layers = 4,
|
||||
int num_octaves_descr = 4, int num_layers_descr = 2);
|
||||
|
||||
void releaseMemory();
|
||||
void collectGarbage();
|
||||
|
||||
protected:
|
||||
void find(const cv::Mat &image, ImageFeatures &features);
|
||||
void find(const Mat &image, ImageFeatures &features);
|
||||
|
||||
cv::Ptr<FeaturesFinder> impl_;
|
||||
Ptr<FeaturesFinder> impl_;
|
||||
};
|
||||
|
||||
|
||||
@@ -93,10 +95,10 @@ struct CV_EXPORTS MatchesInfo
|
||||
const MatchesInfo& operator =(const MatchesInfo &other);
|
||||
|
||||
int src_img_idx, dst_img_idx; // Images indices (optional)
|
||||
std::vector<cv::DMatch> matches;
|
||||
std::vector<DMatch> matches;
|
||||
std::vector<uchar> inliers_mask; // Geometrically consistent matches mask
|
||||
int num_inliers; // Number of geometrically consistent matches
|
||||
cv::Mat H; // Estimated homography
|
||||
Mat H; // Estimated homography
|
||||
double confidence; // Confidence two images are from the same panorama
|
||||
};
|
||||
|
||||
@@ -112,7 +114,7 @@ public:
|
||||
|
||||
bool isThreadSafe() const { return is_thread_safe_; }
|
||||
|
||||
virtual void releaseMemory() {}
|
||||
virtual void collectGarbage() {}
|
||||
|
||||
protected:
|
||||
FeaturesMatcher(bool is_thread_safe = false) : is_thread_safe_(is_thread_safe) {}
|
||||
@@ -127,17 +129,17 @@ protected:
|
||||
class CV_EXPORTS BestOf2NearestMatcher : public FeaturesMatcher
|
||||
{
|
||||
public:
|
||||
BestOf2NearestMatcher(bool try_use_gpu = true, float match_conf = 0.55f, int num_matches_thresh1 = 6,
|
||||
BestOf2NearestMatcher(bool try_use_gpu = true, float match_conf = 0.65f, int num_matches_thresh1 = 6,
|
||||
int num_matches_thresh2 = 6);
|
||||
|
||||
void releaseMemory();
|
||||
void collectGarbage();
|
||||
|
||||
protected:
|
||||
void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info);
|
||||
|
||||
int num_matches_thresh1_;
|
||||
int num_matches_thresh2_;
|
||||
cv::Ptr<FeaturesMatcher> impl_;
|
||||
Ptr<FeaturesMatcher> impl_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_MOTION_ESTIMATORS_HPP__
|
||||
#define __OPENCV_STITCHING_MOTION_ESTIMATORS_HPP__
|
||||
|
||||
|
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_SEAM_FINDERS_HPP__
|
||||
#define __OPENCV_STITCHING_SEAM_FINDERS_HPP__
|
||||
|
||||
|
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_UTIL_HPP__
|
||||
#define __OPENCV_STITCHING_UTIL_HPP__
|
||||
|
||||
@@ -47,6 +48,7 @@
|
||||
|
||||
#define ENABLE_LOG 1
|
||||
|
||||
// TODO remove LOG macros, add logging class
|
||||
#if ENABLE_LOG
|
||||
#include <iostream>
|
||||
#define LOG(msg) { std::cout << msg; std::cout.flush(); }
|
||||
|
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_UTIL_INL_HPP__
|
||||
#define __OPENCV_STITCHING_UTIL_INL_HPP__
|
||||
|
||||
|
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_WARPERS_HPP__
|
||||
#define __OPENCV_STITCHING_WARPERS_HPP__
|
||||
|
||||
@@ -55,11 +56,13 @@ class CV_EXPORTS Warper
|
||||
{
|
||||
public:
|
||||
enum { PLANE, CYLINDRICAL, SPHERICAL };
|
||||
|
||||
// TODO remove this method
|
||||
static Ptr<Warper> createByCameraFocal(float focal, int type, bool try_gpu = false);
|
||||
|
||||
virtual ~Warper() {}
|
||||
virtual Point warp(const Mat &src, float focal, const Mat& R, Mat &dst,
|
||||
int interp_mode = INTER_LINEAR, int border_mode = BORDER_REFLECT) = 0;
|
||||
int interp_mode = INTER_LINEAR, int border_mode = BORDER_REFLECT) = 0;
|
||||
virtual Rect warpRoi(const Size &sz, float focal, const Mat &R) = 0;
|
||||
};
|
||||
|
||||
@@ -81,7 +84,7 @@ class CV_EXPORTS WarperBase : public Warper
|
||||
{
|
||||
public:
|
||||
virtual Point warp(const Mat &src, float focal, const Mat &R, Mat &dst,
|
||||
int interp_mode, int border_mode);
|
||||
int interp_mode, int border_mode);
|
||||
|
||||
virtual Rect warpRoi(const Size &sz, float focal, const Mat &R);
|
||||
|
||||
@@ -126,7 +129,7 @@ class CV_EXPORTS PlaneWarperGpu : public PlaneWarper
|
||||
public:
|
||||
PlaneWarperGpu(float plane_dist = 1.f, float scale = 1.f) : PlaneWarper(plane_dist, scale) {}
|
||||
Point warp(const Mat &src, float focal, const Mat &R, Mat &dst,
|
||||
int interp_mode, int border_mode);
|
||||
int interp_mode, int border_mode);
|
||||
|
||||
private:
|
||||
gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
|
||||
|
@@ -39,6 +39,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_WARPERS_INL_HPP__
|
||||
#define __OPENCV_STITCHING_WARPERS_INL_HPP__
|
||||
|
||||
@@ -50,7 +51,7 @@ namespace detail {
|
||||
|
||||
template <class P>
|
||||
Point WarperBase<P>::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();
|
||||
|
||||
|
128
modules/stitching/include/opencv2/stitching/stitcher.hpp
Normal file
128
modules/stitching/include/opencv2/stitching/stitcher.hpp
Normal file
@@ -0,0 +1,128 @@
|
||||
/*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*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_STITCHER_HPP__
|
||||
#define __OPENCV_STITCHING_STITCHER_HPP__
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "warpers.hpp"
|
||||
#include "detail/matchers.hpp"
|
||||
#include "detail/exposure_compensate.hpp"
|
||||
#include "detail/seam_finders.hpp"
|
||||
#include "detail/blenders.hpp"
|
||||
|
||||
namespace cv {
|
||||
|
||||
class Stitcher
|
||||
{
|
||||
public:
|
||||
enum { ORIG_RESOL = -1 };
|
||||
enum Status { OK, ERR_NEED_MORE_IMGS };
|
||||
|
||||
// Creates stitcher with default parameters
|
||||
static Stitcher createDefault(bool try_use_gpu = false);
|
||||
|
||||
// Stitches the biggest found pano. Returns status code.
|
||||
Status stitch(InputArray imgs, OutputArray pano);
|
||||
|
||||
double registrationResol() const { return registr_resol_; }
|
||||
void setRegistrationResol(double resol_mpx) { registr_resol_ = resol_mpx; }
|
||||
|
||||
double seamEstimationResol() const { return seam_est_resol_; }
|
||||
void setSeamEstimationResol(double resol_mpx) { seam_est_resol_ = resol_mpx; }
|
||||
|
||||
double compositingResol() const { return compose_resol_; }
|
||||
void setCompositingResol(double resol_mpx) { compose_resol_ = resol_mpx; }
|
||||
|
||||
double panoConfidenceThresh() const { return conf_thresh_; }
|
||||
void setPanoConfidenceThresh(double conf_thresh) { conf_thresh_ = conf_thresh; }
|
||||
|
||||
bool horizontalStrightening() const { return horiz_stright_; }
|
||||
void setHorizontalStrightening(bool flag) { horiz_stright_ = flag; }
|
||||
|
||||
Ptr<detail::FeaturesFinder> featuresFinder() { return features_finder_; }
|
||||
const Ptr<detail::FeaturesFinder> featuresFinder() const { return features_finder_; }
|
||||
void setFeaturesFinder(Ptr<detail::FeaturesFinder> features_finder)
|
||||
{ features_finder_ = features_finder; }
|
||||
|
||||
Ptr<detail::FeaturesMatcher> featuresMatcher() { return features_matcher_; }
|
||||
const Ptr<detail::FeaturesMatcher> featuresMatcher() const { return features_matcher_; }
|
||||
void setFeaturesMatcher(Ptr<detail::FeaturesMatcher> features_matcher)
|
||||
{ features_matcher_ = features_matcher; }
|
||||
|
||||
Ptr<WarperCreator> warper() { return warper_; }
|
||||
const Ptr<WarperCreator> warper() const { return warper_; }
|
||||
void setWarper(Ptr<WarperCreator> warper) { warper_ = warper; }
|
||||
|
||||
Ptr<detail::ExposureCompensator> exposureCompensator() { return exposure_comp_; }
|
||||
const Ptr<detail::ExposureCompensator> exposureCompensator() const { return exposure_comp_; }
|
||||
void setExposureCompenstor(Ptr<detail::ExposureCompensator> exposure_comp)
|
||||
{ exposure_comp_ = exposure_comp; }
|
||||
|
||||
Ptr<detail::SeamFinder> seamFinder() { return seam_finder_; }
|
||||
const Ptr<detail::SeamFinder> seamFinder() const { return seam_finder_; }
|
||||
void setSeamFinder(Ptr<detail::SeamFinder> seam_finder) { seam_finder_ = seam_finder; }
|
||||
|
||||
Ptr<detail::Blender> blender() { return blender_; }
|
||||
const Ptr<detail::Blender> blender() const { return blender_; }
|
||||
void setBlender(Ptr<detail::Blender> blender) { blender_ = blender; }
|
||||
|
||||
private:
|
||||
Stitcher() {}
|
||||
|
||||
double registr_resol_;
|
||||
double seam_est_resol_;
|
||||
double compose_resol_;
|
||||
double conf_thresh_;
|
||||
bool horiz_stright_;
|
||||
Ptr<detail::FeaturesFinder> features_finder_;
|
||||
Ptr<detail::FeaturesMatcher> features_matcher_;
|
||||
Ptr<WarperCreator> warper_;
|
||||
Ptr<detail::ExposureCompensator> exposure_comp_;
|
||||
Ptr<detail::SeamFinder> seam_finder_;
|
||||
Ptr<detail::Blender> blender_;
|
||||
};
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // __OPENCV_STITCHING_STITCHER_HPP__
|
105
modules/stitching/include/opencv2/stitching/warpers.hpp
Normal file
105
modules/stitching/include/opencv2/stitching/warpers.hpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/*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*/
|
||||
|
||||
#ifndef __OPENCV_STITCHING_WARPER_CREATORS_HPP__
|
||||
#define __OPENCV_STITCHING_WARPER_CREATORS_HPP__
|
||||
|
||||
#include "detail/warpers.hpp"
|
||||
|
||||
namespace cv {
|
||||
|
||||
class WarperCreator
|
||||
{
|
||||
public:
|
||||
virtual ~WarperCreator() {}
|
||||
virtual Ptr<detail::Warper> createByFocalLength(double f) const = 0;
|
||||
};
|
||||
|
||||
|
||||
class PlaneWarper : public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::Warper> createByFocalLength(double f) const { return new detail::PlaneWarper(f); }
|
||||
};
|
||||
|
||||
|
||||
class CylindricalWarper: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::Warper> createByFocalLength(double f) const { return new detail::CylindricalWarper(f); }
|
||||
};
|
||||
|
||||
|
||||
class SphericalWarper: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::Warper> createByFocalLength(double f) const { return new detail::SphericalWarper(f); }
|
||||
};
|
||||
|
||||
|
||||
#ifndef ANDROID
|
||||
|
||||
class PlaneWarperGpu: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::Warper> createByFocalLength(double f) const { return new detail::PlaneWarperGpu(f); }
|
||||
};
|
||||
|
||||
|
||||
class CylindricalWarperGpu: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::Warper> createByFocalLength(double f) const { return new detail::CylindricalWarperGpu(f); }
|
||||
};
|
||||
|
||||
|
||||
class SphericalWarperGpu: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::Warper> createByFocalLength(double f) const { return new detail::SphericalWarperGpu(f); }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // __OPENCV_STITCHING_WARPER_CREATORS_HPP__
|
Reference in New Issue
Block a user