Gpu functionality in stitching module is excluded from Android build
This commit is contained in:
@@ -28,12 +28,12 @@ endif()
|
|||||||
|
|
||||||
add_subdirectory(video)
|
add_subdirectory(video)
|
||||||
|
|
||||||
|
if(NOT (ANDROID OR IOS))
|
||||||
|
add_subdirectory(gpu)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT IOS)
|
if(NOT IOS)
|
||||||
add_subdirectory(traincascade)
|
add_subdirectory(traincascade)
|
||||||
add_subdirectory(haartraining)
|
add_subdirectory(haartraining)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT (ANDROID OR IOS))
|
|
||||||
add_subdirectory(gpu)
|
|
||||||
add_subdirectory(stitching)
|
add_subdirectory(stitching)
|
||||||
endif()
|
endif()
|
||||||
|
@@ -1,2 +1,6 @@
|
|||||||
include_directories("${OpenCV_SOURCE_DIR}/modules/imgproc/src") # For gcgraph.hpp
|
include_directories("${OpenCV_SOURCE_DIR}/modules/imgproc/src") # For gcgraph.hpp
|
||||||
define_opencv_module(stitching opencv_core opencv_imgproc opencv_features2d opencv_calib3d opencv_gpu opencv_flann opencv_objdetect)
|
if(ANDROID)
|
||||||
|
define_opencv_module(stitching opencv_core opencv_imgproc opencv_features2d opencv_calib3d opencv_flann opencv_objdetect)
|
||||||
|
else()
|
||||||
|
define_opencv_module(stitching opencv_core opencv_imgproc opencv_features2d opencv_calib3d opencv_flann opencv_objdetect opencv_gpu)
|
||||||
|
endif()
|
||||||
|
@@ -44,7 +44,9 @@
|
|||||||
|
|
||||||
#include "opencv2/core/core.hpp"
|
#include "opencv2/core/core.hpp"
|
||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
#include "opencv2/gpu/gpu.hpp"
|
#ifndef ANDROID
|
||||||
|
# include "opencv2/gpu/gpu.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace cv {
|
namespace cv {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
@@ -118,7 +120,7 @@ protected:
|
|||||||
void detectResultRoi(Point &dst_tl, Point &dst_br);
|
void detectResultRoi(Point &dst_tl, Point &dst_br);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
class CV_EXPORTS PlaneWarperGpu : public PlaneWarper
|
class CV_EXPORTS PlaneWarperGpu : public PlaneWarper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -129,6 +131,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
|
gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
struct CV_EXPORTS SphericalProjector : ProjectorBase
|
struct CV_EXPORTS SphericalProjector : ProjectorBase
|
||||||
@@ -150,6 +153,7 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
class CV_EXPORTS SphericalWarperGpu : public SphericalWarper
|
class CV_EXPORTS SphericalWarperGpu : public SphericalWarper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -160,6 +164,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
|
gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
struct CV_EXPORTS CylindricalProjector : ProjectorBase
|
struct CV_EXPORTS CylindricalProjector : ProjectorBase
|
||||||
@@ -183,6 +188,7 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
class CV_EXPORTS CylindricalWarperGpu : public CylindricalWarper
|
class CV_EXPORTS CylindricalWarperGpu : public CylindricalWarper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -193,6 +199,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
|
gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cv
|
} // namespace cv
|
||||||
|
@@ -158,7 +158,11 @@ void FeatherBlender::blend(Mat &dst, Mat &dst_mask)
|
|||||||
MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands)
|
MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands)
|
||||||
{
|
{
|
||||||
setNumBands(num_bands);
|
setNumBands(num_bands);
|
||||||
|
#ifndef ANDROID
|
||||||
can_use_gpu_ = try_gpu && gpu::getCudaEnabledDeviceCount();
|
can_use_gpu_ = try_gpu && gpu::getCudaEnabledDeviceCount();
|
||||||
|
#else
|
||||||
|
can_use_gpu_ = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -342,9 +346,9 @@ void createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
|
void createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
|
||||||
{
|
{
|
||||||
|
#ifndef ANDROID
|
||||||
pyr.resize(num_levels + 1);
|
pyr.resize(num_levels + 1);
|
||||||
|
|
||||||
vector<gpu::GpuMat> gpu_pyr(num_levels + 1);
|
vector<gpu::GpuMat> gpu_pyr(num_levels + 1);
|
||||||
@@ -361,9 +365,9 @@ void createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pyr[num_levels] = gpu_pyr[num_levels];
|
pyr[num_levels] = gpu_pyr[num_levels];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void restoreImageFromLaplacePyr(vector<Mat> &pyr)
|
void restoreImageFromLaplacePyr(vector<Mat> &pyr)
|
||||||
{
|
{
|
||||||
if (pyr.size() == 0)
|
if (pyr.size() == 0)
|
||||||
|
@@ -43,7 +43,9 @@
|
|||||||
#include "precomp.hpp"
|
#include "precomp.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
#ifndef ANDROID
|
||||||
using namespace cv::gpu;
|
using namespace cv::gpu;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace cv {
|
namespace cv {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@@ -45,7 +45,9 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace cv::detail;
|
using namespace cv::detail;
|
||||||
|
#ifndef ANDROID
|
||||||
using namespace cv::gpu;
|
using namespace cv::gpu;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
@@ -67,7 +69,7 @@ private:
|
|||||||
Ptr<DescriptorExtractor> extractor_;
|
Ptr<DescriptorExtractor> extractor_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
class GpuSurfFeaturesFinder : public FeaturesFinder
|
class GpuSurfFeaturesFinder : public FeaturesFinder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -97,6 +99,7 @@ private:
|
|||||||
int num_octaves_, num_layers_;
|
int num_octaves_, num_layers_;
|
||||||
int num_octaves_descr_, num_layers_descr_;
|
int num_octaves_descr_, num_layers_descr_;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void CpuSurfFeaturesFinder::find(const Mat &image, ImageFeatures &features)
|
void CpuSurfFeaturesFinder::find(const Mat &image, ImageFeatures &features)
|
||||||
@@ -108,7 +111,7 @@ void CpuSurfFeaturesFinder::find(const Mat &image, ImageFeatures &features)
|
|||||||
extractor_->compute(gray_image, features.keypoints, features.descriptors);
|
extractor_->compute(gray_image, features.keypoints, features.descriptors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
void GpuSurfFeaturesFinder::find(const Mat &image, ImageFeatures &features)
|
void GpuSurfFeaturesFinder::find(const Mat &image, ImageFeatures &features)
|
||||||
{
|
{
|
||||||
CV_Assert(image.depth() == CV_8U);
|
CV_Assert(image.depth() == CV_8U);
|
||||||
@@ -141,6 +144,7 @@ void GpuSurfFeaturesFinder::releaseMemory()
|
|||||||
keypoints_.release();
|
keypoints_.release();
|
||||||
descriptors_.release();
|
descriptors_.release();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -220,7 +224,7 @@ private:
|
|||||||
float match_conf_;
|
float match_conf_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
class GpuMatcher : public FeaturesMatcher
|
class GpuMatcher : public FeaturesMatcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -235,6 +239,7 @@ private:
|
|||||||
GpuMat train_idx_, distance_, all_dist_;
|
GpuMat train_idx_, distance_, all_dist_;
|
||||||
vector< vector<DMatch> > pair_matches;
|
vector< vector<DMatch> > pair_matches;
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo& matches_info)
|
void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo& matches_info)
|
||||||
@@ -274,7 +279,7 @@ void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
void GpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo& matches_info)
|
void GpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo& matches_info)
|
||||||
{
|
{
|
||||||
matches_info.matches.clear();
|
matches_info.matches.clear();
|
||||||
@@ -330,6 +335,7 @@ void GpuMatcher::releaseMemory()
|
|||||||
all_dist_.release();
|
all_dist_.release();
|
||||||
vector< vector<DMatch> >().swap(pair_matches);
|
vector< vector<DMatch> >().swap(pair_matches);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@@ -348,9 +354,11 @@ void FeaturesFinder::operator ()(const Mat &image, ImageFeatures &features)
|
|||||||
SurfFeaturesFinder::SurfFeaturesFinder(bool try_use_gpu, double hess_thresh, int num_octaves, int num_layers,
|
SurfFeaturesFinder::SurfFeaturesFinder(bool try_use_gpu, double hess_thresh, int num_octaves, int num_layers,
|
||||||
int num_octaves_descr, int num_layers_descr)
|
int num_octaves_descr, int num_layers_descr)
|
||||||
{
|
{
|
||||||
|
#ifndef ANDROID
|
||||||
if (try_use_gpu && getCudaEnabledDeviceCount() > 0)
|
if (try_use_gpu && getCudaEnabledDeviceCount() > 0)
|
||||||
impl_ = new GpuSurfFeaturesFinder(hess_thresh, num_octaves, num_layers, num_octaves_descr, num_layers_descr);
|
impl_ = new GpuSurfFeaturesFinder(hess_thresh, num_octaves, num_layers, num_octaves_descr, num_layers_descr);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
impl_ = new CpuSurfFeaturesFinder(hess_thresh, num_octaves, num_layers, num_octaves_descr, num_layers_descr);
|
impl_ = new CpuSurfFeaturesFinder(hess_thresh, num_octaves, num_layers, num_octaves_descr, num_layers_descr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,9 +420,11 @@ void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<
|
|||||||
|
|
||||||
BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf, int num_matches_thresh1, int num_matches_thresh2)
|
BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf, int num_matches_thresh1, int num_matches_thresh2)
|
||||||
{
|
{
|
||||||
|
#ifndef ANDROID
|
||||||
if (try_use_gpu && getCudaEnabledDeviceCount() > 0)
|
if (try_use_gpu && getCudaEnabledDeviceCount() > 0)
|
||||||
impl_ = new GpuMatcher(match_conf);
|
impl_ = new GpuMatcher(match_conf);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
impl_ = new CpuMatcher(match_conf);
|
impl_ = new CpuMatcher(match_conf);
|
||||||
|
|
||||||
is_thread_safe_ = impl_->isThreadSafe();
|
is_thread_safe_ = impl_->isThreadSafe();
|
||||||
|
@@ -66,7 +66,9 @@
|
|||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
#include "opencv2/features2d/features2d.hpp"
|
#include "opencv2/features2d/features2d.hpp"
|
||||||
#include "opencv2/calib3d/calib3d.hpp"
|
#include "opencv2/calib3d/calib3d.hpp"
|
||||||
#include "opencv2/gpu/gpu.hpp"
|
#ifndef ANDROID
|
||||||
|
# include "opencv2/gpu/gpu.hpp"
|
||||||
|
#endif
|
||||||
#include "gcgraph.hpp"
|
#include "gcgraph.hpp"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -49,13 +49,27 @@ namespace detail {
|
|||||||
|
|
||||||
Ptr<Warper> Warper::createByCameraFocal(float focal, int type, bool try_gpu)
|
Ptr<Warper> Warper::createByCameraFocal(float focal, int type, bool try_gpu)
|
||||||
{
|
{
|
||||||
|
#ifndef ANDROID
|
||||||
bool can_use_gpu = try_gpu && gpu::getCudaEnabledDeviceCount();
|
bool can_use_gpu = try_gpu && gpu::getCudaEnabledDeviceCount();
|
||||||
|
if (can_use_gpu)
|
||||||
|
{
|
||||||
if (type == PLANE)
|
if (type == PLANE)
|
||||||
return !can_use_gpu ? new PlaneWarper(focal) : new PlaneWarperGpu(focal);
|
return new PlaneWarperGpu(focal);
|
||||||
if (type == CYLINDRICAL)
|
if (type == CYLINDRICAL)
|
||||||
return !can_use_gpu ? new CylindricalWarper(focal) : new CylindricalWarperGpu(focal);
|
return new CylindricalWarperGpu(focal);
|
||||||
if (type == SPHERICAL)
|
if (type == SPHERICAL)
|
||||||
return !can_use_gpu ? new SphericalWarper(focal) : new SphericalWarperGpu(focal);
|
return new SphericalWarperGpu(focal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (type == PLANE)
|
||||||
|
return new PlaneWarper(focal);
|
||||||
|
if (type == CYLINDRICAL)
|
||||||
|
return new CylindricalWarper(focal);
|
||||||
|
if (type == SPHERICAL)
|
||||||
|
return new SphericalWarper(focal);
|
||||||
|
}
|
||||||
CV_Error(CV_StsBadArg, "unsupported warping type");
|
CV_Error(CV_StsBadArg, "unsupported warping type");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -107,7 +121,7 @@ void PlaneWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
|
|||||||
dst_br.y = static_cast<int>(br_vf);
|
dst_br.y = static_cast<int>(br_vf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
Point PlaneWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst, int interp_mode, int border_mode)
|
Point PlaneWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst, int interp_mode, int border_mode)
|
||||||
{
|
{
|
||||||
src_size_ = src.size();
|
src_size_ = src.size();
|
||||||
@@ -132,6 +146,7 @@ Point PlaneWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst,
|
|||||||
|
|
||||||
return dst_tl;
|
return dst_tl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
|
void SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
|
||||||
@@ -177,7 +192,7 @@ void SphericalWarper::detectResultRoi(Point &dst_tl, Point &dst_br)
|
|||||||
dst_br.y = static_cast<int>(br_vf);
|
dst_br.y = static_cast<int>(br_vf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef ANDROID
|
||||||
Point SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst,
|
Point SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &dst,
|
||||||
int interp_mode, int border_mode)
|
int interp_mode, int border_mode)
|
||||||
{
|
{
|
||||||
@@ -230,6 +245,7 @@ Point CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat
|
|||||||
|
|
||||||
return dst_tl;
|
return dst_tl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cv
|
} // namespace cv
|
||||||
|
@@ -19,8 +19,10 @@ if (BUILD_EXAMPLES)
|
|||||||
"${CMAKE_SOURCE_DIR}/modules/legacy/include"
|
"${CMAKE_SOURCE_DIR}/modules/legacy/include"
|
||||||
"${CMAKE_SOURCE_DIR}/modules/contrib/include"
|
"${CMAKE_SOURCE_DIR}/modules/contrib/include"
|
||||||
"${CMAKE_SOURCE_DIR}/modules/stitching/include"
|
"${CMAKE_SOURCE_DIR}/modules/stitching/include"
|
||||||
"${CMAKE_SOURCE_DIR}/modules/gpu/include"
|
|
||||||
)
|
)
|
||||||
|
if (NOT ANDROID)
|
||||||
|
include_directories("${CMAKE_SOURCE_DIR}/modules/gpu/include")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
||||||
@@ -37,10 +39,15 @@ if (BUILD_EXAMPLES)
|
|||||||
PROJECT_LABEL "(EXAMPLE) ${name}")
|
PROJECT_LABEL "(EXAMPLE) ${name}")
|
||||||
add_dependencies(${the_target} opencv_core opencv_flann opencv_imgproc opencv_highgui
|
add_dependencies(${the_target} opencv_core opencv_flann opencv_imgproc opencv_highgui
|
||||||
opencv_ml opencv_video opencv_objdetect opencv_features2d
|
opencv_ml opencv_video opencv_objdetect opencv_features2d
|
||||||
opencv_calib3d opencv_legacy opencv_contrib opencv_stitching opencv_gpu)
|
opencv_calib3d opencv_legacy opencv_contrib opencv_stitching)
|
||||||
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_core
|
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} opencv_core
|
||||||
opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
|
opencv_flann opencv_imgproc opencv_highgui opencv_ml opencv_video opencv_objdetect
|
||||||
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching opencv_gpu)
|
opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_stitching)
|
||||||
|
|
||||||
|
if (NOT ANDROID)
|
||||||
|
target_link_libraries(${the_target} opencv_gpu)
|
||||||
|
add_dependencies(${the_target} opencv_gpu)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
if(ENABLE_SOLUTION_FOLDERS)
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//cpp")
|
set_target_properties(${the_target} PROPERTIES FOLDER "samples//cpp")
|
||||||
|
Reference in New Issue
Block a user