version:2.1.5
bugfixes: update:拨号使用ocr进行识别
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
#include "matchers.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_autocalib
|
||||
//! @{
|
||||
@@ -64,9 +64,7 @@ undergoes rotations around its centre only.
|
||||
See "Construction of Panoramic Image Mosaics with Global and Local Alignment"
|
||||
by Heung-Yeung Shum and Richard Szeliski.
|
||||
*/
|
||||
void CV_EXPORTS_W
|
||||
|
||||
focalsFromHomography(const Mat &H, double &f0, double &f1, bool &f0_ok, bool &f1_ok);
|
||||
void CV_EXPORTS_W focalsFromHomography(const Mat &H, double &f0, double &f1, bool &f0_ok, bool &f1_ok);
|
||||
|
||||
/** @brief Estimates focal lengths for each given camera.
|
||||
|
||||
@@ -74,21 +72,15 @@ by Heung-Yeung Shum and Richard Szeliski.
|
||||
@param pairwise_matches Matches between all image pairs.
|
||||
@param focals Estimated focal lengths for each camera.
|
||||
*/
|
||||
void CV_EXPORTS
|
||||
void CV_EXPORTS estimateFocal(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
std::vector<double> &focals);
|
||||
|
||||
estimateFocal(const std::vector <ImageFeatures> &features,
|
||||
const std::vector <MatchesInfo> &pairwise_matches,
|
||||
std::vector<double> &focals);
|
||||
|
||||
bool CV_EXPORTS_W
|
||||
|
||||
calibrateRotatingCamera(const std::vector <Mat> &Hs, CV_OUT Mat &
|
||||
|
||||
K);
|
||||
bool CV_EXPORTS_W calibrateRotatingCamera(const std::vector<Mat> &Hs,CV_OUT Mat &K);
|
||||
|
||||
//! @} stitching_autocalib
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_STITCHING_AUTOCALIB_HPP
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include "opencv2/core/cuda.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_blend
|
||||
//! @{
|
||||
@@ -60,141 +60,125 @@ namespace cv {
|
||||
|
||||
Simple blender which puts one image over another
|
||||
*/
|
||||
class CV_EXPORTS_W Blender {
|
||||
public:
|
||||
virtual ~Blender() {}
|
||||
class CV_EXPORTS_W Blender
|
||||
{
|
||||
public:
|
||||
virtual ~Blender() {}
|
||||
|
||||
enum {
|
||||
NO, FEATHER, MULTI_BAND
|
||||
};
|
||||
CV_WRAP static Ptr <Blender> createDefault(int type, bool try_gpu = false);
|
||||
enum { NO, FEATHER, MULTI_BAND };
|
||||
CV_WRAP static Ptr<Blender> createDefault(int type, bool try_gpu = false);
|
||||
|
||||
/** @brief Prepares the blender for blending.
|
||||
/** @brief Prepares the blender for blending.
|
||||
|
||||
@param corners Source images top-left corners
|
||||
@param sizes Source image sizes
|
||||
*/
|
||||
CV_WRAP virtual void
|
||||
prepare(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
/** @overload */
|
||||
CV_WRAP virtual void prepare(Rect dst_roi);
|
||||
/** @brief Processes the image.
|
||||
@param corners Source images top-left corners
|
||||
@param sizes Source image sizes
|
||||
*/
|
||||
CV_WRAP virtual void prepare(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
/** @overload */
|
||||
CV_WRAP virtual void prepare(Rect dst_roi);
|
||||
/** @brief Processes the image.
|
||||
|
||||
@param img Source image
|
||||
@param mask Source image mask
|
||||
@param tl Source image top-left corners
|
||||
*/
|
||||
CV_WRAP virtual void feed(InputArray img, InputArray mask, Point tl);
|
||||
/** @brief Blends and returns the final pano.
|
||||
@param img Source image
|
||||
@param mask Source image mask
|
||||
@param tl Source image top-left corners
|
||||
*/
|
||||
CV_WRAP virtual void feed(InputArray img, InputArray mask, Point tl);
|
||||
/** @brief Blends and returns the final pano.
|
||||
|
||||
@param dst Final pano
|
||||
@param dst_mask Final pano mask
|
||||
*/
|
||||
CV_WRAP virtual void
|
||||
blend(CV_IN_OUT InputOutputArray dst, CV_IN_OUT InputOutputArray dst_mask);
|
||||
@param dst Final pano
|
||||
@param dst_mask Final pano mask
|
||||
*/
|
||||
CV_WRAP virtual void blend(CV_IN_OUT InputOutputArray dst,CV_IN_OUT InputOutputArray dst_mask);
|
||||
|
||||
protected:
|
||||
UMat dst_, dst_mask_;
|
||||
Rect dst_roi_;
|
||||
};
|
||||
protected:
|
||||
UMat dst_, dst_mask_;
|
||||
Rect dst_roi_;
|
||||
};
|
||||
|
||||
/** @brief Simple blender which mixes images at its borders.
|
||||
*/
|
||||
class CV_EXPORTS_W FeatherBlender : public Blender {
|
||||
public:
|
||||
CV_WRAP FeatherBlender(float sharpness = 0.02f);
|
||||
class CV_EXPORTS_W FeatherBlender : public Blender
|
||||
{
|
||||
public:
|
||||
CV_WRAP FeatherBlender(float sharpness = 0.02f);
|
||||
|
||||
CV_WRAP float sharpness() const { return sharpness_; }
|
||||
CV_WRAP float sharpness() const { return sharpness_; }
|
||||
CV_WRAP void setSharpness(float val) { sharpness_ = val; }
|
||||
|
||||
CV_WRAP void setSharpness(float val) { sharpness_ = val; }
|
||||
CV_WRAP void prepare(Rect dst_roi) CV_OVERRIDE;
|
||||
CV_WRAP void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE;
|
||||
CV_WRAP void blend(InputOutputArray dst, InputOutputArray dst_mask) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void prepare(Rect dst_roi) CV_OVERRIDE;
|
||||
//! Creates weight maps for fixed set of source images by their masks and top-left corners.
|
||||
//! Final image can be obtained by simple weighting of the source images.
|
||||
CV_WRAP Rect createWeightMaps(const std::vector<UMat> &masks, const std::vector<Point> &corners,
|
||||
CV_IN_OUT std::vector<UMat> &weight_maps);
|
||||
|
||||
CV_WRAP void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE;
|
||||
private:
|
||||
float sharpness_;
|
||||
UMat weight_map_;
|
||||
UMat dst_weight_map_;
|
||||
};
|
||||
|
||||
CV_WRAP void blend(InputOutputArray dst, InputOutputArray dst_mask) CV_OVERRIDE;
|
||||
|
||||
//! Creates weight maps for fixed set of source images by their masks and top-left corners.
|
||||
//! Final image can be obtained by simple weighting of the source images.
|
||||
CV_WRAP Rect
|
||||
createWeightMaps(const std::vector<UMat> &masks, const std::vector<Point> &corners,
|
||||
CV_IN_OUT std::vector<UMat> &weight_maps);
|
||||
|
||||
private:
|
||||
float sharpness_;
|
||||
UMat weight_map_;
|
||||
UMat dst_weight_map_;
|
||||
};
|
||||
|
||||
inline FeatherBlender::FeatherBlender(float _sharpness) { setSharpness(_sharpness); }
|
||||
inline FeatherBlender::FeatherBlender(float _sharpness) { setSharpness(_sharpness); }
|
||||
|
||||
/** @brief Blender which uses multi-band blending algorithm (see @cite BA83).
|
||||
*/
|
||||
class CV_EXPORTS_W MultiBandBlender : public Blender {
|
||||
public:
|
||||
CV_WRAP MultiBandBlender(int try_gpu = false, int num_bands = 5,
|
||||
int weight_type = CV_32F);
|
||||
class CV_EXPORTS_W MultiBandBlender : public Blender
|
||||
{
|
||||
public:
|
||||
CV_WRAP MultiBandBlender(int try_gpu = false, int num_bands = 5, int weight_type = CV_32F);
|
||||
|
||||
CV_WRAP int numBands() const { return actual_num_bands_; }
|
||||
CV_WRAP int numBands() const { return actual_num_bands_; }
|
||||
CV_WRAP void setNumBands(int val) { actual_num_bands_ = val; }
|
||||
|
||||
CV_WRAP void setNumBands(int val) { actual_num_bands_ = val; }
|
||||
CV_WRAP void prepare(Rect dst_roi) CV_OVERRIDE;
|
||||
CV_WRAP void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE;
|
||||
CV_WRAP void blend(CV_IN_OUT InputOutputArray dst, CV_IN_OUT InputOutputArray dst_mask) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void prepare(Rect dst_roi) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void
|
||||
blend(CV_IN_OUT InputOutputArray dst, CV_IN_OUT InputOutputArray dst_mask) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
int actual_num_bands_, num_bands_;
|
||||
std::vector<UMat> dst_pyr_laplace_;
|
||||
std::vector<UMat> dst_band_weights_;
|
||||
Rect dst_roi_final_;
|
||||
bool can_use_gpu_;
|
||||
int weight_type_; //CV_32F or CV_16S
|
||||
private:
|
||||
int actual_num_bands_, num_bands_;
|
||||
std::vector<UMat> dst_pyr_laplace_;
|
||||
std::vector<UMat> dst_band_weights_;
|
||||
Rect dst_roi_final_;
|
||||
bool can_use_gpu_;
|
||||
int weight_type_; //CV_32F or CV_16S
|
||||
#if defined(HAVE_OPENCV_CUDAARITHM) && defined(HAVE_OPENCV_CUDAWARPING)
|
||||
std::vector<cuda::GpuMat> gpu_dst_pyr_laplace_;
|
||||
std::vector<cuda::GpuMat> gpu_dst_band_weights_;
|
||||
std::vector<Point> gpu_tl_points_;
|
||||
std::vector<cuda::GpuMat> gpu_imgs_with_border_;
|
||||
std::vector<std::vector<cuda::GpuMat> > gpu_weight_pyr_gauss_vec_;
|
||||
std::vector<std::vector<cuda::GpuMat> > gpu_src_pyr_laplace_vec_;
|
||||
std::vector<std::vector<cuda::GpuMat> > gpu_ups_;
|
||||
cuda::GpuMat gpu_dst_mask_;
|
||||
cuda::GpuMat gpu_mask_;
|
||||
cuda::GpuMat gpu_img_;
|
||||
cuda::GpuMat gpu_weight_map_;
|
||||
cuda::GpuMat gpu_add_mask_;
|
||||
int gpu_feed_idx_;
|
||||
bool gpu_initialized_;
|
||||
std::vector<cuda::GpuMat> gpu_dst_pyr_laplace_;
|
||||
std::vector<cuda::GpuMat> gpu_dst_band_weights_;
|
||||
std::vector<Point> gpu_tl_points_;
|
||||
std::vector<cuda::GpuMat> gpu_imgs_with_border_;
|
||||
std::vector<std::vector<cuda::GpuMat> > gpu_weight_pyr_gauss_vec_;
|
||||
std::vector<std::vector<cuda::GpuMat> > gpu_src_pyr_laplace_vec_;
|
||||
std::vector<std::vector<cuda::GpuMat> > gpu_ups_;
|
||||
cuda::GpuMat gpu_dst_mask_;
|
||||
cuda::GpuMat gpu_mask_;
|
||||
cuda::GpuMat gpu_img_;
|
||||
cuda::GpuMat gpu_weight_map_;
|
||||
cuda::GpuMat gpu_add_mask_;
|
||||
int gpu_feed_idx_;
|
||||
bool gpu_initialized_;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Auxiliary functions
|
||||
|
||||
void CV_EXPORTS_W
|
||||
normalizeUsingWeightMap(InputArray weight, CV_IN_OUT InputOutputArray src);
|
||||
void CV_EXPORTS_W normalizeUsingWeightMap(InputArray weight, CV_IN_OUT InputOutputArray src);
|
||||
|
||||
void CV_EXPORTS_W
|
||||
createWeightMap(InputArray mask, float sharpness, CV_IN_OUT InputOutputArray weight);
|
||||
void CV_EXPORTS_W createWeightMap(InputArray mask, float sharpness, CV_IN_OUT InputOutputArray weight);
|
||||
|
||||
void CV_EXPORTS_W
|
||||
createLaplacePyr(InputArray img, int num_levels, CV_IN_OUT std::vector<UMat> &pyr);
|
||||
|
||||
void CV_EXPORTS_W
|
||||
createLaplacePyrGpu(InputArray img, int num_levels, CV_IN_OUT std::vector<UMat> &pyr);
|
||||
void CV_EXPORTS_W createLaplacePyr(InputArray img, int num_levels, CV_IN_OUT std::vector<UMat>& pyr);
|
||||
void CV_EXPORTS_W createLaplacePyrGpu(InputArray img, int num_levels, CV_IN_OUT std::vector<UMat>& pyr);
|
||||
|
||||
// Restores source image
|
||||
void CV_EXPORTS_W restoreImageFromLaplacePyr(CV_IN_OUT std::vector<UMat> &pyr);
|
||||
|
||||
void CV_EXPORTS_W restoreImageFromLaplacePyrGpu(CV_IN_OUT std::vector<UMat> &pyr);
|
||||
void CV_EXPORTS_W restoreImageFromLaplacePyr(CV_IN_OUT std::vector<UMat>& pyr);
|
||||
void CV_EXPORTS_W restoreImageFromLaplacePyrGpu(CV_IN_OUT std::vector<UMat>& pyr);
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_STITCHING_BLENDERS_HPP
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching
|
||||
//! @{
|
||||
@@ -55,26 +55,24 @@ namespace cv {
|
||||
|
||||
@note Translation is assumed to be zero during the whole stitching pipeline. :
|
||||
*/
|
||||
struct CV_EXPORTS_W_SIMPLE CameraParams {
|
||||
CameraParams();
|
||||
struct CV_EXPORTS_W_SIMPLE CameraParams
|
||||
{
|
||||
CameraParams();
|
||||
CameraParams(const CameraParams& other);
|
||||
CameraParams& operator =(const CameraParams& other);
|
||||
CV_WRAP Mat K() const;
|
||||
|
||||
CameraParams(const CameraParams &other);
|
||||
|
||||
CameraParams &operator=(const CameraParams &other);
|
||||
|
||||
CV_WRAP Mat K() const;
|
||||
|
||||
CV_PROP_RW double focal; // Focal length
|
||||
CV_PROP_RW double aspect; // Aspect ratio
|
||||
CV_PROP_RW double ppx; // Principal point X
|
||||
CV_PROP_RW double ppy; // Principal point Y
|
||||
CV_PROP_RW Mat R; // Rotation
|
||||
CV_PROP_RW Mat t; // Translation
|
||||
};
|
||||
CV_PROP_RW double focal; // Focal length
|
||||
CV_PROP_RW double aspect; // Aspect ratio
|
||||
CV_PROP_RW double ppx; // Principal point X
|
||||
CV_PROP_RW double ppy; // Principal point Y
|
||||
CV_PROP_RW Mat R; // Rotation
|
||||
CV_PROP_RW Mat t; // Translation
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
#endif // #ifndef OPENCV_STITCHING_CAMERA_HPP
|
||||
|
||||
@@ -50,236 +50,181 @@
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_exposure
|
||||
//! @{
|
||||
|
||||
/** @brief Base class for all exposure compensators.
|
||||
*/
|
||||
class CV_EXPORTS_W ExposureCompensator {
|
||||
public:
|
||||
ExposureCompensator() : updateGain(true) {}
|
||||
class CV_EXPORTS_W ExposureCompensator
|
||||
{
|
||||
public:
|
||||
ExposureCompensator(): updateGain(true) {}
|
||||
virtual ~ExposureCompensator() {}
|
||||
|
||||
virtual ~ExposureCompensator() {}
|
||||
enum { NO, GAIN, GAIN_BLOCKS, CHANNELS, CHANNELS_BLOCKS };
|
||||
CV_WRAP static Ptr<ExposureCompensator> createDefault(int type);
|
||||
|
||||
enum {
|
||||
NO, GAIN, GAIN_BLOCKS, CHANNELS, CHANNELS_BLOCKS
|
||||
};
|
||||
CV_WRAP static Ptr <ExposureCompensator> createDefault(int type);
|
||||
/**
|
||||
@param corners Source image top-left corners
|
||||
@param images Source images
|
||||
@param masks Image masks to update (second value in pair specifies the value which should be used
|
||||
to detect where image is)
|
||||
*/
|
||||
CV_WRAP void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<UMat> &masks);
|
||||
/** @overload */
|
||||
virtual void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat, uchar> > &masks) = 0;
|
||||
/** @brief Compensate exposure in the specified image.
|
||||
|
||||
/**
|
||||
@param corners Source image top-left corners
|
||||
@param images Source images
|
||||
@param masks Image masks to update (second value in pair specifies the value which should be used
|
||||
to detect where image is)
|
||||
*/
|
||||
CV_WRAP void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<UMat> &masks);
|
||||
|
||||
/** @overload */
|
||||
virtual void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat, uchar> > &masks) = 0;
|
||||
/** @brief Compensate exposure in the specified image.
|
||||
|
||||
@param index Image index
|
||||
@param corner Image top-left corner
|
||||
@param image Image to process
|
||||
@param mask Image mask
|
||||
*/
|
||||
CV_WRAP virtual void
|
||||
apply(int index, Point corner, InputOutputArray image, InputArray mask) = 0;
|
||||
|
||||
CV_WRAP virtual void getMatGains(CV_OUT std::vector<Mat> &) {
|
||||
CV_Error(Error::StsInternal, "");
|
||||
};
|
||||
CV_WRAP virtual void setMatGains(std::vector<Mat> &) {
|
||||
CV_Error(Error::StsInternal, "");
|
||||
};
|
||||
CV_WRAP void setUpdateGain(bool b) { updateGain = b; };
|
||||
CV_WRAP bool getUpdateGain() { return updateGain; };
|
||||
protected :
|
||||
bool updateGain;
|
||||
};
|
||||
@param index Image index
|
||||
@param corner Image top-left corner
|
||||
@param image Image to process
|
||||
@param mask Image mask
|
||||
*/
|
||||
CV_WRAP virtual void apply(int index, Point corner, InputOutputArray image, InputArray mask) = 0;
|
||||
CV_WRAP virtual void getMatGains(CV_OUT std::vector<Mat>& ) {CV_Error(Error::StsInternal, "");};
|
||||
CV_WRAP virtual void setMatGains(std::vector<Mat>& ) { CV_Error(Error::StsInternal, ""); };
|
||||
CV_WRAP void setUpdateGain(bool b) { updateGain = b; };
|
||||
CV_WRAP bool getUpdateGain() { return updateGain; };
|
||||
protected :
|
||||
bool updateGain;
|
||||
};
|
||||
|
||||
/** @brief Stub exposure compensator which does nothing.
|
||||
*/
|
||||
class CV_EXPORTS_W NoExposureCompensator : public ExposureCompensator {
|
||||
public:
|
||||
void feed(const std::vector<Point> &/*corners*/, const std::vector<UMat> &/*images*/,
|
||||
const std::vector<std::pair<UMat, uchar> > &/*masks*/) CV_OVERRIDE {}
|
||||
|
||||
CV_WRAP void apply(int /*index*/, Point /*corner*/, InputOutputArray /*image*/,
|
||||
InputArray /*mask*/) CV_OVERRIDE {}
|
||||
|
||||
CV_WRAP void getMatGains(CV_OUT std::vector<Mat> &umv) CV_OVERRIDE {
|
||||
umv.clear();
|
||||
return;
|
||||
};
|
||||
CV_WRAP void setMatGains(std::vector<Mat> &umv) CV_OVERRIDE {
|
||||
umv.clear();
|
||||
return;
|
||||
};
|
||||
};
|
||||
class CV_EXPORTS_W NoExposureCompensator : public ExposureCompensator
|
||||
{
|
||||
public:
|
||||
void feed(const std::vector<Point> &/*corners*/, const std::vector<UMat> &/*images*/,
|
||||
const std::vector<std::pair<UMat,uchar> > &/*masks*/) CV_OVERRIDE { }
|
||||
CV_WRAP void apply(int /*index*/, Point /*corner*/, InputOutputArray /*image*/, InputArray /*mask*/) CV_OVERRIDE { }
|
||||
CV_WRAP void getMatGains(CV_OUT std::vector<Mat>& umv) CV_OVERRIDE { umv.clear(); return; };
|
||||
CV_WRAP void setMatGains(std::vector<Mat>& umv) CV_OVERRIDE { umv.clear(); return; };
|
||||
};
|
||||
|
||||
/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image
|
||||
intensities, see @cite BL07 and @cite WJ10 for details.
|
||||
*/
|
||||
class CV_EXPORTS_W GainCompensator : public ExposureCompensator {
|
||||
public:
|
||||
// This Constructor only exists to make source level compatibility detector happy
|
||||
CV_WRAP GainCompensator()
|
||||
: GainCompensator(1) {}
|
||||
class CV_EXPORTS_W GainCompensator : public ExposureCompensator
|
||||
{
|
||||
public:
|
||||
// This Constructor only exists to make source level compatibility detector happy
|
||||
CV_WRAP GainCompensator()
|
||||
: GainCompensator(1) {}
|
||||
CV_WRAP GainCompensator(int nr_feeds)
|
||||
: nr_feeds_(nr_feeds) {}
|
||||
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat,uchar> > &masks) CV_OVERRIDE;
|
||||
void singleFeed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat,uchar> > &masks);
|
||||
CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE;
|
||||
CV_WRAP void getMatGains(CV_OUT std::vector<Mat>& umv) CV_OVERRIDE ;
|
||||
CV_WRAP void setMatGains(std::vector<Mat>& umv) CV_OVERRIDE ;
|
||||
CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; }
|
||||
CV_WRAP int getNrFeeds() { return nr_feeds_; }
|
||||
std::vector<double> gains() const;
|
||||
|
||||
CV_WRAP GainCompensator(int nr_feeds)
|
||||
: nr_feeds_(nr_feeds) {}
|
||||
|
||||
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat, uchar> > &masks) CV_OVERRIDE;
|
||||
|
||||
void singleFeed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat, uchar> > &masks);
|
||||
|
||||
CV_WRAP void
|
||||
apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void getMatGains(CV_OUT std::vector<Mat> &umv) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void setMatGains(std::vector<Mat> &umv) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; }
|
||||
|
||||
CV_WRAP int getNrFeeds() { return nr_feeds_; }
|
||||
|
||||
std::vector<double> gains() const;
|
||||
|
||||
private:
|
||||
Mat_<double> gains_;
|
||||
int nr_feeds_;
|
||||
};
|
||||
private:
|
||||
Mat_<double> gains_;
|
||||
int nr_feeds_;
|
||||
};
|
||||
|
||||
/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image
|
||||
intensities on each channel independently.
|
||||
*/
|
||||
class CV_EXPORTS_W ChannelsCompensator : public ExposureCompensator {
|
||||
public:
|
||||
CV_WRAP ChannelsCompensator(int nr_feeds = 1) : nr_feeds_(nr_feeds) {}
|
||||
class CV_EXPORTS_W ChannelsCompensator : public ExposureCompensator
|
||||
{
|
||||
public:
|
||||
CV_WRAP ChannelsCompensator(int nr_feeds=1) : nr_feeds_(nr_feeds) {}
|
||||
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat,uchar> > &masks) CV_OVERRIDE;
|
||||
CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE;
|
||||
CV_WRAP void getMatGains(CV_OUT std::vector<Mat>& umv) CV_OVERRIDE;
|
||||
CV_WRAP void setMatGains(std::vector<Mat>& umv) CV_OVERRIDE;
|
||||
CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; }
|
||||
CV_WRAP int getNrFeeds() { return nr_feeds_; }
|
||||
std::vector<Scalar> gains() const { return gains_; }
|
||||
|
||||
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat, uchar> > &masks) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void
|
||||
apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void getMatGains(CV_OUT std::vector<Mat> &umv) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void setMatGains(std::vector<Mat> &umv) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; }
|
||||
|
||||
CV_WRAP int getNrFeeds() { return nr_feeds_; }
|
||||
|
||||
std::vector<Scalar> gains() const { return gains_; }
|
||||
|
||||
private:
|
||||
std::vector<Scalar> gains_;
|
||||
int nr_feeds_;
|
||||
};
|
||||
private:
|
||||
std::vector<Scalar> gains_;
|
||||
int nr_feeds_;
|
||||
};
|
||||
|
||||
/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image blocks.
|
||||
*/
|
||||
class CV_EXPORTS_W BlocksCompensator : public ExposureCompensator {
|
||||
public:
|
||||
BlocksCompensator(int bl_width = 32, int bl_height = 32, int nr_feeds = 1)
|
||||
: bl_width_(bl_width), bl_height_(bl_height), nr_feeds_(nr_feeds),
|
||||
nr_gain_filtering_iterations_(2) {}
|
||||
class CV_EXPORTS_W BlocksCompensator : public ExposureCompensator
|
||||
{
|
||||
public:
|
||||
BlocksCompensator(int bl_width=32, int bl_height=32, int nr_feeds=1)
|
||||
: bl_width_(bl_width), bl_height_(bl_height), nr_feeds_(nr_feeds), nr_gain_filtering_iterations_(2) {}
|
||||
CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE;
|
||||
CV_WRAP void getMatGains(CV_OUT std::vector<Mat>& umv) CV_OVERRIDE;
|
||||
CV_WRAP void setMatGains(std::vector<Mat>& umv) CV_OVERRIDE;
|
||||
CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; }
|
||||
CV_WRAP int getNrFeeds() { return nr_feeds_; }
|
||||
CV_WRAP void setBlockSize(int width, int height) { bl_width_ = width; bl_height_ = height; }
|
||||
CV_WRAP void setBlockSize(Size size) { setBlockSize(size.width, size.height); }
|
||||
CV_WRAP Size getBlockSize() const { return Size(bl_width_, bl_height_); }
|
||||
CV_WRAP void setNrGainsFilteringIterations(int nr_iterations) { nr_gain_filtering_iterations_ = nr_iterations; }
|
||||
CV_WRAP int getNrGainsFilteringIterations() const { return nr_gain_filtering_iterations_; }
|
||||
|
||||
CV_WRAP void
|
||||
apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE;
|
||||
protected:
|
||||
template<class Compensator>
|
||||
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat,uchar> > &masks);
|
||||
|
||||
CV_WRAP void getMatGains(CV_OUT std::vector<Mat> &umv) CV_OVERRIDE;
|
||||
private:
|
||||
UMat getGainMap(const GainCompensator& compensator, int bl_idx, Size bl_per_img);
|
||||
UMat getGainMap(const ChannelsCompensator& compensator, int bl_idx, Size bl_per_img);
|
||||
|
||||
CV_WRAP void setMatGains(std::vector<Mat> &umv) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void setNrFeeds(int nr_feeds) { nr_feeds_ = nr_feeds; }
|
||||
|
||||
CV_WRAP int getNrFeeds() { return nr_feeds_; }
|
||||
|
||||
CV_WRAP void setBlockSize(int width, int height) {
|
||||
bl_width_ = width;
|
||||
bl_height_ = height;
|
||||
}
|
||||
|
||||
CV_WRAP void setBlockSize(Size size) { setBlockSize(size.width, size.height); }
|
||||
|
||||
CV_WRAP Size getBlockSize() const { return Size(bl_width_, bl_height_); }
|
||||
|
||||
CV_WRAP void setNrGainsFilteringIterations(
|
||||
int nr_iterations) { nr_gain_filtering_iterations_ = nr_iterations; }
|
||||
|
||||
CV_WRAP int
|
||||
getNrGainsFilteringIterations() const { return nr_gain_filtering_iterations_; }
|
||||
|
||||
protected:
|
||||
template<class Compensator>
|
||||
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat, uchar> > &masks);
|
||||
|
||||
private:
|
||||
UMat getGainMap(const GainCompensator &compensator, int bl_idx, Size bl_per_img);
|
||||
|
||||
UMat getGainMap(const ChannelsCompensator &compensator, int bl_idx, Size bl_per_img);
|
||||
|
||||
int bl_width_, bl_height_;
|
||||
std::vector<UMat> gain_maps_;
|
||||
int nr_feeds_;
|
||||
int nr_gain_filtering_iterations_;
|
||||
};
|
||||
int bl_width_, bl_height_;
|
||||
std::vector<UMat> gain_maps_;
|
||||
int nr_feeds_;
|
||||
int nr_gain_filtering_iterations_;
|
||||
};
|
||||
|
||||
/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image block
|
||||
intensities, see @cite UES01 for details.
|
||||
*/
|
||||
class CV_EXPORTS_W BlocksGainCompensator : public BlocksCompensator {
|
||||
public:
|
||||
// This Constructor only exists to make source level compatibility detector happy
|
||||
CV_WRAP BlocksGainCompensator(int bl_width = 32, int bl_height = 32)
|
||||
: BlocksGainCompensator(bl_width, bl_height, 1) {}
|
||||
class CV_EXPORTS_W BlocksGainCompensator : public BlocksCompensator
|
||||
{
|
||||
public:
|
||||
// This Constructor only exists to make source level compatibility detector happy
|
||||
CV_WRAP BlocksGainCompensator(int bl_width = 32, int bl_height = 32)
|
||||
: BlocksGainCompensator(bl_width, bl_height, 1) {}
|
||||
CV_WRAP BlocksGainCompensator(int bl_width, int bl_height, int nr_feeds)
|
||||
: BlocksCompensator(bl_width, bl_height, nr_feeds) {}
|
||||
|
||||
CV_WRAP BlocksGainCompensator(int bl_width, int bl_height, int nr_feeds)
|
||||
: BlocksCompensator(bl_width, bl_height, nr_feeds) {}
|
||||
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat,uchar> > &masks) CV_OVERRIDE;
|
||||
|
||||
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat, uchar> > &masks) CV_OVERRIDE;
|
||||
|
||||
// This function only exists to make source level compatibility detector happy
|
||||
CV_WRAP void
|
||||
apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE {
|
||||
BlocksCompensator::apply(index, corner, image, mask);
|
||||
}
|
||||
// This function only exists to make source level compatibility detector happy
|
||||
CV_WRAP void getMatGains(CV_OUT std::vector<Mat> &umv) CV_OVERRIDE {
|
||||
BlocksCompensator::getMatGains(umv);
|
||||
}
|
||||
// This function only exists to make source level compatibility detector happy
|
||||
CV_WRAP void
|
||||
setMatGains(std::vector<Mat> &umv) CV_OVERRIDE { BlocksCompensator::setMatGains(umv); }
|
||||
};
|
||||
// This function only exists to make source level compatibility detector happy
|
||||
CV_WRAP void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE {
|
||||
BlocksCompensator::apply(index, corner, image, mask); }
|
||||
// This function only exists to make source level compatibility detector happy
|
||||
CV_WRAP void getMatGains(CV_OUT std::vector<Mat>& umv) CV_OVERRIDE { BlocksCompensator::getMatGains(umv); }
|
||||
// This function only exists to make source level compatibility detector happy
|
||||
CV_WRAP void setMatGains(std::vector<Mat>& umv) CV_OVERRIDE { BlocksCompensator::setMatGains(umv); }
|
||||
};
|
||||
|
||||
/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image block
|
||||
on each channel.
|
||||
*/
|
||||
class CV_EXPORTS_W BlocksChannelsCompensator : public BlocksCompensator {
|
||||
public:
|
||||
CV_WRAP BlocksChannelsCompensator(int bl_width = 32, int bl_height = 32,
|
||||
int nr_feeds = 1)
|
||||
: BlocksCompensator(bl_width, bl_height, nr_feeds) {}
|
||||
class CV_EXPORTS_W BlocksChannelsCompensator : public BlocksCompensator
|
||||
{
|
||||
public:
|
||||
CV_WRAP BlocksChannelsCompensator(int bl_width=32, int bl_height=32, int nr_feeds=1)
|
||||
: BlocksCompensator(bl_width, bl_height, nr_feeds) {}
|
||||
|
||||
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat, uchar> > &masks) CV_OVERRIDE;
|
||||
};
|
||||
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
|
||||
const std::vector<std::pair<UMat,uchar> > &masks) CV_OVERRIDE;
|
||||
};
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP
|
||||
|
||||
@@ -49,19 +49,20 @@
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_match
|
||||
//! @{
|
||||
|
||||
/** @brief Structure containing image keypoints and descriptors. */
|
||||
struct CV_EXPORTS_W_SIMPLE ImageFeatures {
|
||||
CV_PROP_RW int img_idx;
|
||||
CV_PROP_RW Size img_size;
|
||||
std::vector<KeyPoint> keypoints;
|
||||
CV_PROP_RW UMat descriptors;
|
||||
CV_WRAP std::vector<KeyPoint> getKeypoints() { return keypoints; };
|
||||
};
|
||||
struct CV_EXPORTS_W_SIMPLE ImageFeatures
|
||||
{
|
||||
CV_PROP_RW int img_idx;
|
||||
CV_PROP_RW Size img_size;
|
||||
std::vector<KeyPoint> keypoints;
|
||||
CV_PROP_RW UMat descriptors;
|
||||
CV_WRAP std::vector<KeyPoint> getKeypoints() { return keypoints; };
|
||||
};
|
||||
/** @brief
|
||||
|
||||
@param featuresFinder
|
||||
@@ -69,11 +70,11 @@ namespace cv {
|
||||
@param features
|
||||
@param masks
|
||||
*/
|
||||
CV_EXPORTS_W void computeImageFeatures(
|
||||
const Ptr <Feature2D> &featuresFinder,
|
||||
InputArrayOfArrays images,
|
||||
CV_OUT std::vector<ImageFeatures> &features,
|
||||
InputArrayOfArrays masks = noArray());
|
||||
CV_EXPORTS_W void computeImageFeatures(
|
||||
const Ptr<Feature2D> &featuresFinder,
|
||||
InputArrayOfArrays images,
|
||||
CV_OUT std::vector<ImageFeatures> &features,
|
||||
InputArrayOfArrays masks = noArray());
|
||||
|
||||
/** @brief
|
||||
|
||||
@@ -82,13 +83,11 @@ namespace cv {
|
||||
@param features
|
||||
@param mask
|
||||
*/
|
||||
CV_EXPORTS_AS(computeImageFeatures2)
|
||||
|
||||
void computeImageFeatures(
|
||||
const Ptr <Feature2D> &featuresFinder,
|
||||
InputArray image,
|
||||
CV_OUT ImageFeatures &features,
|
||||
InputArray mask = noArray());
|
||||
CV_EXPORTS_AS(computeImageFeatures2) void computeImageFeatures(
|
||||
const Ptr<Feature2D> &featuresFinder,
|
||||
InputArray image,
|
||||
CV_OUT ImageFeatures &features,
|
||||
InputArray mask = noArray());
|
||||
|
||||
/** @brief Structure containing information about matches between two images.
|
||||
|
||||
@@ -97,132 +96,119 @@ homography or affine transformation based on selected matcher.
|
||||
|
||||
@sa detail::FeaturesMatcher
|
||||
*/
|
||||
struct CV_EXPORTS_W_SIMPLE MatchesInfo {
|
||||
MatchesInfo();
|
||||
struct CV_EXPORTS_W_SIMPLE MatchesInfo
|
||||
{
|
||||
MatchesInfo();
|
||||
MatchesInfo(const MatchesInfo &other);
|
||||
MatchesInfo& operator =(const MatchesInfo &other);
|
||||
|
||||
MatchesInfo(const MatchesInfo &other);
|
||||
|
||||
MatchesInfo &operator=(const MatchesInfo &other);
|
||||
|
||||
CV_PROP_RW int src_img_idx;
|
||||
CV_PROP_RW int dst_img_idx; //!< Images indices (optional)
|
||||
std::vector<DMatch> matches;
|
||||
std::vector<uchar> inliers_mask; //!< Geometrically consistent matches mask
|
||||
CV_PROP_RW int num_inliers; //!< Number of geometrically consistent matches
|
||||
CV_PROP_RW Mat H; //!< Estimated transformation
|
||||
CV_PROP_RW double confidence; //!< Confidence two images are from the same panorama
|
||||
CV_WRAP std::vector<DMatch> getMatches() { return matches; };
|
||||
CV_WRAP std::vector<uchar> getInliers() { return inliers_mask; };
|
||||
};
|
||||
CV_PROP_RW int src_img_idx;
|
||||
CV_PROP_RW int dst_img_idx; //!< Images indices (optional)
|
||||
std::vector<DMatch> matches;
|
||||
std::vector<uchar> inliers_mask; //!< Geometrically consistent matches mask
|
||||
CV_PROP_RW int num_inliers; //!< Number of geometrically consistent matches
|
||||
CV_PROP_RW Mat H; //!< Estimated transformation
|
||||
CV_PROP_RW double confidence; //!< Confidence two images are from the same panorama
|
||||
CV_WRAP std::vector<DMatch> getMatches() { return matches; };
|
||||
CV_WRAP std::vector<uchar> getInliers() { return inliers_mask; };
|
||||
};
|
||||
|
||||
/** @brief Feature matchers base class. */
|
||||
class CV_EXPORTS_W FeaturesMatcher {
|
||||
public:
|
||||
CV_WRAP virtual ~FeaturesMatcher() {}
|
||||
class CV_EXPORTS_W FeaturesMatcher
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual ~FeaturesMatcher() {}
|
||||
|
||||
/** @overload
|
||||
@param features1 First image features
|
||||
@param features2 Second image features
|
||||
@param matches_info Found matches
|
||||
*/
|
||||
CV_WRAP_AS(apply)
|
||||
/** @overload
|
||||
@param features1 First image features
|
||||
@param features2 Second image features
|
||||
@param matches_info Found matches
|
||||
*/
|
||||
CV_WRAP_AS(apply) void operator ()(const ImageFeatures &features1, const ImageFeatures &features2,
|
||||
CV_OUT MatchesInfo& matches_info) { match(features1, features2, matches_info); }
|
||||
|
||||
void operator()(const ImageFeatures &features1, const ImageFeatures &features2,
|
||||
CV_OUT MatchesInfo &matches_info) {
|
||||
match(features1, features2, matches_info);
|
||||
}
|
||||
/** @brief Performs images matching.
|
||||
|
||||
/** @brief Performs images matching.
|
||||
@param features Features of the source images
|
||||
@param pairwise_matches Found pairwise matches
|
||||
@param mask Mask indicating which image pairs must be matched
|
||||
|
||||
@param features Features of the source images
|
||||
@param pairwise_matches Found pairwise matches
|
||||
@param mask Mask indicating which image pairs must be matched
|
||||
The function is parallelized with the TBB library.
|
||||
|
||||
The function is parallelized with the TBB library.
|
||||
@sa detail::MatchesInfo
|
||||
*/
|
||||
CV_WRAP_AS(apply2) void operator ()(const std::vector<ImageFeatures> &features, CV_OUT std::vector<MatchesInfo> &pairwise_matches,
|
||||
const cv::UMat &mask = cv::UMat());
|
||||
|
||||
@sa detail::MatchesInfo
|
||||
*/
|
||||
CV_WRAP_AS(apply2)
|
||||
/** @return True, if it's possible to use the same matcher instance in parallel, false otherwise
|
||||
*/
|
||||
CV_WRAP bool isThreadSafe() const { return is_thread_safe_; }
|
||||
|
||||
void operator()(const std::vector<ImageFeatures> &features, CV_OUT
|
||||
std::vector<MatchesInfo> &pairwise_matches,
|
||||
const cv::UMat &mask = cv::UMat());
|
||||
/** @brief Frees unused memory allocated before if there is any.
|
||||
*/
|
||||
CV_WRAP virtual void collectGarbage() {}
|
||||
|
||||
/** @return True, if it's possible to use the same matcher instance in parallel, false otherwise
|
||||
*/
|
||||
CV_WRAP bool isThreadSafe() const { return is_thread_safe_; }
|
||||
protected:
|
||||
FeaturesMatcher(bool is_thread_safe = false) : is_thread_safe_(is_thread_safe) {}
|
||||
|
||||
/** @brief Frees unused memory allocated before if there is any.
|
||||
*/
|
||||
CV_WRAP virtual void collectGarbage() {}
|
||||
/** @brief This method must implement matching logic in order to make the wrappers
|
||||
detail::FeaturesMatcher::operator()_ work.
|
||||
|
||||
protected:
|
||||
FeaturesMatcher(bool is_thread_safe = false) : is_thread_safe_(is_thread_safe) {}
|
||||
@param features1 first image features
|
||||
@param features2 second image features
|
||||
@param matches_info found matches
|
||||
*/
|
||||
virtual void match(const ImageFeatures &features1, const ImageFeatures &features2,
|
||||
MatchesInfo& matches_info) = 0;
|
||||
|
||||
/** @brief This method must implement matching logic in order to make the wrappers
|
||||
detail::FeaturesMatcher::operator()_ work.
|
||||
|
||||
@param features1 first image features
|
||||
@param features2 second image features
|
||||
@param matches_info found matches
|
||||
*/
|
||||
virtual void match(const ImageFeatures &features1, const ImageFeatures &features2,
|
||||
MatchesInfo &matches_info) = 0;
|
||||
|
||||
bool is_thread_safe_;
|
||||
};
|
||||
bool is_thread_safe_;
|
||||
};
|
||||
|
||||
/** @brief Features matcher which finds two best matches for each feature and leaves the best one only if the
|
||||
ratio between descriptor distances is greater than the threshold match_conf
|
||||
|
||||
@sa detail::FeaturesMatcher
|
||||
*/
|
||||
class CV_EXPORTS_W BestOf2NearestMatcher : public FeaturesMatcher {
|
||||
public:
|
||||
/** @brief Constructs a "best of 2 nearest" matcher.
|
||||
class CV_EXPORTS_W BestOf2NearestMatcher : public FeaturesMatcher
|
||||
{
|
||||
public:
|
||||
/** @brief Constructs a "best of 2 nearest" matcher.
|
||||
|
||||
@param try_use_gpu Should try to use GPU or not
|
||||
@param match_conf Match distances ration threshold
|
||||
@param num_matches_thresh1 Minimum number of matches required for the 2D projective transform
|
||||
estimation used in the inliers classification step
|
||||
@param num_matches_thresh2 Minimum number of matches required for the 2D projective transform
|
||||
re-estimation on inliers
|
||||
*/
|
||||
CV_WRAP BestOf2NearestMatcher(bool try_use_gpu = false, float match_conf = 0.3f,
|
||||
int num_matches_thresh1 = 6,
|
||||
int num_matches_thresh2 = 6);
|
||||
@param try_use_gpu Should try to use GPU or not
|
||||
@param match_conf Match distances ration threshold
|
||||
@param num_matches_thresh1 Minimum number of matches required for the 2D projective transform
|
||||
estimation used in the inliers classification step
|
||||
@param num_matches_thresh2 Minimum number of matches required for the 2D projective transform
|
||||
re-estimation on inliers
|
||||
*/
|
||||
CV_WRAP BestOf2NearestMatcher(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6,
|
||||
int num_matches_thresh2 = 6);
|
||||
|
||||
CV_WRAP void collectGarbage() CV_OVERRIDE;
|
||||
CV_WRAP void collectGarbage() CV_OVERRIDE;
|
||||
CV_WRAP static Ptr<BestOf2NearestMatcher> create(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6,
|
||||
int num_matches_thresh2 = 6);
|
||||
|
||||
CV_WRAP static Ptr <BestOf2NearestMatcher>
|
||||
create(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6,
|
||||
int num_matches_thresh2 = 6);
|
||||
protected:
|
||||
|
||||
protected:
|
||||
void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info) CV_OVERRIDE;
|
||||
int num_matches_thresh1_;
|
||||
int num_matches_thresh2_;
|
||||
Ptr<FeaturesMatcher> impl_;
|
||||
};
|
||||
|
||||
void match(const ImageFeatures &features1, const ImageFeatures &features2,
|
||||
MatchesInfo &matches_info) CV_OVERRIDE;
|
||||
class CV_EXPORTS_W BestOf2NearestRangeMatcher : public BestOf2NearestMatcher
|
||||
{
|
||||
public:
|
||||
CV_WRAP BestOf2NearestRangeMatcher(int range_width = 5, bool try_use_gpu = false, float match_conf = 0.3f,
|
||||
int num_matches_thresh1 = 6, int num_matches_thresh2 = 6);
|
||||
|
||||
int num_matches_thresh1_;
|
||||
int num_matches_thresh2_;
|
||||
Ptr <FeaturesMatcher> impl_;
|
||||
};
|
||||
|
||||
class CV_EXPORTS_W BestOf2NearestRangeMatcher : public BestOf2NearestMatcher {
|
||||
public:
|
||||
CV_WRAP BestOf2NearestRangeMatcher(int range_width = 5, bool try_use_gpu = false,
|
||||
float match_conf = 0.3f,
|
||||
int num_matches_thresh1 = 6,
|
||||
int num_matches_thresh2 = 6);
|
||||
|
||||
void operator()(const std::vector<ImageFeatures> &features,
|
||||
std::vector<MatchesInfo> &pairwise_matches,
|
||||
const cv::UMat &mask = cv::UMat());
|
||||
void operator ()(const std::vector<ImageFeatures> &features, std::vector<MatchesInfo> &pairwise_matches,
|
||||
const cv::UMat &mask = cv::UMat());
|
||||
|
||||
|
||||
protected:
|
||||
int range_width_;
|
||||
};
|
||||
protected:
|
||||
int range_width_;
|
||||
};
|
||||
|
||||
/** @brief Features matcher similar to cv::detail::BestOf2NearestMatcher which
|
||||
finds two best matches for each feature and leaves the best one only if the
|
||||
@@ -233,37 +219,35 @@ transformation (affine trasformation estimate will be placed in matches_info).
|
||||
|
||||
@sa cv::detail::FeaturesMatcher cv::detail::BestOf2NearestMatcher
|
||||
*/
|
||||
class CV_EXPORTS_W AffineBestOf2NearestMatcher : public BestOf2NearestMatcher {
|
||||
public:
|
||||
/** @brief Constructs a "best of 2 nearest" matcher that expects affine trasformation
|
||||
between images
|
||||
class CV_EXPORTS_W AffineBestOf2NearestMatcher : public BestOf2NearestMatcher
|
||||
{
|
||||
public:
|
||||
/** @brief Constructs a "best of 2 nearest" matcher that expects affine trasformation
|
||||
between images
|
||||
|
||||
@param full_affine whether to use full affine transformation with 6 degress of freedom or reduced
|
||||
transformation with 4 degrees of freedom using only rotation, translation and uniform scaling
|
||||
@param try_use_gpu Should try to use GPU or not
|
||||
@param match_conf Match distances ration threshold
|
||||
@param num_matches_thresh1 Minimum number of matches required for the 2D affine transform
|
||||
estimation used in the inliers classification step
|
||||
@param full_affine whether to use full affine transformation with 6 degress of freedom or reduced
|
||||
transformation with 4 degrees of freedom using only rotation, translation and uniform scaling
|
||||
@param try_use_gpu Should try to use GPU or not
|
||||
@param match_conf Match distances ration threshold
|
||||
@param num_matches_thresh1 Minimum number of matches required for the 2D affine transform
|
||||
estimation used in the inliers classification step
|
||||
|
||||
@sa cv::estimateAffine2D cv::estimateAffinePartial2D
|
||||
*/
|
||||
CV_WRAP AffineBestOf2NearestMatcher(bool full_affine = false, bool try_use_gpu = false,
|
||||
float match_conf = 0.3f,
|
||||
int num_matches_thresh1 = 6) :
|
||||
BestOf2NearestMatcher(try_use_gpu, match_conf, num_matches_thresh1,
|
||||
num_matches_thresh1),
|
||||
full_affine_(full_affine) {}
|
||||
@sa cv::estimateAffine2D cv::estimateAffinePartial2D
|
||||
*/
|
||||
CV_WRAP AffineBestOf2NearestMatcher(bool full_affine = false, bool try_use_gpu = false,
|
||||
float match_conf = 0.3f, int num_matches_thresh1 = 6) :
|
||||
BestOf2NearestMatcher(try_use_gpu, match_conf, num_matches_thresh1, num_matches_thresh1),
|
||||
full_affine_(full_affine) {}
|
||||
|
||||
protected:
|
||||
void match(const ImageFeatures &features1, const ImageFeatures &features2,
|
||||
MatchesInfo &matches_info) CV_OVERRIDE;
|
||||
protected:
|
||||
void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info) CV_OVERRIDE;
|
||||
|
||||
bool full_affine_;
|
||||
};
|
||||
bool full_affine_;
|
||||
};
|
||||
|
||||
//! @} stitching_match
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_STITCHING_MATCHERS_HPP
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
#include "camera.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_rotation
|
||||
//! @{
|
||||
@@ -62,53 +62,54 @@ cameras.
|
||||
@note The coordinate system origin is implementation-dependent, but you can always normalize the
|
||||
rotations in respect to the first camera, for instance. :
|
||||
*/
|
||||
class CV_EXPORTS_W Estimator {
|
||||
public:
|
||||
virtual ~Estimator() {}
|
||||
class CV_EXPORTS_W Estimator
|
||||
{
|
||||
public:
|
||||
virtual ~Estimator() {}
|
||||
|
||||
/** @brief Estimates camera parameters.
|
||||
/** @brief Estimates camera parameters.
|
||||
|
||||
@param features Features of images
|
||||
@param pairwise_matches Pairwise matches of images
|
||||
@param cameras Estimated camera parameters
|
||||
@return True in case of success, false otherwise
|
||||
*/
|
||||
CV_WRAP_AS(apply)
|
||||
@param features Features of images
|
||||
@param pairwise_matches Pairwise matches of images
|
||||
@param cameras Estimated camera parameters
|
||||
@return True in case of success, false otherwise
|
||||
*/
|
||||
CV_WRAP_AS(apply) bool operator ()(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
CV_OUT CV_IN_OUT std::vector<CameraParams> &cameras)
|
||||
{
|
||||
return estimate(features, pairwise_matches, cameras);
|
||||
}
|
||||
|
||||
bool operator()(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
CV_OUT CV_IN_OUT std::vector<CameraParams> &cameras) {
|
||||
return estimate(features, pairwise_matches, cameras);
|
||||
}
|
||||
protected:
|
||||
/** @brief This method must implement camera parameters estimation logic in order to make the wrapper
|
||||
detail::Estimator::operator()_ work.
|
||||
|
||||
protected:
|
||||
/** @brief This method must implement camera parameters estimation logic in order to make the wrapper
|
||||
detail::Estimator::operator()_ work.
|
||||
|
||||
@param features Features of images
|
||||
@param pairwise_matches Pairwise matches of images
|
||||
@param cameras Estimated camera parameters
|
||||
@return True in case of success, false otherwise
|
||||
*/
|
||||
virtual bool estimate(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
CV_OUT std::vector<CameraParams> &cameras) = 0;
|
||||
};
|
||||
@param features Features of images
|
||||
@param pairwise_matches Pairwise matches of images
|
||||
@param cameras Estimated camera parameters
|
||||
@return True in case of success, false otherwise
|
||||
*/
|
||||
virtual bool estimate(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
CV_OUT std::vector<CameraParams> &cameras) = 0;
|
||||
};
|
||||
|
||||
/** @brief Homography based rotation estimator.
|
||||
*/
|
||||
class CV_EXPORTS_W HomographyBasedEstimator : public Estimator {
|
||||
public:
|
||||
CV_WRAP HomographyBasedEstimator(bool is_focals_estimated = false)
|
||||
: is_focals_estimated_(is_focals_estimated) {}
|
||||
class CV_EXPORTS_W HomographyBasedEstimator : public Estimator
|
||||
{
|
||||
public:
|
||||
CV_WRAP HomographyBasedEstimator(bool is_focals_estimated = false)
|
||||
: is_focals_estimated_(is_focals_estimated) {}
|
||||
|
||||
private:
|
||||
virtual bool estimate(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
private:
|
||||
virtual bool estimate(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
|
||||
bool is_focals_estimated_;
|
||||
};
|
||||
bool is_focals_estimated_;
|
||||
};
|
||||
|
||||
/** @brief Affine transformation based estimator.
|
||||
|
||||
@@ -117,129 +118,122 @@ final transformation for each camera.
|
||||
|
||||
@sa cv::detail::HomographyBasedEstimator
|
||||
*/
|
||||
class CV_EXPORTS_W AffineBasedEstimator : public Estimator {
|
||||
public:
|
||||
CV_WRAP AffineBasedEstimator() {}
|
||||
|
||||
private:
|
||||
virtual bool estimate(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
};
|
||||
class CV_EXPORTS_W AffineBasedEstimator : public Estimator
|
||||
{
|
||||
public:
|
||||
CV_WRAP AffineBasedEstimator(){}
|
||||
private:
|
||||
virtual bool estimate(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
};
|
||||
|
||||
/** @brief Base class for all camera parameters refinement methods.
|
||||
*/
|
||||
class CV_EXPORTS_W BundleAdjusterBase : public Estimator {
|
||||
public:
|
||||
CV_WRAP const Mat refinementMask() const { return refinement_mask_.clone(); }
|
||||
class CV_EXPORTS_W BundleAdjusterBase : public Estimator
|
||||
{
|
||||
public:
|
||||
CV_WRAP const Mat refinementMask() const { return refinement_mask_.clone(); }
|
||||
CV_WRAP void setRefinementMask(const Mat &mask)
|
||||
{
|
||||
CV_Assert(mask.type() == CV_8U && mask.size() == Size(3, 3));
|
||||
refinement_mask_ = mask.clone();
|
||||
}
|
||||
|
||||
CV_WRAP void setRefinementMask(const Mat &mask) {
|
||||
CV_Assert(mask.type() == CV_8U && mask.size() == Size(3, 3));
|
||||
refinement_mask_ = mask.clone();
|
||||
}
|
||||
CV_WRAP double confThresh() const { return conf_thresh_; }
|
||||
CV_WRAP void setConfThresh(double conf_thresh) { conf_thresh_ = conf_thresh; }
|
||||
|
||||
CV_WRAP double confThresh() const { return conf_thresh_; }
|
||||
CV_WRAP TermCriteria termCriteria() { return term_criteria_; }
|
||||
CV_WRAP void setTermCriteria(const TermCriteria& term_criteria) { term_criteria_ = term_criteria; }
|
||||
|
||||
CV_WRAP void setConfThresh(double conf_thresh) { conf_thresh_ = conf_thresh; }
|
||||
protected:
|
||||
/** @brief Construct a bundle adjuster base instance.
|
||||
|
||||
CV_WRAP TermCriteria termCriteria() { return term_criteria_; }
|
||||
@param num_params_per_cam Number of parameters per camera
|
||||
@param num_errs_per_measurement Number of error terms (components) per match
|
||||
*/
|
||||
BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement)
|
||||
: num_images_(0), total_num_matches_(0),
|
||||
num_params_per_cam_(num_params_per_cam),
|
||||
num_errs_per_measurement_(num_errs_per_measurement),
|
||||
features_(0), pairwise_matches_(0), conf_thresh_(0)
|
||||
{
|
||||
setRefinementMask(Mat::ones(3, 3, CV_8U));
|
||||
setConfThresh(1.);
|
||||
setTermCriteria(TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 1000, DBL_EPSILON));
|
||||
}
|
||||
|
||||
CV_WRAP void
|
||||
setTermCriteria(const TermCriteria &term_criteria) { term_criteria_ = term_criteria; }
|
||||
// Runs bundle adjustment
|
||||
virtual bool estimate(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
|
||||
protected:
|
||||
/** @brief Construct a bundle adjuster base instance.
|
||||
/** @brief Sets initial camera parameter to refine.
|
||||
|
||||
@param num_params_per_cam Number of parameters per camera
|
||||
@param num_errs_per_measurement Number of error terms (components) per match
|
||||
*/
|
||||
BundleAdjusterBase(int num_params_per_cam, int num_errs_per_measurement)
|
||||
: num_images_(0), total_num_matches_(0),
|
||||
num_params_per_cam_(num_params_per_cam),
|
||||
num_errs_per_measurement_(num_errs_per_measurement),
|
||||
features_(0), pairwise_matches_(0), conf_thresh_(0) {
|
||||
setRefinementMask(Mat::ones(3, 3, CV_8U));
|
||||
setConfThresh(1.);
|
||||
setTermCriteria(
|
||||
TermCriteria(TermCriteria::EPS + TermCriteria::COUNT, 1000, DBL_EPSILON));
|
||||
}
|
||||
@param cameras Camera parameters
|
||||
*/
|
||||
virtual void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) = 0;
|
||||
/** @brief Gets the refined camera parameters.
|
||||
|
||||
// Runs bundle adjustment
|
||||
virtual bool estimate(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
@param cameras Refined camera parameters
|
||||
*/
|
||||
virtual void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const = 0;
|
||||
/** @brief Calculates error vector.
|
||||
|
||||
/** @brief Sets initial camera parameter to refine.
|
||||
@param err Error column-vector of length total_num_matches \* num_errs_per_measurement
|
||||
*/
|
||||
virtual void calcError(Mat &err) = 0;
|
||||
/** @brief Calculates the cost function jacobian.
|
||||
|
||||
@param cameras Camera parameters
|
||||
*/
|
||||
virtual void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) = 0;
|
||||
@param jac Jacobian matrix of dimensions
|
||||
(total_num_matches \* num_errs_per_measurement) x (num_images \* num_params_per_cam)
|
||||
*/
|
||||
virtual void calcJacobian(Mat &jac) = 0;
|
||||
|
||||
/** @brief Gets the refined camera parameters.
|
||||
// 3x3 8U mask, where 0 means don't refine respective parameter, != 0 means refine
|
||||
Mat refinement_mask_;
|
||||
|
||||
@param cameras Refined camera parameters
|
||||
*/
|
||||
virtual void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const = 0;
|
||||
int num_images_;
|
||||
int total_num_matches_;
|
||||
|
||||
/** @brief Calculates error vector.
|
||||
int num_params_per_cam_;
|
||||
int num_errs_per_measurement_;
|
||||
|
||||
@param err Error column-vector of length total_num_matches \* num_errs_per_measurement
|
||||
*/
|
||||
virtual void calcError(Mat &err) = 0;
|
||||
const ImageFeatures *features_;
|
||||
const MatchesInfo *pairwise_matches_;
|
||||
|
||||
/** @brief Calculates the cost function jacobian.
|
||||
// Threshold to filter out poorly matched image pairs
|
||||
double conf_thresh_;
|
||||
|
||||
@param jac Jacobian matrix of dimensions
|
||||
(total_num_matches \* num_errs_per_measurement) x (num_images \* num_params_per_cam)
|
||||
*/
|
||||
virtual void calcJacobian(Mat &jac) = 0;
|
||||
//Levenberg-Marquardt algorithm termination criteria
|
||||
TermCriteria term_criteria_;
|
||||
|
||||
// 3x3 8U mask, where 0 means don't refine respective parameter, != 0 means refine
|
||||
Mat refinement_mask_;
|
||||
// Camera parameters matrix (CV_64F)
|
||||
Mat cam_params_;
|
||||
|
||||
int num_images_;
|
||||
int total_num_matches_;
|
||||
|
||||
int num_params_per_cam_;
|
||||
int num_errs_per_measurement_;
|
||||
|
||||
const ImageFeatures *features_;
|
||||
const MatchesInfo *pairwise_matches_;
|
||||
|
||||
// Threshold to filter out poorly matched image pairs
|
||||
double conf_thresh_;
|
||||
|
||||
//Levenberg-Marquardt algorithm termination criteria
|
||||
TermCriteria term_criteria_;
|
||||
|
||||
// Camera parameters matrix (CV_64F)
|
||||
Mat cam_params_;
|
||||
|
||||
// Connected images pairs
|
||||
std::vector<std::pair<int, int> > edges_;
|
||||
};
|
||||
// Connected images pairs
|
||||
std::vector<std::pair<int,int> > edges_;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Stub bundle adjuster that does nothing.
|
||||
*/
|
||||
class CV_EXPORTS_W NoBundleAdjuster : public BundleAdjusterBase {
|
||||
public:
|
||||
CV_WRAP NoBundleAdjuster() : BundleAdjusterBase(0, 0) {}
|
||||
class CV_EXPORTS_W NoBundleAdjuster : public BundleAdjusterBase
|
||||
{
|
||||
public:
|
||||
CV_WRAP NoBundleAdjuster() : BundleAdjusterBase(0, 0) {}
|
||||
|
||||
private:
|
||||
bool estimate(const std::vector<ImageFeatures> &, const std::vector<MatchesInfo> &,
|
||||
std::vector<CameraParams> &) CV_OVERRIDE {
|
||||
return true;
|
||||
}
|
||||
|
||||
void setUpInitialCameraParams(const std::vector<CameraParams> &) CV_OVERRIDE {}
|
||||
|
||||
void obtainRefinedCameraParams(std::vector<CameraParams> &) const CV_OVERRIDE {}
|
||||
|
||||
void calcError(Mat &) CV_OVERRIDE {}
|
||||
|
||||
void calcJacobian(Mat &) CV_OVERRIDE {}
|
||||
};
|
||||
private:
|
||||
bool estimate(const std::vector<ImageFeatures> &, const std::vector<MatchesInfo> &,
|
||||
std::vector<CameraParams> &) CV_OVERRIDE
|
||||
{
|
||||
return true;
|
||||
}
|
||||
void setUpInitialCameraParams(const std::vector<CameraParams> &) CV_OVERRIDE {}
|
||||
void obtainRefinedCameraParams(std::vector<CameraParams> &) const CV_OVERRIDE {}
|
||||
void calcError(Mat &) CV_OVERRIDE {}
|
||||
void calcJacobian(Mat &) CV_OVERRIDE {}
|
||||
};
|
||||
|
||||
|
||||
/** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the reprojection
|
||||
@@ -248,21 +242,19 @@ error squares
|
||||
It can estimate focal length, aspect ratio, principal point.
|
||||
You can affect only on them via the refinement mask.
|
||||
*/
|
||||
class CV_EXPORTS_W BundleAdjusterReproj : public BundleAdjusterBase {
|
||||
public:
|
||||
CV_WRAP BundleAdjusterReproj() : BundleAdjusterBase(7, 2) {}
|
||||
class CV_EXPORTS_W BundleAdjusterReproj : public BundleAdjusterBase
|
||||
{
|
||||
public:
|
||||
CV_WRAP BundleAdjusterReproj() : BundleAdjusterBase(7, 2) {}
|
||||
|
||||
private:
|
||||
void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
private:
|
||||
void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const CV_OVERRIDE;
|
||||
void calcError(Mat &err) CV_OVERRIDE;
|
||||
void calcJacobian(Mat &jac) CV_OVERRIDE;
|
||||
|
||||
void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const CV_OVERRIDE;
|
||||
|
||||
void calcError(Mat &err) CV_OVERRIDE;
|
||||
|
||||
void calcJacobian(Mat &jac) CV_OVERRIDE;
|
||||
|
||||
Mat err1_, err2_;
|
||||
};
|
||||
Mat err1_, err2_;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the distances
|
||||
@@ -270,21 +262,19 @@ between the rays passing through the camera center and a feature. :
|
||||
|
||||
It can estimate focal length. It ignores the refinement mask for now.
|
||||
*/
|
||||
class CV_EXPORTS_W BundleAdjusterRay : public BundleAdjusterBase {
|
||||
public:
|
||||
CV_WRAP BundleAdjusterRay() : BundleAdjusterBase(4, 3) {}
|
||||
class CV_EXPORTS_W BundleAdjusterRay : public BundleAdjusterBase
|
||||
{
|
||||
public:
|
||||
CV_WRAP BundleAdjusterRay() : BundleAdjusterBase(4, 3) {}
|
||||
|
||||
private:
|
||||
void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
private:
|
||||
void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const CV_OVERRIDE;
|
||||
void calcError(Mat &err) CV_OVERRIDE;
|
||||
void calcJacobian(Mat &jac) CV_OVERRIDE;
|
||||
|
||||
void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const CV_OVERRIDE;
|
||||
|
||||
void calcError(Mat &err) CV_OVERRIDE;
|
||||
|
||||
void calcJacobian(Mat &jac) CV_OVERRIDE;
|
||||
|
||||
Mat err1_, err2_;
|
||||
};
|
||||
Mat err1_, err2_;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Bundle adjuster that expects affine transformation
|
||||
@@ -296,21 +286,19 @@ It estimates all transformation parameters. Refinement mask is ignored.
|
||||
|
||||
@sa AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffinePartial
|
||||
*/
|
||||
class CV_EXPORTS_W BundleAdjusterAffine : public BundleAdjusterBase {
|
||||
public:
|
||||
CV_WRAP BundleAdjusterAffine() : BundleAdjusterBase(6, 2) {}
|
||||
class CV_EXPORTS_W BundleAdjusterAffine : public BundleAdjusterBase
|
||||
{
|
||||
public:
|
||||
CV_WRAP BundleAdjusterAffine() : BundleAdjusterBase(6, 2) {}
|
||||
|
||||
private:
|
||||
void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
private:
|
||||
void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const CV_OVERRIDE;
|
||||
void calcError(Mat &err) CV_OVERRIDE;
|
||||
void calcJacobian(Mat &jac) CV_OVERRIDE;
|
||||
|
||||
void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const CV_OVERRIDE;
|
||||
|
||||
void calcError(Mat &err) CV_OVERRIDE;
|
||||
|
||||
void calcJacobian(Mat &jac) CV_OVERRIDE;
|
||||
|
||||
Mat err1_, err2_;
|
||||
};
|
||||
Mat err1_, err2_;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Bundle adjuster that expects affine transformation with 4 DOF
|
||||
@@ -322,56 +310,54 @@ It estimates all transformation parameters. Refinement mask is ignored.
|
||||
|
||||
@sa AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffine
|
||||
*/
|
||||
class CV_EXPORTS_W BundleAdjusterAffinePartial : public BundleAdjusterBase {
|
||||
public:
|
||||
CV_WRAP BundleAdjusterAffinePartial() : BundleAdjusterBase(4, 2) {}
|
||||
class CV_EXPORTS_W BundleAdjusterAffinePartial : public BundleAdjusterBase
|
||||
{
|
||||
public:
|
||||
CV_WRAP BundleAdjusterAffinePartial() : BundleAdjusterBase(4, 2) {}
|
||||
|
||||
private:
|
||||
void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
private:
|
||||
void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) CV_OVERRIDE;
|
||||
void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const CV_OVERRIDE;
|
||||
void calcError(Mat &err) CV_OVERRIDE;
|
||||
void calcJacobian(Mat &jac) CV_OVERRIDE;
|
||||
|
||||
void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const CV_OVERRIDE;
|
||||
|
||||
void calcError(Mat &err) CV_OVERRIDE;
|
||||
|
||||
void calcJacobian(Mat &jac) CV_OVERRIDE;
|
||||
|
||||
Mat err1_, err2_;
|
||||
};
|
||||
Mat err1_, err2_;
|
||||
};
|
||||
|
||||
|
||||
enum WaveCorrectKind {
|
||||
WAVE_CORRECT_HORIZ,
|
||||
WAVE_CORRECT_VERT
|
||||
};
|
||||
enum WaveCorrectKind
|
||||
{
|
||||
WAVE_CORRECT_HORIZ,
|
||||
WAVE_CORRECT_VERT
|
||||
};
|
||||
|
||||
/** @brief Tries to make panorama more horizontal (or vertical).
|
||||
|
||||
@param rmats Camera rotation matrices.
|
||||
@param kind Correction kind, see detail::WaveCorrectKind.
|
||||
*/
|
||||
void CV_EXPORTS_W waveCorrect(CV_IN_OUT std::vector<Mat> &rmats, WaveCorrectKind kind);
|
||||
void CV_EXPORTS_W waveCorrect(CV_IN_OUT std::vector<Mat> &rmats, WaveCorrectKind kind);
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Auxiliary functions
|
||||
|
||||
// Returns matches graph representation in DOT language
|
||||
String CV_EXPORTS_W matchesGraphAsString(std::vector<String> &pathes,
|
||||
std::vector<MatchesInfo> &pairwise_matches,
|
||||
float conf_threshold);
|
||||
String CV_EXPORTS_W matchesGraphAsString(std::vector<String> &pathes, std::vector<MatchesInfo> &pairwise_matches,
|
||||
float conf_threshold);
|
||||
|
||||
CV_EXPORTS_W std::vector<int> leaveBiggestComponent(
|
||||
std::vector<ImageFeatures> &features,
|
||||
std::vector<MatchesInfo> &pairwise_matches,
|
||||
float conf_threshold);
|
||||
CV_EXPORTS_W std::vector<int> leaveBiggestComponent(
|
||||
std::vector<ImageFeatures> &features,
|
||||
std::vector<MatchesInfo> &pairwise_matches,
|
||||
float conf_threshold);
|
||||
|
||||
void CV_EXPORTS findMaxSpanningTree(
|
||||
int num_images, const std::vector<MatchesInfo> &pairwise_matches,
|
||||
Graph &span_tree, std::vector<int> ¢ers);
|
||||
void CV_EXPORTS findMaxSpanningTree(
|
||||
int num_images, const std::vector<MatchesInfo> &pairwise_matches,
|
||||
Graph &span_tree, std::vector<int> ¢ers);
|
||||
|
||||
//! @} stitching_rotation
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_STITCHING_MOTION_ESTIMATORS_HPP
|
||||
|
||||
@@ -48,258 +48,244 @@
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_seam
|
||||
//! @{
|
||||
|
||||
/** @brief Base class for a seam estimator.
|
||||
*/
|
||||
class CV_EXPORTS_W SeamFinder {
|
||||
public:
|
||||
CV_WRAP virtual ~SeamFinder() {}
|
||||
class CV_EXPORTS_W SeamFinder
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual ~SeamFinder() {}
|
||||
enum { NO, VORONOI_SEAM, DP_SEAM };
|
||||
/** @brief Estimates seams.
|
||||
|
||||
enum {
|
||||
NO, VORONOI_SEAM, DP_SEAM
|
||||
};
|
||||
/** @brief Estimates seams.
|
||||
|
||||
@param src Source images
|
||||
@param corners Source image top-left corners
|
||||
@param masks Source image masks to update
|
||||
*/
|
||||
CV_WRAP virtual void
|
||||
find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
CV_IN_OUT std::vector<UMat> &masks) = 0;
|
||||
|
||||
CV_WRAP static Ptr <SeamFinder> createDefault(int type);
|
||||
};
|
||||
@param src Source images
|
||||
@param corners Source image top-left corners
|
||||
@param masks Source image masks to update
|
||||
*/
|
||||
CV_WRAP virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
CV_IN_OUT std::vector<UMat> &masks) = 0;
|
||||
CV_WRAP static Ptr<SeamFinder> createDefault(int type);
|
||||
};
|
||||
|
||||
/** @brief Stub seam estimator which does nothing.
|
||||
*/
|
||||
class CV_EXPORTS_W NoSeamFinder : public SeamFinder {
|
||||
public:
|
||||
CV_WRAP void find(const std::vector<UMat> &, const std::vector<Point> &, CV_IN_OUT
|
||||
std::vector<UMat> &) CV_OVERRIDE {}
|
||||
};
|
||||
class CV_EXPORTS_W NoSeamFinder : public SeamFinder
|
||||
{
|
||||
public:
|
||||
CV_WRAP void find(const std::vector<UMat>&, const std::vector<Point>&, CV_IN_OUT std::vector<UMat>&) CV_OVERRIDE {}
|
||||
};
|
||||
|
||||
/** @brief Base class for all pairwise seam estimators.
|
||||
*/
|
||||
class CV_EXPORTS_W PairwiseSeamFinder : public SeamFinder {
|
||||
public:
|
||||
CV_WRAP virtual void
|
||||
find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
CV_IN_OUT std::vector<UMat> &masks) CV_OVERRIDE;
|
||||
class CV_EXPORTS_W PairwiseSeamFinder : public SeamFinder
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
CV_IN_OUT std::vector<UMat> &masks) CV_OVERRIDE;
|
||||
|
||||
protected:
|
||||
void run();
|
||||
protected:
|
||||
void run();
|
||||
/** @brief Resolves masks intersection of two specified images in the given ROI.
|
||||
|
||||
/** @brief Resolves masks intersection of two specified images in the given ROI.
|
||||
@param first First image index
|
||||
@param second Second image index
|
||||
@param roi Region of interest
|
||||
*/
|
||||
virtual void findInPair(size_t first, size_t second, Rect roi) = 0;
|
||||
|
||||
@param first First image index
|
||||
@param second Second image index
|
||||
@param roi Region of interest
|
||||
*/
|
||||
virtual void findInPair(size_t first, size_t second, Rect roi) = 0;
|
||||
|
||||
std::vector<UMat> images_;
|
||||
std::vector<Size> sizes_;
|
||||
std::vector<Point> corners_;
|
||||
std::vector<UMat> masks_;
|
||||
};
|
||||
std::vector<UMat> images_;
|
||||
std::vector<Size> sizes_;
|
||||
std::vector<Point> corners_;
|
||||
std::vector<UMat> masks_;
|
||||
};
|
||||
|
||||
/** @brief Voronoi diagram-based seam estimator.
|
||||
*/
|
||||
class CV_EXPORTS_W VoronoiSeamFinder : public PairwiseSeamFinder {
|
||||
public:
|
||||
CV_WRAP virtual void
|
||||
find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
CV_IN_OUT std::vector<UMat> &masks) CV_OVERRIDE;
|
||||
|
||||
virtual void find(const std::vector<Size> &size, const std::vector<Point> &corners,
|
||||
std::vector<UMat> &masks);
|
||||
|
||||
private:
|
||||
void findInPair(size_t first, size_t second, Rect roi) CV_OVERRIDE;
|
||||
};
|
||||
class CV_EXPORTS_W VoronoiSeamFinder : public PairwiseSeamFinder
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
CV_IN_OUT std::vector<UMat> &masks) CV_OVERRIDE;
|
||||
virtual void find(const std::vector<Size> &size, const std::vector<Point> &corners,
|
||||
std::vector<UMat> &masks);
|
||||
private:
|
||||
void findInPair(size_t first, size_t second, Rect roi) CV_OVERRIDE;
|
||||
};
|
||||
|
||||
|
||||
class CV_EXPORTS_W DpSeamFinder : public SeamFinder {
|
||||
public:
|
||||
enum CostFunction {
|
||||
COLOR, COLOR_GRAD
|
||||
};
|
||||
class CV_EXPORTS_W DpSeamFinder : public SeamFinder
|
||||
{
|
||||
public:
|
||||
enum CostFunction { COLOR, COLOR_GRAD };
|
||||
|
||||
DpSeamFinder(CostFunction costFunc = COLOR);
|
||||
DpSeamFinder(CostFunction costFunc = COLOR);
|
||||
CV_WRAP DpSeamFinder(String costFunc );
|
||||
|
||||
CV_WRAP DpSeamFinder(String costFunc);
|
||||
CostFunction costFunction() const { return costFunc_; }
|
||||
void setCostFunction(CostFunction val) { costFunc_ = val; }
|
||||
CV_WRAP void setCostFunction(String val);
|
||||
|
||||
CostFunction costFunction() const { return costFunc_; }
|
||||
virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
std::vector<UMat> &masks) CV_OVERRIDE;
|
||||
|
||||
void setCostFunction(CostFunction val) { costFunc_ = val; }
|
||||
private:
|
||||
enum ComponentState
|
||||
{
|
||||
FIRST = 1, SECOND = 2, INTERS = 4,
|
||||
INTERS_FIRST = INTERS | FIRST,
|
||||
INTERS_SECOND = INTERS | SECOND
|
||||
};
|
||||
|
||||
CV_WRAP void setCostFunction(String val);
|
||||
class ImagePairLess
|
||||
{
|
||||
public:
|
||||
ImagePairLess(const std::vector<Mat> &images, const std::vector<Point> &corners)
|
||||
: src_(&images[0]), corners_(&corners[0]) {}
|
||||
|
||||
virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
std::vector<UMat> &masks) CV_OVERRIDE;
|
||||
bool operator() (const std::pair<size_t, size_t> &l, const std::pair<size_t, size_t> &r) const
|
||||
{
|
||||
Point c1 = corners_[l.first] + Point(src_[l.first].cols / 2, src_[l.first].rows / 2);
|
||||
Point c2 = corners_[l.second] + Point(src_[l.second].cols / 2, src_[l.second].rows / 2);
|
||||
int d1 = (c1 - c2).dot(c1 - c2);
|
||||
|
||||
private:
|
||||
enum ComponentState {
|
||||
FIRST = 1, SECOND = 2, INTERS = 4,
|
||||
INTERS_FIRST = INTERS | FIRST,
|
||||
INTERS_SECOND = INTERS | SECOND
|
||||
};
|
||||
c1 = corners_[r.first] + Point(src_[r.first].cols / 2, src_[r.first].rows / 2);
|
||||
c2 = corners_[r.second] + Point(src_[r.second].cols / 2, src_[r.second].rows / 2);
|
||||
int d2 = (c1 - c2).dot(c1 - c2);
|
||||
|
||||
class ImagePairLess {
|
||||
public:
|
||||
ImagePairLess(const std::vector<Mat> &images, const std::vector<Point> &corners)
|
||||
: src_(&images[0]), corners_(&corners[0]) {}
|
||||
return d1 < d2;
|
||||
}
|
||||
|
||||
bool operator()(const std::pair<size_t, size_t> &l,
|
||||
const std::pair<size_t, size_t> &r) const {
|
||||
Point c1 = corners_[l.first] +
|
||||
Point(src_[l.first].cols / 2, src_[l.first].rows / 2);
|
||||
Point c2 = corners_[l.second] +
|
||||
Point(src_[l.second].cols / 2, src_[l.second].rows / 2);
|
||||
int d1 = (c1 - c2).dot(c1 - c2);
|
||||
private:
|
||||
const Mat *src_;
|
||||
const Point *corners_;
|
||||
};
|
||||
|
||||
c1 = corners_[r.first] + Point(src_[r.first].cols / 2, src_[r.first].rows / 2);
|
||||
c2 = corners_[r.second] +
|
||||
Point(src_[r.second].cols / 2, src_[r.second].rows / 2);
|
||||
int d2 = (c1 - c2).dot(c1 - c2);
|
||||
class ClosePoints
|
||||
{
|
||||
public:
|
||||
ClosePoints(int minDist) : minDist_(minDist) {}
|
||||
|
||||
return d1 < d2;
|
||||
}
|
||||
bool operator() (const Point &p1, const Point &p2) const
|
||||
{
|
||||
int dist2 = (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y);
|
||||
return dist2 < minDist_ * minDist_;
|
||||
}
|
||||
|
||||
private:
|
||||
const Mat *src_;
|
||||
const Point *corners_;
|
||||
};
|
||||
private:
|
||||
int minDist_;
|
||||
};
|
||||
|
||||
class ClosePoints {
|
||||
public:
|
||||
ClosePoints(int minDist) : minDist_(minDist) {}
|
||||
void process(
|
||||
const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1, Mat &mask2);
|
||||
|
||||
bool operator()(const Point &p1, const Point &p2) const {
|
||||
int dist2 = (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
|
||||
return dist2 < minDist_ * minDist_;
|
||||
}
|
||||
void findComponents();
|
||||
|
||||
private:
|
||||
int minDist_;
|
||||
};
|
||||
void findEdges();
|
||||
|
||||
void process(
|
||||
const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1,
|
||||
Mat &mask2);
|
||||
void resolveConflicts(
|
||||
const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1, Mat &mask2);
|
||||
|
||||
void findComponents();
|
||||
void computeGradients(const Mat &image1, const Mat &image2);
|
||||
|
||||
void findEdges();
|
||||
bool hasOnlyOneNeighbor(int comp);
|
||||
|
||||
void resolveConflicts(
|
||||
const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1,
|
||||
Mat &mask2);
|
||||
bool closeToContour(int y, int x, const Mat_<uchar> &contourMask);
|
||||
|
||||
void computeGradients(const Mat &image1, const Mat &image2);
|
||||
bool getSeamTips(int comp1, int comp2, Point &p1, Point &p2);
|
||||
|
||||
bool hasOnlyOneNeighbor(int comp);
|
||||
void computeCosts(
|
||||
const Mat &image1, const Mat &image2, Point tl1, Point tl2,
|
||||
int comp, Mat_<float> &costV, Mat_<float> &costH);
|
||||
|
||||
bool closeToContour(int y, int x, const Mat_ <uchar> &contourMask);
|
||||
bool estimateSeam(
|
||||
const Mat &image1, const Mat &image2, Point tl1, Point tl2, int comp,
|
||||
Point p1, Point p2, std::vector<Point> &seam, bool &isHorizontal);
|
||||
|
||||
bool getSeamTips(int comp1, int comp2, Point &p1, Point &p2);
|
||||
void updateLabelsUsingSeam(
|
||||
int comp1, int comp2, const std::vector<Point> &seam, bool isHorizontalSeam);
|
||||
|
||||
void computeCosts(
|
||||
const Mat &image1, const Mat &image2, Point tl1, Point tl2,
|
||||
int comp, Mat_<float> &costV, Mat_<float> &costH);
|
||||
CostFunction costFunc_;
|
||||
|
||||
bool estimateSeam(
|
||||
const Mat &image1, const Mat &image2, Point tl1, Point tl2, int comp,
|
||||
Point p1, Point p2, std::vector<Point> &seam, bool &isHorizontal);
|
||||
// processing images pair data
|
||||
Point unionTl_, unionBr_;
|
||||
Size unionSize_;
|
||||
Mat_<uchar> mask1_, mask2_;
|
||||
Mat_<uchar> contour1mask_, contour2mask_;
|
||||
Mat_<float> gradx1_, grady1_;
|
||||
Mat_<float> gradx2_, grady2_;
|
||||
|
||||
void updateLabelsUsingSeam(
|
||||
int comp1, int comp2, const std::vector<Point> &seam, bool isHorizontalSeam);
|
||||
|
||||
CostFunction costFunc_;
|
||||
|
||||
// processing images pair data
|
||||
Point unionTl_, unionBr_;
|
||||
Size unionSize_;
|
||||
Mat_ <uchar> mask1_, mask2_;
|
||||
Mat_ <uchar> contour1mask_, contour2mask_;
|
||||
Mat_<float> gradx1_, grady1_;
|
||||
Mat_<float> gradx2_, grady2_;
|
||||
|
||||
// components data
|
||||
int ncomps_;
|
||||
Mat_<int> labels_;
|
||||
std::vector<ComponentState> states_;
|
||||
std::vector<Point> tls_, brs_;
|
||||
std::vector<std::vector<Point> > contours_;
|
||||
std::set<std::pair<int, int> > edges_;
|
||||
};
|
||||
// components data
|
||||
int ncomps_;
|
||||
Mat_<int> labels_;
|
||||
std::vector<ComponentState> states_;
|
||||
std::vector<Point> tls_, brs_;
|
||||
std::vector<std::vector<Point> > contours_;
|
||||
std::set<std::pair<int, int> > edges_;
|
||||
};
|
||||
|
||||
/** @brief Base class for all minimum graph-cut-based seam estimators.
|
||||
*/
|
||||
class CV_EXPORTS GraphCutSeamFinderBase {
|
||||
public:
|
||||
enum CostType {
|
||||
COST_COLOR, COST_COLOR_GRAD
|
||||
};
|
||||
};
|
||||
class CV_EXPORTS GraphCutSeamFinderBase
|
||||
{
|
||||
public:
|
||||
enum CostType { COST_COLOR, COST_COLOR_GRAD };
|
||||
};
|
||||
|
||||
/** @brief Minimum graph cut-based seam estimator. See details in @cite V03 .
|
||||
*/
|
||||
class CV_EXPORTS_W GraphCutSeamFinder : public GraphCutSeamFinderBase, public SeamFinder {
|
||||
public:
|
||||
GraphCutSeamFinder(int cost_type = COST_COLOR_GRAD, float terminal_cost = 10000.f,
|
||||
float bad_region_penalty = 1000.f);
|
||||
class CV_EXPORTS_W GraphCutSeamFinder : public GraphCutSeamFinderBase, public SeamFinder
|
||||
{
|
||||
public:
|
||||
GraphCutSeamFinder(int cost_type = COST_COLOR_GRAD, float terminal_cost = 10000.f,
|
||||
float bad_region_penalty = 1000.f);
|
||||
CV_WRAP GraphCutSeamFinder(String cost_type,float terminal_cost = 10000.f,
|
||||
float bad_region_penalty = 1000.f);
|
||||
|
||||
CV_WRAP GraphCutSeamFinder(String cost_type, float terminal_cost = 10000.f,
|
||||
float bad_region_penalty = 1000.f);
|
||||
~GraphCutSeamFinder();
|
||||
|
||||
~GraphCutSeamFinder();
|
||||
CV_WRAP void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
std::vector<UMat> &masks) CV_OVERRIDE;
|
||||
|
||||
CV_WRAP void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
std::vector<UMat> &masks) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
// To avoid GCGraph dependency
|
||||
class Impl;
|
||||
|
||||
Ptr <PairwiseSeamFinder> impl_;
|
||||
};
|
||||
private:
|
||||
// To avoid GCGraph dependency
|
||||
class Impl;
|
||||
Ptr<PairwiseSeamFinder> impl_;
|
||||
};
|
||||
|
||||
|
||||
#ifdef HAVE_OPENCV_CUDALEGACY
|
||||
class CV_EXPORTS GraphCutSeamFinderGpu : public GraphCutSeamFinderBase, public PairwiseSeamFinder
|
||||
{
|
||||
public:
|
||||
GraphCutSeamFinderGpu(int cost_type = COST_COLOR_GRAD, float terminal_cost = 10000.f,
|
||||
float bad_region_penalty = 1000.f)
|
||||
: cost_type_(cost_type), terminal_cost_(terminal_cost),
|
||||
bad_region_penalty_(bad_region_penalty) {}
|
||||
class CV_EXPORTS GraphCutSeamFinderGpu : public GraphCutSeamFinderBase, public PairwiseSeamFinder
|
||||
{
|
||||
public:
|
||||
GraphCutSeamFinderGpu(int cost_type = COST_COLOR_GRAD, float terminal_cost = 10000.f,
|
||||
float bad_region_penalty = 1000.f)
|
||||
: cost_type_(cost_type), terminal_cost_(terminal_cost),
|
||||
bad_region_penalty_(bad_region_penalty) {}
|
||||
|
||||
void find(const std::vector<cv::UMat> &src, const std::vector<cv::Point> &corners,
|
||||
std::vector<cv::UMat> &masks) CV_OVERRIDE;
|
||||
void findInPair(size_t first, size_t second, Rect roi) CV_OVERRIDE;
|
||||
void find(const std::vector<cv::UMat> &src, const std::vector<cv::Point> &corners,
|
||||
std::vector<cv::UMat> &masks) CV_OVERRIDE;
|
||||
void findInPair(size_t first, size_t second, Rect roi) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void setGraphWeightsColor(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &mask1, const cv::Mat &mask2,
|
||||
cv::Mat &terminals, cv::Mat &leftT, cv::Mat &rightT, cv::Mat &top, cv::Mat &bottom);
|
||||
void setGraphWeightsColorGrad(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &dx1, const cv::Mat &dx2,
|
||||
const cv::Mat &dy1, const cv::Mat &dy2, const cv::Mat &mask1, const cv::Mat &mask2,
|
||||
cv::Mat &terminals, cv::Mat &leftT, cv::Mat &rightT, cv::Mat &top, cv::Mat &bottom);
|
||||
std::vector<Mat> dx_, dy_;
|
||||
int cost_type_;
|
||||
float terminal_cost_;
|
||||
float bad_region_penalty_;
|
||||
};
|
||||
private:
|
||||
void setGraphWeightsColor(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &mask1, const cv::Mat &mask2,
|
||||
cv::Mat &terminals, cv::Mat &leftT, cv::Mat &rightT, cv::Mat &top, cv::Mat &bottom);
|
||||
void setGraphWeightsColorGrad(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &dx1, const cv::Mat &dx2,
|
||||
const cv::Mat &dy1, const cv::Mat &dy2, const cv::Mat &mask1, const cv::Mat &mask2,
|
||||
cv::Mat &terminals, cv::Mat &leftT, cv::Mat &rightT, cv::Mat &top, cv::Mat &bottom);
|
||||
std::vector<Mat> dx_, dy_;
|
||||
int cost_type_;
|
||||
float terminal_cost_;
|
||||
float bad_region_penalty_;
|
||||
};
|
||||
#endif
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
#endif // OPENCV_STITCHING_SEAM_FINDERS_HPP
|
||||
|
||||
@@ -47,45 +47,41 @@
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching
|
||||
//! @{
|
||||
|
||||
// Base Timelapser class, takes a sequence of images, applies appropriate shift, stores result in dst_.
|
||||
|
||||
class CV_EXPORTS_W Timelapser
|
||||
{
|
||||
public:
|
||||
class CV_EXPORTS_W Timelapser
|
||||
{
|
||||
public:
|
||||
|
||||
enum { AS_IS, CROP };
|
||||
enum {AS_IS, CROP};
|
||||
|
||||
virtual ~Timelapser() {}
|
||||
virtual ~Timelapser() {}
|
||||
|
||||
CV_WRAP static Ptr<Timelapser> createDefault(int type);
|
||||
CV_WRAP static Ptr<Timelapser> createDefault(int type);
|
||||
|
||||
CV_WRAP virtual void initialize(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
CV_WRAP virtual void process(InputArray img, InputArray mask, Point tl);
|
||||
CV_WRAP virtual const UMat& getDst() { return dst_; }
|
||||
CV_WRAP virtual void initialize(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
CV_WRAP virtual void process(InputArray img, InputArray mask, Point tl);
|
||||
CV_WRAP virtual const UMat& getDst() {return dst_;}
|
||||
|
||||
protected:
|
||||
protected:
|
||||
|
||||
virtual bool test_point(Point pt);
|
||||
virtual bool test_point(Point pt);
|
||||
|
||||
UMat dst_;
|
||||
Rect dst_roi_;
|
||||
};
|
||||
UMat dst_;
|
||||
Rect dst_roi_;
|
||||
};
|
||||
|
||||
|
||||
class CV_EXPORTS_W TimelapserCrop
|
||||
|
||||
: public Timelapser {
|
||||
public:
|
||||
|
||||
virtual void initialize(const std::vector <Point> &corners, const std::vector <Size> &sizes)
|
||||
|
||||
CV_OVERRIDE;
|
||||
};
|
||||
class CV_EXPORTS_W TimelapserCrop : public Timelapser
|
||||
{
|
||||
public:
|
||||
virtual void initialize(const std::vector<Point> &corners, const std::vector<Size> &sizes) CV_OVERRIDE;
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
|
||||
@@ -47,89 +47,73 @@
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching
|
||||
//! @{
|
||||
|
||||
class CV_EXPORTS DisjointSets {
|
||||
public:
|
||||
DisjointSets(int elem_count = 0) { createOneElemSets(elem_count); }
|
||||
class CV_EXPORTS DisjointSets
|
||||
{
|
||||
public:
|
||||
DisjointSets(int elem_count = 0) { createOneElemSets(elem_count); }
|
||||
|
||||
void createOneElemSets(int elem_count);
|
||||
void createOneElemSets(int elem_count);
|
||||
int findSetByElem(int elem);
|
||||
int mergeSets(int set1, int set2);
|
||||
|
||||
int findSetByElem(int elem);
|
||||
std::vector<int> parent;
|
||||
std::vector<int> size;
|
||||
|
||||
int mergeSets(int set1, int set2);
|
||||
|
||||
std::vector<int> parent;
|
||||
std::vector<int> size;
|
||||
|
||||
private:
|
||||
std::vector<int> rank_;
|
||||
};
|
||||
private:
|
||||
std::vector<int> rank_;
|
||||
};
|
||||
|
||||
|
||||
struct CV_EXPORTS GraphEdge {
|
||||
GraphEdge(int from, int to, float weight);
|
||||
struct CV_EXPORTS GraphEdge
|
||||
{
|
||||
GraphEdge(int from, int to, float weight);
|
||||
bool operator <(const GraphEdge& other) const { return weight < other.weight; }
|
||||
bool operator >(const GraphEdge& other) const { return weight > other.weight; }
|
||||
|
||||
bool operator<(const GraphEdge &other) const { return weight < other.weight; }
|
||||
int from, to;
|
||||
float weight;
|
||||
};
|
||||
|
||||
bool operator>(const GraphEdge &other) const { return weight > other.weight; }
|
||||
|
||||
int from, to;
|
||||
float weight;
|
||||
};
|
||||
|
||||
inline GraphEdge::GraphEdge(int _from, int _to, float _weight) : from(_from), to(_to),
|
||||
weight(_weight) {}
|
||||
inline GraphEdge::GraphEdge(int _from, int _to, float _weight) : from(_from), to(_to), weight(_weight) {}
|
||||
|
||||
|
||||
class CV_EXPORTS Graph {
|
||||
public:
|
||||
Graph(int num_vertices = 0) { create(num_vertices); }
|
||||
class CV_EXPORTS Graph
|
||||
{
|
||||
public:
|
||||
Graph(int num_vertices = 0) { create(num_vertices); }
|
||||
void create(int num_vertices) { edges_.assign(num_vertices, std::list<GraphEdge>()); }
|
||||
int numVertices() const { return static_cast<int>(edges_.size()); }
|
||||
void addEdge(int from, int to, float weight);
|
||||
template <typename B> B forEach(B body) const;
|
||||
template <typename B> B walkBreadthFirst(int from, B body) const;
|
||||
|
||||
void create(int num_vertices) { edges_.assign(num_vertices, std::list<GraphEdge>()); }
|
||||
|
||||
int numVertices() const { return static_cast<int>(edges_.size()); }
|
||||
|
||||
void addEdge(int from, int to, float weight);
|
||||
|
||||
template<typename B>
|
||||
B forEach(B body) const;
|
||||
|
||||
template<typename B>
|
||||
B walkBreadthFirst(int from, B body) const;
|
||||
|
||||
private:
|
||||
std::vector<std::list<GraphEdge> > edges_;
|
||||
};
|
||||
private:
|
||||
std::vector< std::list<GraphEdge> > edges_;
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Auxiliary functions
|
||||
|
||||
CV_EXPORTS_W bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi);
|
||||
|
||||
CV_EXPORTS_W Rect
|
||||
resultRoi(const std::vector<Point> &corners, const std::vector<UMat> &images);
|
||||
|
||||
CV_EXPORTS_W Rect
|
||||
resultRoi(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
|
||||
CV_EXPORTS_W Rect
|
||||
resultRoiIntersection(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
|
||||
CV_EXPORTS_W Point resultTl(const std::vector<Point> &corners);
|
||||
CV_EXPORTS_W bool overlapRoi(Point tl1, Point tl2, Size sz1, Size sz2, Rect &roi);
|
||||
CV_EXPORTS_W Rect resultRoi(const std::vector<Point> &corners, const std::vector<UMat> &images);
|
||||
CV_EXPORTS_W Rect resultRoi(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
CV_EXPORTS_W Rect resultRoiIntersection(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
CV_EXPORTS_W Point resultTl(const std::vector<Point> &corners);
|
||||
|
||||
// Returns random 'count' element subset of the {0,1,...,size-1} set
|
||||
CV_EXPORTS_W void selectRandomSubset(int count, int size, std::vector<int> &subset);
|
||||
CV_EXPORTS_W void selectRandomSubset(int count, int size, std::vector<int> &subset);
|
||||
|
||||
CV_EXPORTS_W int &stitchingLogLevel();
|
||||
CV_EXPORTS_W int& stitchingLogLevel();
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
#include "util_inl.hpp"
|
||||
|
||||
@@ -50,73 +50,80 @@
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
namespace detail {
|
||||
|
||||
template<typename B>
|
||||
B Graph::forEach(B body) const {
|
||||
for (int i = 0; i < numVertices(); ++i) {
|
||||
std::list<GraphEdge>::const_iterator edge = edges_[i].begin();
|
||||
for (; edge != edges_[i].end(); ++edge)
|
||||
body(*edge);
|
||||
template <typename B>
|
||||
B Graph::forEach(B body) const
|
||||
{
|
||||
for (int i = 0; i < numVertices(); ++i)
|
||||
{
|
||||
std::list<GraphEdge>::const_iterator edge = edges_[i].begin();
|
||||
for (; edge != edges_[i].end(); ++edge)
|
||||
body(*edge);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
template <typename B>
|
||||
B Graph::walkBreadthFirst(int from, B body) const
|
||||
{
|
||||
std::vector<bool> was(numVertices(), false);
|
||||
std::queue<int> vertices;
|
||||
|
||||
was[from] = true;
|
||||
vertices.push(from);
|
||||
|
||||
while (!vertices.empty())
|
||||
{
|
||||
int vertex = vertices.front();
|
||||
vertices.pop();
|
||||
|
||||
std::list<GraphEdge>::const_iterator edge = edges_[vertex].begin();
|
||||
for (; edge != edges_[vertex].end(); ++edge)
|
||||
{
|
||||
if (!was[edge->to])
|
||||
{
|
||||
body(*edge);
|
||||
was[edge->to] = true;
|
||||
vertices.push(edge->to);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename B>
|
||||
B Graph::walkBreadthFirst(int from, B body) const {
|
||||
std::vector<bool> was(numVertices(), false);
|
||||
std::queue<int> vertices;
|
||||
|
||||
was[from] = true;
|
||||
vertices.push(from);
|
||||
|
||||
while (!vertices.empty()) {
|
||||
int vertex = vertices.front();
|
||||
vertices.pop();
|
||||
|
||||
std::list<GraphEdge>::const_iterator edge = edges_[vertex].begin();
|
||||
for (; edge != edges_[vertex].end(); ++edge) {
|
||||
if (!was[edge->to]) {
|
||||
body(*edge);
|
||||
was[edge->to] = true;
|
||||
vertices.push(edge->to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return body;
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// Some auxiliary math functions
|
||||
|
||||
static inline
|
||||
float normL2(const Point3f &a) {
|
||||
return a.x * a.x + a.y * a.y + a.z * a.z;
|
||||
}
|
||||
static inline
|
||||
float normL2(const Point3f& a)
|
||||
{
|
||||
return a.x * a.x + a.y * a.y + a.z * a.z;
|
||||
}
|
||||
|
||||
|
||||
static inline
|
||||
float normL2(const Point3f &a, const Point3f &b) {
|
||||
return normL2(a - b);
|
||||
}
|
||||
static inline
|
||||
float normL2(const Point3f& a, const Point3f& b)
|
||||
{
|
||||
return normL2(a - b);
|
||||
}
|
||||
|
||||
|
||||
static inline
|
||||
double normL2sq(const Mat &r) {
|
||||
return r.dot(r);
|
||||
}
|
||||
static inline
|
||||
double normL2sq(const Mat &r)
|
||||
{
|
||||
return r.dot(r);
|
||||
}
|
||||
|
||||
|
||||
static inline int sqr(int x) { return x * x; }
|
||||
static inline int sqr(int x) { return x * x; }
|
||||
static inline float sqr(float x) { return x * x; }
|
||||
static inline double sqr(double x) { return x * x; }
|
||||
|
||||
static inline float sqr(float x) { return x * x; }
|
||||
|
||||
static inline double sqr(double x) { return x * x; }
|
||||
|
||||
} // namespace detail
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
//! @endcond
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -47,14 +47,13 @@
|
||||
#include <string>
|
||||
|
||||
namespace cv {
|
||||
class CV_EXPORTS_W PyRotationWarper {
|
||||
class CV_EXPORTS_W PyRotationWarper
|
||||
{
|
||||
Ptr<detail::RotationWarper> rw;
|
||||
|
||||
public:
|
||||
CV_WRAP PyRotationWarper(String type, float scale);
|
||||
|
||||
CV_WRAP PyRotationWarper() {};
|
||||
|
||||
~PyRotationWarper() {}
|
||||
|
||||
/** @brief Projects the image point.
|
||||
@@ -75,8 +74,7 @@ namespace cv {
|
||||
@param ymap Projection map for the y axis
|
||||
@return Projected image minimum bounding box
|
||||
*/
|
||||
CV_WRAP Rect
|
||||
buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap);
|
||||
CV_WRAP Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap);
|
||||
|
||||
/** @brief Projects the image.
|
||||
|
||||
@@ -88,9 +86,8 @@ namespace cv {
|
||||
@param dst Projected image
|
||||
@return Project image top-left corner
|
||||
*/
|
||||
CV_WRAP Point
|
||||
warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
|
||||
CV_OUT OutputArray dst);
|
||||
CV_WRAP Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
|
||||
CV_OUT OutputArray dst);
|
||||
|
||||
/** @brief Projects the image backward.
|
||||
|
||||
@@ -102,9 +99,8 @@ namespace cv {
|
||||
@param dst_size Backward-projected image size
|
||||
@param dst Backward-projected image
|
||||
*/
|
||||
CV_WRAP void
|
||||
warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
|
||||
Size dst_size, CV_OUT OutputArray dst);
|
||||
CV_WRAP void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
|
||||
Size dst_size, CV_OUT OutputArray dst);
|
||||
|
||||
/**
|
||||
@param src_size Source image bounding box
|
||||
@@ -115,7 +111,6 @@ namespace cv {
|
||||
CV_WRAP Rect warpRoi(Size src_size, InputArray K, InputArray R);
|
||||
|
||||
CV_WRAP float getScale() const { return 1.f; }
|
||||
|
||||
CV_WRAP void setScale(float) {}
|
||||
};
|
||||
|
||||
@@ -125,146 +120,138 @@ namespace cv {
|
||||
/** @brief Image warper factories base class.
|
||||
*/
|
||||
|
||||
class CV_EXPORTS_W WarperCreator {
|
||||
public:
|
||||
CV_WRAP virtual ~WarperCreator() {}
|
||||
|
||||
virtual Ptr<detail::RotationWarper> create(float scale) const = 0;
|
||||
};
|
||||
class CV_EXPORTS_W WarperCreator
|
||||
{
|
||||
public:
|
||||
CV_WRAP virtual ~WarperCreator() {}
|
||||
virtual Ptr<detail::RotationWarper> create(float scale) const = 0;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Plane warper factory class.
|
||||
@sa detail::PlaneWarper
|
||||
*/
|
||||
class CV_EXPORTS PlaneWarper : public WarperCreator {
|
||||
public:
|
||||
Ptr<detail::RotationWarper>
|
||||
create(float scale) const CV_OVERRIDE { return makePtr<detail::PlaneWarper>(scale); }
|
||||
};
|
||||
class CV_EXPORTS PlaneWarper : public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::PlaneWarper>(scale); }
|
||||
};
|
||||
|
||||
/** @brief Affine warper factory class.
|
||||
@sa detail::AffineWarper
|
||||
*/
|
||||
class CV_EXPORTS AffineWarper : public WarperCreator {
|
||||
public:
|
||||
Ptr<detail::RotationWarper>
|
||||
create(float scale) const CV_OVERRIDE { return makePtr<detail::AffineWarper>(scale); }
|
||||
};
|
||||
class CV_EXPORTS AffineWarper : public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::AffineWarper>(scale); }
|
||||
};
|
||||
|
||||
/** @brief Cylindrical warper factory class.
|
||||
@sa detail::CylindricalWarper
|
||||
*/
|
||||
class CV_EXPORTS CylindricalWarper : public WarperCreator {
|
||||
public:
|
||||
Ptr<detail::RotationWarper>
|
||||
create(float scale) const CV_OVERRIDE { return makePtr<detail::CylindricalWarper>(scale); }
|
||||
};
|
||||
class CV_EXPORTS CylindricalWarper: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::CylindricalWarper>(scale); }
|
||||
};
|
||||
|
||||
/** @brief Spherical warper factory class */
|
||||
class CV_EXPORTS SphericalWarper : public WarperCreator {
|
||||
public:
|
||||
Ptr<detail::RotationWarper>
|
||||
create(float scale) const CV_OVERRIDE { return makePtr<detail::SphericalWarper>(scale); }
|
||||
};
|
||||
class CV_EXPORTS SphericalWarper: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::SphericalWarper>(scale); }
|
||||
};
|
||||
|
||||
class CV_EXPORTS FisheyeWarper : public WarperCreator {
|
||||
public:
|
||||
Ptr<detail::RotationWarper>
|
||||
create(float scale) const CV_OVERRIDE { return makePtr<detail::FisheyeWarper>(scale); }
|
||||
};
|
||||
class CV_EXPORTS FisheyeWarper : public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::FisheyeWarper>(scale); }
|
||||
};
|
||||
|
||||
class CV_EXPORTS StereographicWarper : public WarperCreator {
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE {
|
||||
return makePtr<detail::StereographicWarper>(scale);
|
||||
}
|
||||
};
|
||||
class CV_EXPORTS StereographicWarper: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::StereographicWarper>(scale); }
|
||||
};
|
||||
|
||||
class CV_EXPORTS CompressedRectilinearWarper : public WarperCreator {
|
||||
float a, b;
|
||||
public:
|
||||
CompressedRectilinearWarper(float A = 1, float B = 1) {
|
||||
a = A;
|
||||
b = B;
|
||||
}
|
||||
class CV_EXPORTS CompressedRectilinearWarper: public WarperCreator
|
||||
{
|
||||
float a, b;
|
||||
public:
|
||||
CompressedRectilinearWarper(float A = 1, float B = 1)
|
||||
{
|
||||
a = A; b = B;
|
||||
}
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::CompressedRectilinearWarper>(scale, a, b); }
|
||||
};
|
||||
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE {
|
||||
return makePtr<detail::CompressedRectilinearWarper>(scale, a, b);
|
||||
}
|
||||
};
|
||||
class CV_EXPORTS CompressedRectilinearPortraitWarper: public WarperCreator
|
||||
{
|
||||
float a, b;
|
||||
public:
|
||||
CompressedRectilinearPortraitWarper(float A = 1, float B = 1)
|
||||
{
|
||||
a = A; b = B;
|
||||
}
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::CompressedRectilinearPortraitWarper>(scale, a, b); }
|
||||
};
|
||||
|
||||
class CV_EXPORTS CompressedRectilinearPortraitWarper : public WarperCreator {
|
||||
float a, b;
|
||||
public:
|
||||
CompressedRectilinearPortraitWarper(float A = 1, float B = 1) {
|
||||
a = A;
|
||||
b = B;
|
||||
}
|
||||
class CV_EXPORTS PaniniWarper: public WarperCreator
|
||||
{
|
||||
float a, b;
|
||||
public:
|
||||
PaniniWarper(float A = 1, float B = 1)
|
||||
{
|
||||
a = A; b = B;
|
||||
}
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::PaniniWarper>(scale, a, b); }
|
||||
};
|
||||
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE {
|
||||
return makePtr<detail::CompressedRectilinearPortraitWarper>(scale, a, b);
|
||||
}
|
||||
};
|
||||
class CV_EXPORTS PaniniPortraitWarper: public WarperCreator
|
||||
{
|
||||
float a, b;
|
||||
public:
|
||||
PaniniPortraitWarper(float A = 1, float B = 1)
|
||||
{
|
||||
a = A; b = B;
|
||||
}
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::PaniniPortraitWarper>(scale, a, b); }
|
||||
};
|
||||
|
||||
class CV_EXPORTS PaniniWarper : public WarperCreator {
|
||||
float a, b;
|
||||
public:
|
||||
PaniniWarper(float A = 1, float B = 1) {
|
||||
a = A;
|
||||
b = B;
|
||||
}
|
||||
class CV_EXPORTS MercatorWarper: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::MercatorWarper>(scale); }
|
||||
};
|
||||
|
||||
Ptr<detail::RotationWarper>
|
||||
create(float scale) const CV_OVERRIDE { return makePtr<detail::PaniniWarper>(scale, a, b); }
|
||||
};
|
||||
class CV_EXPORTS TransverseMercatorWarper: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::TransverseMercatorWarper>(scale); }
|
||||
};
|
||||
|
||||
class CV_EXPORTS PaniniPortraitWarper : public WarperCreator {
|
||||
float a, b;
|
||||
public:
|
||||
PaniniPortraitWarper(float A = 1, float B = 1) {
|
||||
a = A;
|
||||
b = B;
|
||||
}
|
||||
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE {
|
||||
return makePtr<detail::PaniniPortraitWarper>(scale, a, b);
|
||||
}
|
||||
};
|
||||
|
||||
class CV_EXPORTS MercatorWarper : public WarperCreator {
|
||||
public:
|
||||
Ptr<detail::RotationWarper>
|
||||
create(float scale) const CV_OVERRIDE { return makePtr<detail::MercatorWarper>(scale); }
|
||||
};
|
||||
|
||||
class CV_EXPORTS TransverseMercatorWarper : public WarperCreator {
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE {
|
||||
return makePtr<detail::TransverseMercatorWarper>(scale);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifdef HAVE_OPENCV_CUDAWARPING
|
||||
class PlaneWarperGpu: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::PlaneWarperGpu>(scale); }
|
||||
};
|
||||
class PlaneWarperGpu: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::PlaneWarperGpu>(scale); }
|
||||
};
|
||||
|
||||
|
||||
class CylindricalWarperGpu: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::CylindricalWarperGpu>(scale); }
|
||||
};
|
||||
class CylindricalWarperGpu: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::CylindricalWarperGpu>(scale); }
|
||||
};
|
||||
|
||||
|
||||
class SphericalWarperGpu: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::SphericalWarperGpu>(scale); }
|
||||
};
|
||||
class SphericalWarperGpu: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const CV_OVERRIDE { return makePtr<detail::SphericalWarperGpu>(scale); }
|
||||
};
|
||||
#endif
|
||||
|
||||
//! @} stitching_warp
|
||||
|
||||
Reference in New Issue
Block a user