init: 64 bits version of the webcam

This commit is contained in:
2026-07-13 16:31:52 +02:00
parent c0f3eeb00d
commit 07e526544d
381 changed files with 43996 additions and 9097 deletions

View File

@ -40,8 +40,8 @@
//
//M*/
#ifndef __OPENCV_STITCHING_AUTOCALIB_HPP__
#define __OPENCV_STITCHING_AUTOCALIB_HPP__
#ifndef OPENCV_STITCHING_AUTOCALIB_HPP
#define OPENCV_STITCHING_AUTOCALIB_HPP
#include "opencv2/core.hpp"
#include "matchers.hpp"
@ -83,4 +83,4 @@ bool CV_EXPORTS calibrateRotatingCamera(const std::vector<Mat> &Hs, Mat &K);
} // namespace detail
} // namespace cv
#endif // __OPENCV_STITCHING_AUTOCALIB_HPP__
#endif // OPENCV_STITCHING_AUTOCALIB_HPP

View File

@ -40,10 +40,15 @@
//
//M*/
#ifndef __OPENCV_STITCHING_BLENDERS_HPP__
#define __OPENCV_STITCHING_BLENDERS_HPP__
#ifndef OPENCV_STITCHING_BLENDERS_HPP
#define OPENCV_STITCHING_BLENDERS_HPP
#if defined(NO)
# warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.
#endif
#include "opencv2/core.hpp"
#include "opencv2/core/cuda.hpp"
namespace cv {
namespace detail {
@ -100,9 +105,9 @@ public:
float sharpness() const { return sharpness_; }
void setSharpness(float val) { sharpness_ = val; }
void prepare(Rect dst_roi);
void feed(InputArray img, InputArray mask, Point tl);
void blend(InputOutputArray dst, InputOutputArray dst_mask);
void prepare(Rect dst_roi) CV_OVERRIDE;
void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE;
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.
@ -127,9 +132,9 @@ public:
int numBands() const { return actual_num_bands_; }
void setNumBands(int val) { actual_num_bands_ = val; }
void prepare(Rect dst_roi);
void feed(InputArray img, InputArray mask, Point tl);
void blend(InputOutputArray dst, InputOutputArray dst_mask);
void prepare(Rect dst_roi) CV_OVERRIDE;
void feed(InputArray img, InputArray mask, Point tl) CV_OVERRIDE;
void blend(InputOutputArray dst, InputOutputArray dst_mask) CV_OVERRIDE;
private:
int actual_num_bands_, num_bands_;
@ -138,6 +143,22 @@ private:
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_;
#endif
};
@ -160,4 +181,4 @@ void CV_EXPORTS restoreImageFromLaplacePyrGpu(std::vector<UMat>& pyr);
} // namespace detail
} // namespace cv
#endif // __OPENCV_STITCHING_BLENDERS_HPP__
#endif // OPENCV_STITCHING_BLENDERS_HPP

View File

@ -40,8 +40,8 @@
//
//M*/
#ifndef __OPENCV_STITCHING_CAMERA_HPP__
#define __OPENCV_STITCHING_CAMERA_HPP__
#ifndef OPENCV_STITCHING_CAMERA_HPP
#define OPENCV_STITCHING_CAMERA_HPP
#include "opencv2/core.hpp"
@ -59,7 +59,7 @@ struct CV_EXPORTS CameraParams
{
CameraParams();
CameraParams(const CameraParams& other);
const CameraParams& operator =(const CameraParams& other);
CameraParams& operator =(const CameraParams& other);
Mat K() const;
double focal; // Focal length
@ -75,4 +75,4 @@ struct CV_EXPORTS CameraParams
} // namespace detail
} // namespace cv
#endif // #ifndef __OPENCV_STITCHING_CAMERA_HPP__
#endif // #ifndef OPENCV_STITCHING_CAMERA_HPP

View File

