set(the_description "Images stitching")
-ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect OPTIONAL opencv_gpu opencv_gpuarithm opencv_gpufilters opencv_nonfree)
+ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect
+ OPTIONAL opencv_gpu opencv_gpuarithm opencv_gpufilters opencv_gpufeatures2d opencv_nonfree)
#include "opencv2/features2d.hpp"
#include "opencv2/opencv_modules.hpp"
-#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU)
-#include "opencv2/nonfree/gpu.hpp"
+
+#ifdef HAVE_OPENCV_NONFREE
+# include "opencv2/nonfree/gpu.hpp"
#endif
namespace cv {
};
-#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU)
+#ifdef HAVE_OPENCV_NONFREE
class CV_EXPORTS SurfFeaturesFinderGpu : public FeaturesFinder
{
public:
#define __OPENCV_STITCHING_WARPERS_HPP__
#include "opencv2/core.hpp"
+#include "opencv2/core/gpumat.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/opencv_modules.hpp"
-#ifdef HAVE_OPENCV_GPU
-# include "opencv2/gpu.hpp"
-#endif
namespace cv {
namespace detail {
};
-#ifdef HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPUWARPING
class CV_EXPORTS PlaneWarperGpu : public PlaneWarper
{
public:
-#ifdef HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPUWARPING
class PlaneWarperGpu: public WarperCreator
{
public:
MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands, int weight_type)
{
setNumBands(num_bands);
-#ifdef HAVE_OPENCV_GPU
+
+#if defined(HAVE_OPENCV_GPUARITHM) && defined(HAVE_OPENCV_GPUWARPING)
can_use_gpu_ = try_gpu && gpu::getCudaEnabledDeviceCount();
#else
- (void)try_gpu;
+ (void) try_gpu;
can_use_gpu_ = false;
#endif
+
CV_Assert(weight_type == CV_32F || weight_type == CV_16S);
weight_type_ = weight_type;
}
void createLaplacePyrGpu(const Mat &img, int num_levels, std::vector<Mat> &pyr)
{
-#ifdef HAVE_OPENCV_GPU
+#if defined(HAVE_OPENCV_GPUARITHM) && defined(HAVE_OPENCV_GPUWARPING)
pyr.resize(num_levels + 1);
std::vector<gpu::GpuMat> gpu_pyr(num_levels + 1);
void restoreImageFromLaplacePyrGpu(std::vector<Mat> &pyr)
{
-#ifdef HAVE_OPENCV_GPU
+#if defined(HAVE_OPENCV_GPUARITHM) && defined(HAVE_OPENCV_GPUWARPING)
if (pyr.empty())
return;
using namespace cv;
using namespace cv::detail;
-
-#ifdef HAVE_OPENCV_GPU
using namespace cv::gpu;
-#endif
#ifdef HAVE_OPENCV_NONFREE
#include "opencv2/nonfree.hpp"
float match_conf_;
};
-#ifdef HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPUFEATURES2D
class GpuMatcher : public FeaturesMatcher
{
public:
LOG("1->2 & 2->1 matches: " << matches_info.matches.size() << endl);
}
-#ifdef HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPUFEATURES2D
void GpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo& matches_info)
{
matches_info.matches.clear();
}
}
-#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU)
+#ifdef HAVE_OPENCV_NONFREE
SurfFeaturesFinderGpu::SurfFeaturesFinderGpu(double hess_thresh, int num_octaves, int num_layers,
int num_octaves_descr, int num_layers_descr)
{
BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf, int num_matches_thresh1, int num_matches_thresh2)
{
-#ifdef HAVE_OPENCV_GPU
+ (void)try_use_gpu;
+
+#ifdef HAVE_OPENCV_GPUFEATURES2D
if (try_use_gpu && getCudaEnabledDeviceCount() > 0)
+ {
impl_ = new GpuMatcher(match_conf);
+ }
else
-#else
- (void)try_use_gpu;
#endif
+ {
impl_ = new CpuMatcher(match_conf);
+ }
is_thread_safe_ = impl_->isThreadSafe();
num_matches_thresh1_ = num_matches_thresh1;
#include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/calib3d.hpp"
+
+#ifdef HAVE_OPENCV_GPUARITHM
+# include "opencv2/gpuarithm.hpp"
+#endif
+
+#ifdef HAVE_OPENCV_GPUWARPING
+# include "opencv2/gpuwarping.hpp"
+#endif
+
+#ifdef HAVE_OPENCV_GPUFEATURES2D
+# include "opencv2/gpufeatures2d.hpp"
+#endif
+
#ifdef HAVE_OPENCV_GPU
# include "opencv2/gpu.hpp"
-# ifdef HAVE_OPENCV_NONFREE
-# include "opencv2/nonfree/gpu.hpp"
-# endif
+#endif
+
+#ifdef HAVE_OPENCV_NONFREE
+# include "opencv2/nonfree/gpu.hpp"
#endif
#include "../../imgproc/src/gcgraph.hpp"
#ifdef HAVE_OPENCV_GPU
if (try_use_gpu && gpu::getCudaEnabledDeviceCount() > 0)
{
-#if defined(HAVE_OPENCV_NONFREE)
+#ifdef HAVE_OPENCV_NONFREE
stitcher.setFeaturesFinder(new detail::SurfFeaturesFinderGpu());
#else
stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder());
}
-#ifdef HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPUWARPING
Rect PlaneWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap)
{
return buildMaps(src_size, K, R, Mat::zeros(3, 1, CV_32F), xmap, ymap);
Ptr<FeaturesFinder> finder;
if (features_type == "surf")
{
-#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU)
+#ifdef HAVE_OPENCV_NONFREE
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
finder = new SurfFeaturesFinderGpu();
else
// Warp images and their masks
Ptr<WarperCreator> warper_creator;
-#ifdef HAVE_OPENCV_GPU
+#ifdef HAVE_OPENCV_GPUWARPING
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
{
if (warp_type == "plane") warper_creator = new cv::PlaneWarperGpu();