Doxygen documentation: flann, photo and stitching modules
This commit is contained in:
@@ -53,8 +53,46 @@
|
||||
#include "opencv2/stitching/detail/blenders.hpp"
|
||||
#include "opencv2/stitching/detail/camera.hpp"
|
||||
|
||||
/**
|
||||
@defgroup stitching Images stitching
|
||||
|
||||
This figure illustrates the stitching module pipeline implemented in the Stitcher class. Using that
|
||||
class it's possible to configure/remove some steps, i.e. adjust the stitching pipeline according to
|
||||
the particular needs. All building blocks from the pipeline are available in the detail namespace,
|
||||
one can combine and use them separately.
|
||||
|
||||
The implemented stitching pipeline is very similar to the one proposed in @cite BL07.
|
||||
|
||||

|
||||
|
||||
@{
|
||||
@defgroup stitching_match Features Finding and Images Matching
|
||||
@defgroup stitching_rotation Rotation Estimation
|
||||
@defgroup stitching_autocalib Autocalibration
|
||||
@defgroup stitching_warp Images Warping
|
||||
@defgroup stitching_seam Seam Estimation
|
||||
@defgroup stitching_exposure Exposure Compensation
|
||||
@defgroup stitching_blend Image Blenders
|
||||
@}
|
||||
*/
|
||||
|
||||
namespace cv {
|
||||
|
||||
//! @addtogroup stitching
|
||||
//! @{
|
||||
|
||||
/** @brief High level image stitcher.
|
||||
|
||||
It's possible to use this class without being aware of the entire stitching pipeline. However, to
|
||||
be able to achieve higher stitching stability and quality of the final images at least being
|
||||
familiar with the theory is recommended.
|
||||
|
||||
@note
|
||||
- A basic example on image stitching can be found at
|
||||
opencv\_source\_code/samples/cpp/stitching.cpp
|
||||
- A detailed example on image stitching can be found at
|
||||
opencv\_source\_code/samples/cpp/stitching\_detailed.cpp
|
||||
*/
|
||||
class CV_EXPORTS_W Stitcher
|
||||
{
|
||||
public:
|
||||
@@ -68,7 +106,11 @@ public:
|
||||
};
|
||||
|
||||
// Stitcher() {}
|
||||
// Creates stitcher with default parameters
|
||||
/** @brief Creates a stitcher with the default parameters.
|
||||
|
||||
@param try\_use\_gpu Flag indicating whether GPU should be used whenever it's possible.
|
||||
@return Stitcher class instance.
|
||||
*/
|
||||
static Stitcher createDefault(bool try_use_gpu = false);
|
||||
|
||||
CV_WRAP double registrationResol() const { return registr_resol_; }
|
||||
@@ -128,13 +170,43 @@ public:
|
||||
const Ptr<detail::Blender> blender() const { return blender_; }
|
||||
void setBlender(Ptr<detail::Blender> b) { blender_ = b; }
|
||||
|
||||
/** @overload */
|
||||
CV_WRAP Status estimateTransform(InputArrayOfArrays images);
|
||||
/** @brief These functions try to match the given images and to estimate rotations of each camera.
|
||||
|
||||
@note Use the functions only if you're aware of the stitching pipeline, otherwise use
|
||||
Stitcher::stitch.
|
||||
|
||||
@param images Input images.
|
||||
@param rois Region of interest rectangles.
|
||||
@return Status code.
|
||||
*/
|
||||
Status estimateTransform(InputArrayOfArrays images, const std::vector<std::vector<Rect> > &rois);
|
||||
|
||||
/** @overload */
|
||||
CV_WRAP Status composePanorama(OutputArray pano);
|
||||
/** @brief These functions try to compose the given images (or images stored internally from the other function
|
||||
calls) into the final pano under the assumption that the image transformations were estimated
|
||||
before.
|
||||
|
||||
@note Use the functions only if you're aware of the stitching pipeline, otherwise use
|
||||
Stitcher::stitch.
|
||||
|
||||
@param images Input images.
|
||||
@param pano Final pano.
|
||||
@return Status code.
|
||||
*/
|
||||
Status composePanorama(InputArrayOfArrays images, OutputArray pano);
|
||||
|
||||
/** @overload */
|
||||
CV_WRAP Status stitch(InputArrayOfArrays images, OutputArray pano);
|
||||
/** @brief These functions try to stitch the given images.
|
||||
|
||||
@param images Input images.
|
||||
@param rois Region of interest rectangles.
|
||||
@param pano Final pano.
|
||||
@return Status code.
|
||||
*/
|
||||
Status stitch(InputArrayOfArrays images, const std::vector<std::vector<Rect> > &rois, OutputArray pano);
|
||||
|
||||
std::vector<int> component() const { return indices_; }
|
||||
@@ -178,6 +250,8 @@ private:
|
||||
|
||||
CV_EXPORTS_W Ptr<Stitcher> createStitcher(bool try_use_gpu = false);
|
||||
|
||||
//! @} stitching
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // __OPENCV_STITCHING_STITCHER_HPP__
|
||||
|
@@ -49,16 +49,37 @@
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
// See "Construction of Panoramic Image Mosaics with Global and Local Alignment"
|
||||
// by Heung-Yeung Shum and Richard Szeliski.
|
||||
//! @addtogroup stitching_autocalib
|
||||
//! @{
|
||||
|
||||
/** @brief Tries to estimate focal lengths from the given homography under the assumption that the camera
|
||||
undergoes rotations around its centre only.
|
||||
|
||||
@param H Homography.
|
||||
@param f0 Estimated focal length along X axis.
|
||||
@param f1 Estimated focal length along Y axis.
|
||||
@param f0\_ok True, if f0 was estimated successfully, false otherwise.
|
||||
@param f1\_ok True, if f1 was estimated successfully, false otherwise.
|
||||
|
||||
See "Construction of Panoramic Image Mosaics with Global and Local Alignment"
|
||||
by Heung-Yeung Shum and Richard Szeliski.
|
||||
*/
|
||||
void CV_EXPORTS focalsFromHomography(const Mat &H, double &f0, double &f1, bool &f0_ok, bool &f1_ok);
|
||||
|
||||
/** @brief Estimates focal lengths for each given camera.
|
||||
|
||||
@param features Features of images.
|
||||
@param pairwise\_matches Matches between all image pairs.
|
||||
@param focals Estimated focal lengths for each camera.
|
||||
*/
|
||||
void CV_EXPORTS estimateFocal(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
std::vector<double> &focals);
|
||||
|
||||
bool CV_EXPORTS calibrateRotatingCamera(const std::vector<Mat> &Hs, Mat &K);
|
||||
|
||||
//! @} stitching_autocalib
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
|
@@ -48,8 +48,13 @@
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_blend
|
||||
//! @{
|
||||
|
||||
// Simple blender which puts one image over another
|
||||
/** @brief Base class for all blenders.
|
||||
|
||||
Simple blender which puts one image over another
|
||||
*/
|
||||
class CV_EXPORTS Blender
|
||||
{
|
||||
public:
|
||||
@@ -58,9 +63,26 @@ public:
|
||||
enum { NO, FEATHER, MULTI_BAND };
|
||||
static Ptr<Blender> createDefault(int type, bool try_gpu = false);
|
||||
|
||||
/** @brief Prepares the blender for blending.
|
||||
|
||||
@param corners Source images top-left corners
|
||||
@param sizes Source image sizes
|
||||
*/
|
||||
void prepare(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
/** @overload */
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
virtual void blend(InputOutputArray dst, InputOutputArray dst_mask);
|
||||
|
||||
protected:
|
||||
@@ -68,7 +90,8 @@ protected:
|
||||
Rect dst_roi_;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Simple blender which mixes images at its borders.
|
||||
*/
|
||||
class CV_EXPORTS FeatherBlender : public Blender
|
||||
{
|
||||
public:
|
||||
@@ -81,8 +104,8 @@ public:
|
||||
void feed(InputArray img, InputArray mask, Point tl);
|
||||
void blend(InputOutputArray dst, InputOutputArray dst_mask);
|
||||
|
||||
// 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.
|
||||
//! 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.
|
||||
Rect createWeightMaps(const std::vector<UMat> &masks, const std::vector<Point> &corners,
|
||||
std::vector<UMat> &weight_maps);
|
||||
|
||||
@@ -94,7 +117,8 @@ private:
|
||||
|
||||
inline FeatherBlender::FeatherBlender(float _sharpness) { setSharpness(_sharpness); }
|
||||
|
||||
|
||||
/** @brief Blender which uses multi-band blending algorithm (see @cite BA83).
|
||||
*/
|
||||
class CV_EXPORTS MultiBandBlender : public Blender
|
||||
{
|
||||
public:
|
||||
@@ -131,6 +155,8 @@ void CV_EXPORTS createLaplacePyrGpu(InputArray img, int num_levels, std::vector<
|
||||
void CV_EXPORTS restoreImageFromLaplacePyr(std::vector<UMat>& pyr);
|
||||
void CV_EXPORTS restoreImageFromLaplacePyrGpu(std::vector<UMat>& pyr);
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
|
@@ -48,6 +48,13 @@
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching
|
||||
//! @{
|
||||
|
||||
/** @brief Describes camera parameters.
|
||||
|
||||
@note Translation is assumed to be zero during the whole stitching pipeline. :
|
||||
*/
|
||||
struct CV_EXPORTS CameraParams
|
||||
{
|
||||
CameraParams();
|
||||
@@ -63,6 +70,8 @@ struct CV_EXPORTS CameraParams
|
||||
Mat t; // Translation
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
|
@@ -48,6 +48,11 @@
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_exposure
|
||||
//! @{
|
||||
|
||||
/** @brief Base class for all exposure compensators.
|
||||
*/
|
||||
class CV_EXPORTS ExposureCompensator
|
||||
{
|
||||
public:
|
||||
@@ -56,14 +61,29 @@ public:
|
||||
enum { NO, GAIN, GAIN_BLOCKS };
|
||||
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)
|
||||
*/
|
||||
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
|
||||
*/
|
||||
virtual void apply(int index, Point corner, InputOutputArray image, InputArray mask) = 0;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Stub exposure compensator which does nothing.
|
||||
*/
|
||||
class CV_EXPORTS NoExposureCompensator : public ExposureCompensator
|
||||
{
|
||||
public:
|
||||
@@ -72,7 +92,9 @@ public:
|
||||
void apply(int /*index*/, Point /*corner*/, InputOutputArray /*image*/, InputArray /*mask*/) { }
|
||||
};
|
||||
|
||||
|
||||
/** @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 GainCompensator : public ExposureCompensator
|
||||
{
|
||||
public:
|
||||
@@ -85,7 +107,9 @@ private:
|
||||
Mat_<double> gains_;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image block
|
||||
intensities, see @cite UES01 for details.
|
||||
*/
|
||||
class CV_EXPORTS BlocksGainCompensator : public ExposureCompensator
|
||||
{
|
||||
public:
|
||||
@@ -100,6 +124,8 @@ private:
|
||||
std::vector<UMat> gain_maps_;
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
|
@@ -55,6 +55,10 @@
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_match
|
||||
//! @{
|
||||
|
||||
/** @brief Structure containing image keypoints and descriptors. */
|
||||
struct CV_EXPORTS ImageFeatures
|
||||
{
|
||||
int img_idx;
|
||||
@@ -63,20 +67,40 @@ struct CV_EXPORTS ImageFeatures
|
||||
UMat descriptors;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Feature finders base class */
|
||||
class CV_EXPORTS FeaturesFinder
|
||||
{
|
||||
public:
|
||||
virtual ~FeaturesFinder() {}
|
||||
/** @overload */
|
||||
void operator ()(InputArray image, ImageFeatures &features);
|
||||
/** @brief Finds features in the given image.
|
||||
|
||||
@param image Source image
|
||||
@param features Found features
|
||||
@param rois Regions of interest
|
||||
|
||||
@sa detail::ImageFeatures, Rect\_
|
||||
*/
|
||||
void operator ()(InputArray image, ImageFeatures &features, const std::vector<cv::Rect> &rois);
|
||||
/** @brief Frees unused memory allocated before if there is any. */
|
||||
virtual void collectGarbage() {}
|
||||
|
||||
protected:
|
||||
/** @brief This method must implement features finding logic in order to make the wrappers
|
||||
detail::FeaturesFinder::operator()\_ work.
|
||||
|
||||
@param image Source image
|
||||
@param features Found features
|
||||
|
||||
@sa detail::ImageFeatures */
|
||||
virtual void find(InputArray image, ImageFeatures &features) = 0;
|
||||
};
|
||||
|
||||
/** @brief SURF features finder.
|
||||
|
||||
@sa detail::FeaturesFinder, SURF
|
||||
*/
|
||||
class CV_EXPORTS SurfFeaturesFinder : public FeaturesFinder
|
||||
{
|
||||
public:
|
||||
@@ -91,6 +115,10 @@ private:
|
||||
Ptr<Feature2D> surf;
|
||||
};
|
||||
|
||||
/** @brief ORB features finder. :
|
||||
|
||||
@sa detail::FeaturesFinder, ORB
|
||||
*/
|
||||
class CV_EXPORTS OrbFeaturesFinder : public FeaturesFinder
|
||||
{
|
||||
public:
|
||||
@@ -126,50 +154,92 @@ private:
|
||||
};
|
||||
#endif
|
||||
|
||||
/** @brief Structure containing information about matches between two images.
|
||||
|
||||
It's assumed that there is a homography between those images.
|
||||
*/
|
||||
struct CV_EXPORTS MatchesInfo
|
||||
{
|
||||
MatchesInfo();
|
||||
MatchesInfo(const MatchesInfo &other);
|
||||
const MatchesInfo& operator =(const MatchesInfo &other);
|
||||
|
||||
int src_img_idx, dst_img_idx; // Images indices (optional)
|
||||
int src_img_idx, dst_img_idx; //!< Images indices (optional)
|
||||
std::vector<DMatch> matches;
|
||||
std::vector<uchar> inliers_mask; // Geometrically consistent matches mask
|
||||
int num_inliers; // Number of geometrically consistent matches
|
||||
Mat H; // Estimated homography
|
||||
double confidence; // Confidence two images are from the same panorama
|
||||
std::vector<uchar> inliers_mask; //!< Geometrically consistent matches mask
|
||||
int num_inliers; //!< Number of geometrically consistent matches
|
||||
Mat H; //!< Estimated homography
|
||||
double confidence; //!< Confidence two images are from the same panorama
|
||||
};
|
||||
|
||||
|
||||
/** @brief Feature matchers base class. */
|
||||
class CV_EXPORTS FeaturesMatcher
|
||||
{
|
||||
public:
|
||||
virtual ~FeaturesMatcher() {}
|
||||
|
||||
/** @overload
|
||||
@param features1 First image features
|
||||
@param features2 Second image features
|
||||
@param matches\_info Found matches
|
||||
*/
|
||||
void operator ()(const ImageFeatures &features1, const ImageFeatures &features2,
|
||||
MatchesInfo& matches_info) { match(features1, features2, matches_info); }
|
||||
|
||||
/** @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
|
||||
|
||||
The function is parallelized with the TBB library.
|
||||
|
||||
@sa detail::MatchesInfo
|
||||
*/
|
||||
void operator ()(const std::vector<ImageFeatures> &features, std::vector<MatchesInfo> &pairwise_matches,
|
||||
const cv::UMat &mask = cv::UMat());
|
||||
|
||||
/** @return True, if it's possible to use the same matcher instance in parallel, false otherwise
|
||||
*/
|
||||
bool isThreadSafe() const { return is_thread_safe_; }
|
||||
|
||||
/** @brief Frees unused memory allocated before if there is any.
|
||||
*/
|
||||
virtual void collectGarbage() {}
|
||||
|
||||
protected:
|
||||
FeaturesMatcher(bool is_thread_safe = false) : is_thread_safe_(is_thread_safe) {}
|
||||
|
||||
/** @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_;
|
||||
};
|
||||
|
||||
/** @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 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
|
||||
*/
|
||||
BestOf2NearestMatcher(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6,
|
||||
int num_matches_thresh2 = 6);
|
||||
|
||||
@@ -197,6 +267,8 @@ protected:
|
||||
int range_width_;
|
||||
};
|
||||
|
||||
//! @} stitching_match
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
|
@@ -51,23 +51,50 @@
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_rotation
|
||||
//! @{
|
||||
|
||||
/** @brief Rotation estimator base class.
|
||||
|
||||
It takes features of all images, pairwise matches between all images and estimates rotations of all
|
||||
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 Estimator
|
||||
{
|
||||
public:
|
||||
virtual ~Estimator() {}
|
||||
|
||||
/** @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
|
||||
*/
|
||||
bool operator ()(const std::vector<ImageFeatures> &features,
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
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.
|
||||
|
||||
@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,
|
||||
std::vector<CameraParams> &cameras) = 0;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Homography based rotation estimator.
|
||||
*/
|
||||
class CV_EXPORTS HomographyBasedEstimator : public Estimator
|
||||
{
|
||||
public:
|
||||
@@ -82,7 +109,8 @@ private:
|
||||
bool is_focals_estimated_;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Base class for all camera parameters refinement methods.
|
||||
*/
|
||||
class CV_EXPORTS BundleAdjusterBase : public Estimator
|
||||
{
|
||||
public:
|
||||
@@ -100,6 +128,11 @@ public:
|
||||
void setTermCriteria(const TermCriteria& term_criteria) { term_criteria_ = term_criteria; }
|
||||
|
||||
protected:
|
||||
/** @brief Construct a bundle adjuster base instance.
|
||||
|
||||
@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_params_per_cam_(num_params_per_cam),
|
||||
num_errs_per_measurement_(num_errs_per_measurement)
|
||||
@@ -114,9 +147,26 @@ protected:
|
||||
const std::vector<MatchesInfo> &pairwise_matches,
|
||||
std::vector<CameraParams> &cameras);
|
||||
|
||||
/** @brief Sets initial camera parameter to refine.
|
||||
|
||||
@param cameras Camera parameters
|
||||
*/
|
||||
virtual void setUpInitialCameraParams(const std::vector<CameraParams> &cameras) = 0;
|
||||
/** @brief Gets the refined camera parameters.
|
||||
|
||||
@param cameras Refined camera parameters
|
||||
*/
|
||||
virtual void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const = 0;
|
||||
/** @brief Calculates error vector.
|
||||
|
||||
@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 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;
|
||||
|
||||
// 3x3 8U mask, where 0 means don't refine respective parameter, != 0 means refine
|
||||
@@ -145,9 +195,12 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
// Minimizes reprojection error.
|
||||
// It can estimate focal length, aspect ratio, principal point.
|
||||
// You can affect only on them via the refinement mask.
|
||||
/** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the reprojection
|
||||
error squares
|
||||
|
||||
It can estimate focal length, aspect ratio, principal point.
|
||||
You can affect only on them via the refinement mask.
|
||||
*/
|
||||
class CV_EXPORTS BundleAdjusterReproj : public BundleAdjusterBase
|
||||
{
|
||||
public:
|
||||
@@ -163,8 +216,11 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// Minimizes sun of ray-to-ray distances.
|
||||
// It can estimate focal length. It ignores the refinement mask for now.
|
||||
/** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the distances
|
||||
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 BundleAdjusterRay : public BundleAdjusterBase
|
||||
{
|
||||
public:
|
||||
@@ -186,6 +242,11 @@ enum WaveCorrectKind
|
||||
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 waveCorrect(std::vector<Mat> &rmats, WaveCorrectKind kind);
|
||||
|
||||
|
||||
@@ -205,6 +266,8 @@ 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 cv
|
||||
|
||||
|
@@ -50,22 +50,35 @@
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_seam
|
||||
//! @{
|
||||
|
||||
/** @brief Base class for a seam estimator.
|
||||
*/
|
||||
class CV_EXPORTS SeamFinder
|
||||
{
|
||||
public:
|
||||
virtual ~SeamFinder() {}
|
||||
/** @brief Estimates seams.
|
||||
|
||||
@param src Source images
|
||||
@param corners Source image top-left corners
|
||||
@param masks Source image masks to update
|
||||
*/
|
||||
virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
|
||||
std::vector<UMat> &masks) = 0;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Stub seam estimator which does nothing.
|
||||
*/
|
||||
class CV_EXPORTS NoSeamFinder : public SeamFinder
|
||||
{
|
||||
public:
|
||||
void find(const std::vector<UMat>&, const std::vector<Point>&, std::vector<UMat>&) {}
|
||||
};
|
||||
|
||||
|
||||
/** @brief Base class for all pairwise seam estimators.
|
||||
*/
|
||||
class CV_EXPORTS PairwiseSeamFinder : public SeamFinder
|
||||
{
|
||||
public:
|
||||
@@ -74,6 +87,12 @@ public:
|
||||
|
||||
protected:
|
||||
void run();
|
||||
/** @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;
|
||||
|
||||
std::vector<UMat> images_;
|
||||
@@ -82,7 +101,8 @@ protected:
|
||||
std::vector<UMat> masks_;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Voronoi diagram-based seam estimator.
|
||||
*/
|
||||
class CV_EXPORTS VoronoiSeamFinder : public PairwiseSeamFinder
|
||||
{
|
||||
public:
|
||||
@@ -201,14 +221,16 @@ private:
|
||||
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 };
|
||||
};
|
||||
|
||||
|
||||
/** @brief Minimum graph cut-based seam estimator. See details in @cite V03.
|
||||
*/
|
||||
class CV_EXPORTS GraphCutSeamFinder : public GraphCutSeamFinderBase, public SeamFinder
|
||||
{
|
||||
public:
|
||||
@@ -253,6 +275,8 @@ private:
|
||||
};
|
||||
#endif
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
|
@@ -49,6 +49,9 @@
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching
|
||||
//! @{
|
||||
|
||||
// Base Timelapser class, takes a sequence of images, applies appropriate shift, stores result in dst_.
|
||||
|
||||
class CV_EXPORTS Timelapser
|
||||
@@ -80,6 +83,8 @@ public:
|
||||
virtual void initialize(const std::vector<Point> &corners, const std::vector<Size> &sizes);
|
||||
};
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
|
@@ -99,6 +99,9 @@
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching
|
||||
//! @{
|
||||
|
||||
class CV_EXPORTS DisjointSets
|
||||
{
|
||||
public:
|
||||
@@ -158,6 +161,8 @@ CV_EXPORTS void selectRandomSubset(int count, int size, std::vector<int> &subset
|
||||
|
||||
CV_EXPORTS int& stitchingLogLevel();
|
||||
|
||||
//! @}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
|
@@ -47,6 +47,8 @@
|
||||
#include "opencv2/core.hpp"
|
||||
#include "util.hpp" // Make your IDE see declarations
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
@@ -124,4 +126,6 @@ static inline double sqr(double x) { return x * x; }
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // __OPENCV_STITCHING_UTIL_INL_HPP__
|
||||
|
@@ -51,28 +51,76 @@
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
//! @addtogroup stitching_warp
|
||||
//! @{
|
||||
|
||||
/** @brief Rotation-only model image warper interface.
|
||||
*/
|
||||
class CV_EXPORTS RotationWarper
|
||||
{
|
||||
public:
|
||||
virtual ~RotationWarper() {}
|
||||
|
||||
/** @brief Projects the image point.
|
||||
|
||||
@param pt Source point
|
||||
@param K Camera intrinsic parameters
|
||||
@param R Camera rotation matrix
|
||||
@return Projected point
|
||||
*/
|
||||
virtual Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) = 0;
|
||||
|
||||
/** @brief Builds the projection maps according to the given camera data.
|
||||
|
||||
@param src\_size Source image size
|
||||
@param K Camera intrinsic parameters
|
||||
@param R Camera rotation matrix
|
||||
@param xmap Projection map for the x axis
|
||||
@param ymap Projection map for the y axis
|
||||
@return Projected image minimum bounding box
|
||||
*/
|
||||
virtual Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) = 0;
|
||||
|
||||
/** @brief Projects the image.
|
||||
|
||||
@param src Source image
|
||||
@param K Camera intrinsic parameters
|
||||
@param R Camera rotation matrix
|
||||
@param interp\_mode Interpolation mode
|
||||
@param border\_mode Border extrapolation mode
|
||||
@param dst Projected image
|
||||
@return Project image top-left corner
|
||||
*/
|
||||
virtual Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
|
||||
OutputArray dst) = 0;
|
||||
|
||||
/** @brief Projects the image backward.
|
||||
|
||||
@param src Projected image
|
||||
@param K Camera intrinsic parameters
|
||||
@param R Camera rotation matrix
|
||||
@param interp\_mode Interpolation mode
|
||||
@param border\_mode Border extrapolation mode
|
||||
@param dst\_size Backward-projected image size
|
||||
@param dst Backward-projected image
|
||||
*/
|
||||
virtual void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
|
||||
Size dst_size, OutputArray dst) = 0;
|
||||
|
||||
/**
|
||||
@param src\_size Source image bounding box
|
||||
@param K Camera intrinsic parameters
|
||||
@param R Camera rotation matrix
|
||||
@return Projected image minimum bounding box
|
||||
*/
|
||||
virtual Rect warpRoi(Size src_size, InputArray K, InputArray R) = 0;
|
||||
|
||||
virtual float getScale() const { return 1.f; }
|
||||
virtual void setScale(float) {}
|
||||
};
|
||||
|
||||
|
||||
/** @brief Base class for warping logic implementation.
|
||||
*/
|
||||
struct CV_EXPORTS ProjectorBase
|
||||
{
|
||||
void setCameraParams(InputArray K = Mat::eye(3, 3, CV_32F),
|
||||
@@ -87,7 +135,8 @@ struct CV_EXPORTS ProjectorBase
|
||||
float t[3];
|
||||
};
|
||||
|
||||
|
||||
/** @brief Base class for rotation-based warper using a detail::ProjectorBase\_ derived class.
|
||||
*/
|
||||
template <class P>
|
||||
class CV_EXPORTS RotationWarperBase : public RotationWarper
|
||||
{
|
||||
@@ -126,10 +175,15 @@ struct CV_EXPORTS PlaneProjector : ProjectorBase
|
||||
void mapBackward(float u, float v, float &x, float &y);
|
||||
};
|
||||
|
||||
|
||||
/** @brief Warper that maps an image onto the z = 1 plane.
|
||||
*/
|
||||
class CV_EXPORTS PlaneWarper : public RotationWarperBase<PlaneProjector>
|
||||
{
|
||||
public:
|
||||
/** @brief Construct an instance of the plane warper class.
|
||||
|
||||
@param scale Projected image scale multiplier
|
||||
*/
|
||||
PlaneWarper(float scale = 1.f) { projector_.scale = scale; }
|
||||
|
||||
Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R, InputArray T);
|
||||
@@ -154,11 +208,18 @@ struct CV_EXPORTS SphericalProjector : ProjectorBase
|
||||
};
|
||||
|
||||
|
||||
// Projects image onto unit sphere with origin at (0, 0, 0).
|
||||
// Poles are located at (0, -1, 0) and (0, 1, 0) points.
|
||||
/** @brief Warper that maps an image onto the unit sphere located at the origin.
|
||||
|
||||
Projects image onto unit sphere with origin at (0, 0, 0).
|
||||
Poles are located at (0, -1, 0) and (0, 1, 0) points.
|
||||
*/
|
||||
class CV_EXPORTS SphericalWarper : public RotationWarperBase<SphericalProjector>
|
||||
{
|
||||
public:
|
||||
/** @brief Construct an instance of the spherical warper class.
|
||||
|
||||
@param scale Projected image scale multiplier
|
||||
*/
|
||||
SphericalWarper(float scale) { projector_.scale = scale; }
|
||||
|
||||
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap);
|
||||
@@ -175,10 +236,15 @@ struct CV_EXPORTS CylindricalProjector : ProjectorBase
|
||||
};
|
||||
|
||||
|
||||
// Projects image onto x * x + z * z = 1 cylinder
|
||||
/** @brief Warper that maps an image onto the x\*x + z\*z = 1 cylinder.
|
||||
*/
|
||||
class CV_EXPORTS CylindricalWarper : public RotationWarperBase<CylindricalProjector>
|
||||
{
|
||||
public:
|
||||
/** @brief Construct an instance of the cylindrical warper class.
|
||||
|
||||
@param scale Projected image scale multiplier
|
||||
*/
|
||||
CylindricalWarper(float scale) { projector_.scale = scale; }
|
||||
|
||||
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap);
|
||||
@@ -508,6 +574,8 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
//! @} stitching_warp
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
|
@@ -47,6 +47,8 @@
|
||||
#include "warpers.hpp" // Make your IDE see declarations
|
||||
#include <limits>
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
|
||||
@@ -767,4 +769,6 @@ void PlanePortraitProjector::mapBackward(float u0, float v0, float &x, float &y)
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // __OPENCV_STITCHING_WARPERS_INL_HPP__
|
||||
|
@@ -47,6 +47,11 @@
|
||||
|
||||
namespace cv {
|
||||
|
||||
//! @addtogroup stitching_warp
|
||||
//! @{
|
||||
|
||||
/** @brief Image warper factories base class.
|
||||
*/
|
||||
class WarperCreator
|
||||
{
|
||||
public:
|
||||
@@ -54,21 +59,25 @@ public:
|
||||
virtual Ptr<detail::RotationWarper> create(float scale) const = 0;
|
||||
};
|
||||
|
||||
|
||||
/** @brief Plane warper factory class.
|
||||
@sa detail::PlaneWarper
|
||||
*/
|
||||
class PlaneWarper : public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const { return makePtr<detail::PlaneWarper>(scale); }
|
||||
};
|
||||
|
||||
|
||||
/** @brief Cylindrical warper factory class.
|
||||
@sa detail::CylindricalWarper
|
||||
*/
|
||||
class CylindricalWarper: public WarperCreator
|
||||
{
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const { return makePtr<detail::CylindricalWarper>(scale); }
|
||||
};
|
||||
|
||||
|
||||
/** @brief Spherical warper factory class */
|
||||
class SphericalWarper: public WarperCreator
|
||||
{
|
||||
public:
|
||||
@@ -167,6 +176,8 @@ public:
|
||||
};
|
||||
#endif
|
||||
|
||||
//! @} stitching_warp
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // __OPENCV_STITCHING_WARPER_CREATORS_HPP__
|
||||
|
Reference in New Issue
Block a user