@ -40,8 +40,12 @@
//
//M*/
#ifndef __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__
#define __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__
#ifndef OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP
#define OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP
#if defined(NO)
# warning Detected Apple 'NO' macro definition, it can cause build conflicts. Please, include this header before any Apple headers.
#endif
#include "opencv2/core.hpp"
@ -88,8 +92,8 @@ class CV_EXPORTS NoExposureCompensator : public ExposureCompensator
{
public:
void feed(const std::vector<Point> &/*corners*/, const std::vector<UMat> &/*images*/,
const std::vector<std::pair<UMat,uchar> > &/*masks*/) { }
void apply(int /*index*/, Point /*corner*/, InputOutputArray /*image*/, InputArray /*mask*/) { }
const std::vector<std::pair<UMat,uchar> > &/*masks*/) CV_OVERRIDE { }
void apply(int /*index*/, Point /*corner*/, InputOutputArray /*image*/, InputArray /*mask*/) CV_OVERRIDE { }
};
/** @brief Exposure compensator which tries to remove exposure related artifacts by adjusting image
@ -99,8 +103,8 @@ class CV_EXPORTS GainCompensator : public ExposureCompensator
{
public:
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
const std::vector<std::pair<UMat,uchar> > &masks);
void apply(int index, Point corner, InputOutputArray image, InputArray mask);
const std::vector<std::pair<UMat,uchar> > &masks) CV_OVERRIDE;
void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE;
std::vector<double> gains() const;
private:
@ -116,8 +120,8 @@ public:
BlocksGainCompensator(int bl_width = 32, int bl_height = 32)
: bl_width_(bl_width), bl_height_(bl_height) {}
void feed(const std::vector<Point> &corners, const std::vector<UMat> &images,
const std::vector<std::pair<UMat,uchar> > &masks);
void apply(int index, Point corner, InputOutputArray image, InputArray mask);
const std::vector<std::pair<UMat,uchar> > &masks) CV_OVERRIDE;
void apply(int index, Point corner, InputOutputArray image, InputArray mask) CV_OVERRIDE;
private:
int bl_width_, bl_height_;
@ -129,4 +133,4 @@ private:
} // namespace detail
} // namespace cv
#endif // __OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP__
#endif // OPENCV_STITCHING_EXPOSURE_COMPENSATE_HPP

View File

@ -40,8 +40,8 @@
//
//M*/
#ifndef __OPENCV_STITCHING_MATCHERS_HPP__
#define __OPENCV_STITCHING_MATCHERS_HPP__
#ifndef OPENCV_STITCHING_MATCHERS_HPP
#define OPENCV_STITCHING_MATCHERS_HPP
#include "opencv2/core.hpp"
#include "opencv2/features2d.hpp"
@ -83,9 +83,27 @@ public:
@sa detail::ImageFeatures, Rect_
*/
void operator ()(InputArray image, ImageFeatures &features, const std::vector<cv::Rect> &rois);
/** @brief Finds features in the given images in parallel.
@param images Source images
@param features Found features for each image
@param rois Regions of interest for each image
@sa detail::ImageFeatures, Rect_
*/
void operator ()(InputArrayOfArrays images, std::vector<ImageFeatures> &features,
const std::vector<std::vector<cv::Rect> > &rois);
/** @overload */
void operator ()(InputArrayOfArrays images, std::vector<ImageFeatures> &features);
/** @brief Frees unused memory allocated before if there is any. */
virtual void collectGarbage() {}
/* TODO OpenCV ABI 4.x
reimplement this as public method similar to FeaturesMatcher and remove private function hack
@return True, if it's possible to use the same finder instance in parallel, false otherwise
bool isThreadSafe() const { return is_thread_safe_; }
*/
protected:
/** @brief This method must implement features finding logic in order to make the wrappers
detail::FeaturesFinder::operator()_ work.
@ -95,6 +113,10 @@ protected:
@sa detail::ImageFeatures */
virtual void find(InputArray image, ImageFeatures &features) = 0;
/** @brief uses dynamic_cast to determine thread-safety
@return True, if it's possible to use the same finder instance in parallel, false otherwise
*/
bool isThreadSafe() const;
};
/** @brief SURF features finder.
@ -108,13 +130,28 @@ public:
int num_octaves_descr = /*4*/3, int num_layers_descr = /*2*/4);
private:
void find(InputArray image, ImageFeatures &features);
void find(InputArray image, ImageFeatures &features) CV_OVERRIDE;
Ptr<FeatureDetector> detector_;
Ptr<DescriptorExtractor> extractor_;
Ptr<Feature2D> surf;
};
/** @brief SIFT features finder.
@sa detail::FeaturesFinder, SIFT
*/
class CV_EXPORTS SiftFeaturesFinder : public FeaturesFinder
{
public:
SiftFeaturesFinder();
private:
void find(InputArray image, ImageFeatures &features) CV_OVERRIDE;
Ptr<Feature2D> sift;
};
/** @brief ORB features finder. :
@sa detail::FeaturesFinder, ORB
@ -125,12 +162,32 @@ public:
OrbFeaturesFinder(Size _grid_size = Size(3,1), int nfeatures=1500, float scaleFactor=1.3f, int nlevels=5);
private:
void find(InputArray image, ImageFeatures &features);
void find(InputArray image, ImageFeatures &features) CV_OVERRIDE;
Ptr<ORB> orb;
Size grid_size;
};
/** @brief AKAZE features finder. :
@sa detail::FeaturesFinder, AKAZE
*/
class CV_EXPORTS AKAZEFeaturesFinder : public detail::FeaturesFinder
{
public:
AKAZEFeaturesFinder(int descriptor_type = AKAZE::DESCRIPTOR_MLDB,
int descriptor_size = 0,
int descriptor_channels = 3,
float threshold = 0.001f,
int nOctaves = 4,
int nOctaveLayers = 4,
int diffusivity = KAZE::DIFF_PM_G2);
private:
void find(InputArray image, ImageFeatures &features) CV_OVERRIDE;
Ptr<AKAZE> akaze;
};
#ifdef HAVE_OPENCV_XFEATURES2D
class CV_EXPORTS SurfFeaturesFinderGpu : public FeaturesFinder
@ -139,10 +196,10 @@ public:
SurfFeaturesFinderGpu(double hess_thresh = 300., int num_octaves = 3, int num_layers = 4,
int num_octaves_descr = 4, int num_layers_descr = 2);
void collectGarbage();
void collectGarbage() CV_OVERRIDE;
private:
void find(InputArray image, ImageFeatures &features);
void find(InputArray image, ImageFeatures &features) CV_OVERRIDE;
cuda::GpuMat image_;
cuda::GpuMat gray_image_;
@ -156,19 +213,22 @@ private:
/** @brief Structure containing information about matches between two images.
It's assumed that there is a homography between those images.
It's assumed that there is a transformation between those images. Transformation may be
homography or affine transformation based on selected matcher.
@sa detail::FeaturesMatcher
*/
struct CV_EXPORTS MatchesInfo
{
MatchesInfo();
MatchesInfo(const MatchesInfo &other);
const MatchesInfo& operator =(const MatchesInfo &other);
MatchesInfo& operator =(const MatchesInfo &other);
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
Mat H; //!< Estimated transformation
double confidence; //!< Confidence two images are from the same panorama
};
@ -243,10 +303,10 @@ public:
BestOf2NearestMatcher(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6,
int num_matches_thresh2 = 6);
void collectGarbage();
void collectGarbage() CV_OVERRIDE;
protected:
void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info);
void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info) CV_OVERRIDE;
int num_matches_thresh1_;
int num_matches_thresh2_;
@ -267,9 +327,44 @@ 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
ratio between descriptor distances is greater than the threshold match_conf.
Unlike cv::detail::BestOf2NearestMatcher this matcher uses affine
transformation (affine trasformation estimate will be placed in matches_info).
@sa cv::detail::FeaturesMatcher cv::detail::BestOf2NearestMatcher
*/
class CV_EXPORTS 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
@sa cv::estimateAffine2D cv::estimateAffinePartial2D
*/
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;
bool full_affine_;
};
//! @} stitching_match
} // namespace detail
} // namespace cv
#endif // __OPENCV_STITCHING_MATCHERS_HPP__
#endif // OPENCV_STITCHING_MATCHERS_HPP

View File

@ -40,8 +40,8 @@
//
//M*/
#ifndef __OPENCV_STITCHING_MOTION_ESTIMATORS_HPP__
#define __OPENCV_STITCHING_MOTION_ESTIMATORS_HPP__
#ifndef OPENCV_STITCHING_MOTION_ESTIMATORS_HPP
#define OPENCV_STITCHING_MOTION_ESTIMATORS_HPP
#include "opencv2/core.hpp"
#include "matchers.hpp"
@ -104,11 +104,26 @@ public:
private:
virtual bool estimate(const std::vector<ImageFeatures> &features,
const std::vector<MatchesInfo> &pairwise_matches,
std::vector<CameraParams> &cameras);
std::vector<CameraParams> &cameras) CV_OVERRIDE;
bool is_focals_estimated_;
};
/** @brief Affine transformation based estimator.
This estimator uses pairwise transformations estimated by matcher to estimate
final transformation for each camera.
@sa cv::detail::HomographyBasedEstimator
*/
class CV_EXPORTS AffineBasedEstimator : public Estimator
{
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 BundleAdjusterBase : public Estimator
@ -134,8 +149,10 @@ protected:
@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)
: 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.);
@ -145,7 +162,7 @@ protected:
// Runs bundle adjustment
virtual bool estimate(const std::vector<ImageFeatures> &features,
const std::vector<MatchesInfo> &pairwise_matches,
std::vector<CameraParams> &cameras);
std::vector<CameraParams> &cameras) CV_OVERRIDE;
/** @brief Sets initial camera parameter to refine.
@ -184,7 +201,7 @@ protected:
// Threshold to filter out poorly matched image pairs
double conf_thresh_;
//LevenbergMarquardt algorithm termination criteria
//Levenberg-Marquardt algorithm termination criteria
TermCriteria term_criteria_;
// Camera parameters matrix (CV_64F)
@ -195,6 +212,26 @@ protected:
};
/** @brief Stub bundle adjuster that does nothing.
*/
class CV_EXPORTS NoBundleAdjuster : public BundleAdjusterBase
{
public:
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 {}
};
/** @brief Implementation of the camera parameters refinement algorithm which minimizes sum of the reprojection
error squares
@ -207,10 +244,10 @@ public:
BundleAdjusterReproj() : BundleAdjusterBase(7, 2) {}
private:
void setUpInitialCameraParams(const std::vector<CameraParams> &cameras);
void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const;
void calcError(Mat &err);
void calcJacobian(Mat &jac);
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;
Mat err1_, err2_;
};
@ -227,10 +264,58 @@ public:
BundleAdjusterRay() : BundleAdjusterBase(4, 3) {}
private:
void setUpInitialCameraParams(const std::vector<CameraParams> &cameras);
void obtainRefinedCameraParams(std::vector<CameraParams> &cameras) const;
void calcError(Mat &err);
void calcJacobian(Mat &jac);
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;
Mat err1_, err2_;
};
/** @brief Bundle adjuster that expects affine transformation
represented in homogeneous coordinates in R for each camera param. Implements
camera parameters refinement algorithm which minimizes sum of the reprojection
error squares
It estimates all transformation parameters. Refinement mask is ignored.
@sa AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffinePartial
*/
class CV_EXPORTS BundleAdjusterAffine : public BundleAdjusterBase
{
public:
BundleAdjusterAffine() : BundleAdjusterBase(6, 2) {}
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;
Mat err1_, err2_;
};
/** @brief Bundle adjuster that expects affine transformation with 4 DOF
represented in homogeneous coordinates in R for each camera param. Implements
camera parameters refinement algorithm which minimizes sum of the reprojection
error squares
It estimates all transformation parameters. Refinement mask is ignored.
@sa AffineBasedEstimator AffineBestOf2NearestMatcher BundleAdjusterAffine
*/
class CV_EXPORTS BundleAdjusterAffinePartial : public BundleAdjusterBase
{
public:
BundleAdjusterAffinePartial() : BundleAdjusterBase(4, 2) {}
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;
Mat err1_, err2_;
};
@ -271,4 +356,4 @@ void CV_EXPORTS findMaxSpanningTree(
} // namespace detail
} // namespace cv
#endif // __OPENCV_STITCHING_MOTION_ESTIMATORS_HPP__
#endif // OPENCV_STITCHING_MOTION_ESTIMATORS_HPP

View File

@ -40,8 +40,8 @@
//
//M*/
#ifndef __OPENCV_STITCHING_SEAM_FINDERS_HPP__
#define __OPENCV_STITCHING_SEAM_FINDERS_HPP__
#ifndef OPENCV_STITCHING_SEAM_FINDERS_HPP
#define OPENCV_STITCHING_SEAM_FINDERS_HPP
#include <set>
#include "opencv2/core.hpp"
@ -74,7 +74,7 @@ public:
class CV_EXPORTS NoSeamFinder : public SeamFinder
{
public:
void find(const std::vector<UMat>&, const std::vector<Point>&, std::vector<UMat>&) {}
void find(const std::vector<UMat>&, const std::vector<Point>&, std::vector<UMat>&) CV_OVERRIDE {}
};
/** @brief Base class for all pairwise seam estimators.
@ -83,7 +83,7 @@ class CV_EXPORTS PairwiseSeamFinder : public SeamFinder
{
public:
virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
std::vector<UMat> &masks);
std::vector<UMat> &masks) CV_OVERRIDE;
protected:
void run();
@ -107,11 +107,11 @@ class CV_EXPORTS VoronoiSeamFinder : public PairwiseSeamFinder
{
public:
virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
std::vector<UMat> &masks);
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);
void findInPair(size_t first, size_t second, Rect roi) CV_OVERRIDE;
};
@ -126,7 +126,7 @@ public:
void setCostFunction(CostFunction val) { costFunc_ = val; }
virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
std::vector<UMat> &masks);
std::vector<UMat> &masks) CV_OVERRIDE;
private:
enum ComponentState
@ -242,7 +242,7 @@ public:
~GraphCutSeamFinder();
void find(const std::vector<UMat> &src, const std::vector<Point> &corners,
std::vector<UMat> &masks);
std::vector<UMat> &masks) CV_OVERRIDE;
private:
// To avoid GCGraph dependency
@ -261,8 +261,8 @@ public:
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);
void findInPair(size_t first, size_t second, Rect roi);
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,
@ -282,4 +282,4 @@ private:
} // namespace detail
} // namespace cv
#endif // __OPENCV_STITCHING_SEAM_FINDERS_HPP__
#endif // OPENCV_STITCHING_SEAM_FINDERS_HPP

View File

@ -41,8 +41,8 @@
//M*/
#ifndef __OPENCV_STITCHING_TIMELAPSERS_HPP__
#define __OPENCV_STITCHING_TIMELAPSERS_HPP__
#ifndef OPENCV_STITCHING_TIMELAPSERS_HPP
#define OPENCV_STITCHING_TIMELAPSERS_HPP
#include "opencv2/core.hpp"
@ -80,7 +80,7 @@ protected:
class CV_EXPORTS TimelapserCrop : public Timelapser
{
public:
virtual void initialize(const std::vector<Point> &corners, const std::vector<Size> &sizes);
virtual void initialize(const std::vector<Point> &corners, const std::vector<Size> &sizes) CV_OVERRIDE;
};
//! @}
@ -88,4 +88,4 @@ public:
} // namespace detail
} // namespace cv
#endif // __OPENCV_STITCHING_TIMELAPSERS_HPP__
#endif // OPENCV_STITCHING_TIMELAPSERS_HPP

View File

@ -40,62 +40,12 @@
//
//M*/
#ifndef __OPENCV_STITCHING_UTIL_HPP__
#define __OPENCV_STITCHING_UTIL_HPP__
#ifndef OPENCV_STITCHING_UTIL_HPP
#define OPENCV_STITCHING_UTIL_HPP
#include <list>
#include "opencv2/core.hpp"
#ifndef ENABLE_LOG
#define ENABLE_LOG 0
#endif
// TODO remove LOG macros, add logging class
#if ENABLE_LOG
#ifdef ANDROID
#include <iostream>
#include <sstream>
#include <android/log.h>
#define LOG_STITCHING_MSG(msg) \
do { \
Stringstream _os; \
_os << msg; \
__android_log_print(ANDROID_LOG_DEBUG, "STITCHING", "%s", _os.str().c_str()); \
} while(0);
#else
#include <iostream>
#define LOG_STITCHING_MSG(msg) for(;;) { std::cout << msg; std::cout.flush(); break; }
#endif
#else
#define LOG_STITCHING_MSG(msg)
#endif
#define LOG_(_level, _msg) \
for(;;) \
{ \
using namespace std; \
if ((_level) >= ::cv::detail::stitchingLogLevel()) \
{ \
LOG_STITCHING_MSG(_msg); \
} \
break; \
}
#define LOG(msg) LOG_(1, msg)
#define LOG_CHAT(msg) LOG_(0, msg)
#define LOGLN(msg) LOG(msg << std::endl)
#define LOGLN_CHAT(msg) LOG_CHAT(msg << std::endl)
//#if DEBUG_LOG_CHAT
// #define LOG_CHAT(msg) LOG(msg)
// #define LOGLN_CHAT(msg) LOGLN(msg)
//#else
// #define LOG_CHAT(msg) do{}while(0)
// #define LOGLN_CHAT(msg) do{}while(0)
//#endif
namespace cv {
namespace detail {
@ -168,4 +118,4 @@ CV_EXPORTS int& stitchingLogLevel();
#include "util_inl.hpp"
#endif // __OPENCV_STITCHING_UTIL_HPP__
#endif // OPENCV_STITCHING_UTIL_HPP

View File

@ -40,8 +40,8 @@
//
//M*/
#ifndef __OPENCV_STITCHING_UTIL_INL_HPP__
#define __OPENCV_STITCHING_UTIL_INL_HPP__
#ifndef OPENCV_STITCHING_UTIL_INL_HPP
#define OPENCV_STITCHING_UTIL_INL_HPP
#include <queue>
#include "opencv2/core.hpp"
@ -128,4 +128,4 @@ static inline double sqr(double x) { return x * x; }
//! @endcond
#endif // __OPENCV_STITCHING_UTIL_INL_HPP__
#endif // OPENCV_STITCHING_UTIL_INL_HPP

View File

@ -40,8 +40,8 @@
//
//M*/
#ifndef __OPENCV_STITCHING_WARPERS_HPP__
#define __OPENCV_STITCHING_WARPERS_HPP__
#ifndef OPENCV_STITCHING_WARPERS_HPP
#define OPENCV_STITCHING_WARPERS_HPP
#include "opencv2/core.hpp"
#include "opencv2/core/cuda.hpp"
@ -138,23 +138,23 @@ struct CV_EXPORTS ProjectorBase
/** @brief Base class for rotation-based warper using a detail::ProjectorBase_ derived class.
*/
template <class P>
class CV_EXPORTS RotationWarperBase : public RotationWarper
class CV_EXPORTS_TEMPLATE RotationWarperBase : public RotationWarper
{
public:
Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R);
Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) CV_OVERRIDE;
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap);
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE;
Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
OutputArray dst);
OutputArray dst) CV_OVERRIDE;
void warpBackward(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
Size dst_size, OutputArray dst);
Size dst_size, OutputArray dst) CV_OVERRIDE;
Rect warpRoi(Size src_size, InputArray K, InputArray R);
Rect warpRoi(Size src_size, InputArray K, InputArray R) CV_OVERRIDE;
float getScale() const { return projector_.scale; }
void setScale(float val) { projector_.scale = val; }
float getScale() const CV_OVERRIDE{ return projector_.scale; }
void setScale(float val) CV_OVERRIDE { projector_.scale = val; }
protected:
@ -186,22 +186,50 @@ public:
*/
PlaneWarper(float scale = 1.f) { projector_.scale = scale; }
Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R);
Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) CV_OVERRIDE;
Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R, InputArray T);
virtual Rect buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, OutputArray xmap, OutputArray ymap);
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap);
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE;
Point warp(InputArray src, InputArray K, InputArray R,
int interp_mode, int border_mode, OutputArray dst);
int interp_mode, int border_mode, OutputArray dst) CV_OVERRIDE;
virtual Point warp(InputArray src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode,
OutputArray dst);
Rect warpRoi(Size src_size, InputArray K, InputArray R);
Rect warpRoi(Size src_size, InputArray K, InputArray R) CV_OVERRIDE;
Rect warpRoi(Size src_size, InputArray K, InputArray R, InputArray T);
protected:
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br);
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE;
};
/** @brief Affine warper that uses rotations and translations
Uses affine transformation in homogeneous coordinates to represent both rotation and
translation in camera rotation matrix.
*/
class CV_EXPORTS AffineWarper : public PlaneWarper
{
public:
/** @brief Construct an instance of the affine warper class.
@param scale Projected image scale multiplier
*/
AffineWarper(float scale = 1.f) : PlaneWarper(scale) {}
Point2f warpPoint(const Point2f &pt, InputArray K, InputArray R) CV_OVERRIDE;
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE;
Point warp(InputArray src, InputArray K, InputArray R,
int interp_mode, int border_mode, OutputArray dst) CV_OVERRIDE;
Rect warpRoi(Size src_size, InputArray K, InputArray R) CV_OVERRIDE;
protected:
/** @brief Extracts rotation and translation matrices from matrix H representing
affine transformation in homogeneous coordinates
*/
void getRTfromHomogeneous(InputArray H, Mat &R, Mat &T);
};
@ -214,7 +242,8 @@ struct CV_EXPORTS SphericalProjector : ProjectorBase
/** @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).
Projects image onto unit sphere with origin at (0, 0, 0) and radius scale, measured in pixels.
A 360 panorama would therefore have a resulting width of 2 * scale * PI pixels.
Poles are located at (0, -1, 0) and (0, 1, 0) points.
*/
class CV_EXPORTS SphericalWarper : public RotationWarperBase<SphericalProjector>
@ -222,14 +251,15 @@ class CV_EXPORTS SphericalWarper : public RotationWarperBase<SphericalProjector>
public:
/** @brief Construct an instance of the spherical warper class.
@param scale Projected image scale multiplier
@param scale Radius of the projected sphere, in pixels. An image spanning the
whole sphere will have a width of 2 * scale * PI pixels.
*/
SphericalWarper(float scale) { projector_.scale = scale; }
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap);
Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst);
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE;
Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) CV_OVERRIDE;
protected:
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br);
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE;
};
@ -251,10 +281,10 @@ public:
*/
CylindricalWarper(float scale) { projector_.scale = scale; }
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap);
Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst);
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE;
Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode, OutputArray dst) CV_OVERRIDE;
protected:
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br)
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE
{
RotationWarperBase<CylindricalProjector>::detectResultRoiByBorder(src_size, dst_tl, dst_br);
}
@ -407,7 +437,7 @@ class CV_EXPORTS PlaneWarperGpu : public PlaneWarper
public:
PlaneWarperGpu(float scale = 1.f) : PlaneWarper(scale) {}
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap)
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE
{
Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_);
d_xmap_.download(xmap);
@ -415,7 +445,7 @@ public:
return result;
}
Rect buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, OutputArray xmap, OutputArray ymap)
Rect buildMaps(Size src_size, InputArray K, InputArray R, InputArray T, OutputArray xmap, OutputArray ymap) CV_OVERRIDE
{
Rect result = buildMaps(src_size, K, R, T, d_xmap_, d_ymap_);
d_xmap_.download(xmap);
@ -424,7 +454,7 @@ public:
}
Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
OutputArray dst)
OutputArray dst) CV_OVERRIDE
{
d_src_.upload(src);
Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_);
@ -433,7 +463,7 @@ public:
}
Point warp(InputArray src, InputArray K, InputArray R, InputArray T, int interp_mode, int border_mode,
OutputArray dst)
OutputArray dst) CV_OVERRIDE
{
d_src_.upload(src);
Point result = warp(d_src_, K, R, T, interp_mode, border_mode, d_dst_);
@ -461,7 +491,7 @@ class CV_EXPORTS SphericalWarperGpu : public SphericalWarper
public:
SphericalWarperGpu(float scale) : SphericalWarper(scale) {}
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap)
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE
{
Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_);
d_xmap_.download(xmap);
@ -470,7 +500,7 @@ public:
}
Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
OutputArray dst)
OutputArray dst) CV_OVERRIDE
{
d_src_.upload(src);
Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_);
@ -493,7 +523,7 @@ class CV_EXPORTS CylindricalWarperGpu : public CylindricalWarper
public:
CylindricalWarperGpu(float scale) : CylindricalWarper(scale) {}
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap)
Rect buildMaps(Size src_size, InputArray K, InputArray R, OutputArray xmap, OutputArray ymap) CV_OVERRIDE
{
Rect result = buildMaps(src_size, K, R, d_xmap_, d_ymap_);
d_xmap_.download(xmap);
@ -502,7 +532,7 @@ public:
}
Point warp(InputArray src, InputArray K, InputArray R, int interp_mode, int border_mode,
OutputArray dst)
OutputArray dst) CV_OVERRIDE
{
d_src_.upload(src);
Point result = warp(d_src_, K, R, interp_mode, border_mode, d_dst_);
@ -520,7 +550,7 @@ private:
};
struct SphericalPortraitProjector : ProjectorBase
struct CV_EXPORTS SphericalPortraitProjector : ProjectorBase
{
void mapForward(float x, float y, float &u, float &v);
void mapBackward(float u, float v, float &x, float &y);
@ -535,10 +565,10 @@ public:
SphericalPortraitWarper(float scale) { projector_.scale = scale; }
protected:
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br);
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE;
};
struct CylindricalPortraitProjector : ProjectorBase
struct CV_EXPORTS CylindricalPortraitProjector : ProjectorBase
{
void mapForward(float x, float y, float &u, float &v);
void mapBackward(float u, float v, float &x, float &y);
@ -551,13 +581,13 @@ public:
CylindricalPortraitWarper(float scale) { projector_.scale = scale; }
protected:
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br)
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE
{
RotationWarperBase<CylindricalPortraitProjector>::detectResultRoiByBorder(src_size, dst_tl, dst_br);
}
};
struct PlanePortraitProjector : ProjectorBase
struct CV_EXPORTS PlanePortraitProjector : ProjectorBase
{
void mapForward(float x, float y, float &u, float &v);
void mapBackward(float u, float v, float &x, float &y);
@ -570,7 +600,7 @@ public:
PlanePortraitWarper(float scale) { projector_.scale = scale; }
protected:
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br)
void detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br) CV_OVERRIDE
{
RotationWarperBase<PlanePortraitProjector>::detectResultRoiByBorder(src_size, dst_tl, dst_br);
}
@ -583,4 +613,4 @@ protected:
#include "warpers_inl.hpp"
#endif // __OPENCV_STITCHING_WARPERS_HPP__
#endif // OPENCV_STITCHING_WARPERS_HPP

View File

@ -40,8 +40,8 @@
//
//M*/
#ifndef __OPENCV_STITCHING_WARPERS_INL_HPP__
#define __OPENCV_STITCHING_WARPERS_INL_HPP__
#ifndef OPENCV_STITCHING_WARPERS_INL_HPP
#define OPENCV_STITCHING_WARPERS_INL_HPP
#include "opencv2/core.hpp"
#include "warpers.hpp" // Make your IDE see declarations
@ -150,10 +150,10 @@ Rect RotationWarperBase<P>::warpRoi(Size src_size, InputArray K, InputArray R)
template <class P>
void RotationWarperBase<P>::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br)
{
float tl_uf = std::numeric_limits<float>::max();
float tl_vf = std::numeric_limits<float>::max();
float br_uf = -std::numeric_limits<float>::max();
float br_vf = -std::numeric_limits<float>::max();
float tl_uf = (std::numeric_limits<float>::max)();
float tl_vf = (std::numeric_limits<float>::max)();
float br_uf = -(std::numeric_limits<float>::max)();
float br_vf = -(std::numeric_limits<float>::max)();
float u, v;
for (int y = 0; y < src_size.height; ++y)
@ -161,8 +161,8 @@ void RotationWarperBase<P>::detectResultRoi(Size src_size, Point &dst_tl, Point
for (int x = 0; x < src_size.width; ++x)
{
projector_.mapForward(static_cast<float>(x), static_cast<float>(y), u, v);
tl_uf = std::min(tl_uf, u); tl_vf = std::min(tl_vf, v);
br_uf = std::max(br_uf, u); br_vf = std::max(br_vf, v);
tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v);
br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v);
}
}
@ -176,31 +176,31 @@ void RotationWarperBase<P>::detectResultRoi(Size src_size, Point &dst_tl, Point
template <class P>
void RotationWarperBase<P>::detectResultRoiByBorder(Size src_size, Point &dst_tl, Point &dst_br)
{
float tl_uf = std::numeric_limits<float>::max();
float tl_vf = std::numeric_limits<float>::max();
float br_uf = -std::numeric_limits<float>::max();
float br_vf = -std::numeric_limits<float>::max();
float tl_uf = (std::numeric_limits<float>::max)();
float tl_vf = (std::numeric_limits<float>::max)();
float br_uf = -(std::numeric_limits<float>::max)();
float br_vf = -(std::numeric_limits<float>::max)();
float u, v;
for (float x = 0; x < src_size.width; ++x)
{
projector_.mapForward(static_cast<float>(x), 0, u, v);
tl_uf = std::min(tl_uf, u); tl_vf = std::min(tl_vf, v);
br_uf = std::max(br_uf, u); br_vf = std::max(br_vf, v);
tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v);
br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v);
projector_.mapForward(static_cast<float>(x), static_cast<float>(src_size.height - 1), u, v);
tl_uf = std::min(tl_uf, u); tl_vf = std::min(tl_vf, v);
br_uf = std::max(br_uf, u); br_vf = std::max(br_vf, v);
tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v);
br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v);
}
for (int y = 0; y < src_size.height; ++y)
{
projector_.mapForward(0, static_cast<float>(y), u, v);
tl_uf = std::min(tl_uf, u); tl_vf = std::min(tl_vf, v);
br_uf = std::max(br_uf, u); br_vf = std::max(br_vf, v);
tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v);
br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v);
projector_.mapForward(static_cast<float>(src_size.width - 1), static_cast<float>(y), u, v);
tl_uf = std::min(tl_uf, u); tl_vf = std::min(tl_vf, v);
br_uf = std::max(br_uf, u); br_vf = std::max(br_vf, v);
tl_uf = (std::min)(tl_uf, u); tl_vf = (std::min)(tl_vf, v);
br_uf = (std::max)(br_uf, u); br_vf = (std::max)(br_vf, v);
}
dst_tl.x = static_cast<int>(tl_uf);
@ -771,4 +771,4 @@ void PlanePortraitProjector::mapBackward(float u0, float v0, float &x, float &y)
//! @endcond
#endif // __OPENCV_STITCHING_WARPERS_INL_HPP__
#endif // OPENCV_STITCHING_WARPERS_INL_HPP