Merge pull request #2022 from asmorkalov:ocv_dynamic_cuda
This commit is contained in:
commit
f22d9a232d
@ -201,6 +201,7 @@ OCV_OPTION(INSTALL_TO_MANGLED_PATHS "Enables mangled install paths, that help wi
|
|||||||
|
|
||||||
# OpenCV build options
|
# OpenCV build options
|
||||||
# ===================================================
|
# ===================================================
|
||||||
|
OCV_OPTION(ENABLE_DYNAMIC_CUDA "Enabled dynamic CUDA linkage" ON IF ANDROID )
|
||||||
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) )
|
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) )
|
||||||
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) IF (CMAKE_VERSION VERSION_GREATER "2.8.0") )
|
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) IF (CMAKE_VERSION VERSION_GREATER "2.8.0") )
|
||||||
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||||
@ -472,7 +473,11 @@ endif()
|
|||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# Add CUDA libraries (needed for apps/tools, samples)
|
# Add CUDA libraries (needed for apps/tools, samples)
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
if(HAVE_CUDA)
|
if(NOT HAVE_CUDA)
|
||||||
|
set(ENABLE_DYNAMIC_CUDA OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(HAVE_CUDA AND NOT ENABLE_DYNAMIC_CUDA)
|
||||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||||
if(HAVE_CUBLAS)
|
if(HAVE_CUBLAS)
|
||||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cublas_LIBRARY})
|
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cublas_LIBRARY})
|
||||||
@ -481,6 +486,7 @@ if(HAVE_CUDA)
|
|||||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cufft_LIBRARY})
|
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cufft_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
# Solution folders:
|
# Solution folders:
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
@ -488,7 +488,7 @@ macro(ocv_glob_module_sources)
|
|||||||
file(GLOB lib_cuda_srcs "src/cuda/*.cu")
|
file(GLOB lib_cuda_srcs "src/cuda/*.cu")
|
||||||
set(cuda_objs "")
|
set(cuda_objs "")
|
||||||
set(lib_cuda_hdrs "")
|
set(lib_cuda_hdrs "")
|
||||||
if(HAVE_CUDA AND lib_cuda_srcs)
|
if(HAVE_CUDA)
|
||||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||||
file(GLOB lib_cuda_hdrs "src/cuda/*.hpp")
|
file(GLOB lib_cuda_hdrs "src/cuda/*.hpp")
|
||||||
|
|
||||||
@ -537,9 +537,6 @@ macro(ocv_create_module)
|
|||||||
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS})
|
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS})
|
||||||
target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS})
|
target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS})
|
||||||
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
|
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
|
||||||
if (HAVE_CUDA)
|
|
||||||
target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_dependencies(opencv_modules ${the_module})
|
add_dependencies(opencv_modules ${the_module})
|
||||||
|
@ -1,11 +1,25 @@
|
|||||||
set(the_description "The Core Functionality")
|
set(the_description "The Core Functionality")
|
||||||
ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES})
|
|
||||||
ocv_module_include_directories(${ZLIB_INCLUDE_DIR})
|
if (NOT HAVE_CUDA OR ENABLE_DYNAMIC_CUDA)
|
||||||
|
ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES})
|
||||||
|
else()
|
||||||
|
ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
ocv_module_include_directories("${OpenCV_SOURCE_DIR}/modules/dynamicuda/include/" ${ZLIB_INCLUDE_DIR})
|
||||||
|
|
||||||
if(HAVE_WINRT)
|
if(HAVE_WINRT)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /GS /Gm- /AI\"${WINDOWS_SDK_PATH}/References/CommonConfiguration/Neutral\" /AI\"${VISUAL_STUDIO_PATH}/vcpackages\"")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW /GS /Gm- /AI\"${WINDOWS_SDK_PATH}/References/CommonConfiguration/Neutral\" /AI\"${VISUAL_STUDIO_PATH}/vcpackages\"")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_DYNAMIC_CUDA)
|
||||||
|
add_definitions(-DDYNAMIC_CUDA_SUPPORT)
|
||||||
|
else()
|
||||||
|
if (HAVE_CUDA)
|
||||||
|
add_definitions(-DUSE_CUDA)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(HAVE_CUDA)
|
if(HAVE_CUDA)
|
||||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include")
|
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include")
|
||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
|
||||||
@ -14,11 +28,26 @@ endif()
|
|||||||
file(GLOB lib_cuda_hdrs "include/opencv2/${name}/cuda/*.hpp" "include/opencv2/${name}/cuda/*.h")
|
file(GLOB lib_cuda_hdrs "include/opencv2/${name}/cuda/*.hpp" "include/opencv2/${name}/cuda/*.h")
|
||||||
file(GLOB lib_cuda_hdrs_detail "include/opencv2/${name}/cuda/detail/*.hpp" "include/opencv2/${name}/cuda/detail/*.h")
|
file(GLOB lib_cuda_hdrs_detail "include/opencv2/${name}/cuda/detail/*.hpp" "include/opencv2/${name}/cuda/detail/*.h")
|
||||||
|
|
||||||
|
if(HAVE_CUDA AND NOT ENABLE_DYNAMIC_CUDA)
|
||||||
|
file(GLOB lib_cuda "../dynamicuda/src/cuda/*.cu*")
|
||||||
|
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||||
|
ocv_cuda_compile(cuda_objs ${lib_cuda})
|
||||||
|
endif()
|
||||||
|
|
||||||
source_group("Cuda Headers" FILES ${lib_cuda_hdrs})
|
source_group("Cuda Headers" FILES ${lib_cuda_hdrs})
|
||||||
source_group("Cuda Headers\\Detail" FILES ${lib_cuda_hdrs_detail})
|
source_group("Cuda Headers\\Detail" FILES ${lib_cuda_hdrs_detail})
|
||||||
|
|
||||||
ocv_glob_module_sources(SOURCES "${opencv_core_BINARY_DIR}/version_string.inc"
|
if (HAVE_CUDA AND NOT ENABLE_DYNAMIC_CUDA)
|
||||||
HEADERS ${lib_cuda_hdrs} ${lib_cuda_hdrs_detail})
|
source_group("Src\\Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (NOT HAVE_CUDA OR ENABLE_DYNAMIC_CUDA)
|
||||||
|
ocv_glob_module_sources(SOURCES "${opencv_core_BINARY_DIR}/version_string.inc"
|
||||||
|
HEADERS ${lib_cuda_hdrs} ${lib_cuda_hdrs_detail})
|
||||||
|
else()
|
||||||
|
ocv_glob_module_sources(SOURCES "${opencv_core_BINARY_DIR}/version_string.inc" ${lib_cuda} ${cuda_objs}
|
||||||
|
HEADERS ${lib_cuda_hdrs} ${lib_cuda_hdrs_detail})
|
||||||
|
endif()
|
||||||
|
|
||||||
ocv_create_module()
|
ocv_create_module()
|
||||||
ocv_add_precompiled_headers(${the_module})
|
ocv_add_precompiled_headers(${the_module})
|
||||||
|
File diff suppressed because it is too large
Load Diff
15
modules/dynamicuda/CMakeLists.txt
Normal file
15
modules/dynamicuda/CMakeLists.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
if(NOT DYNAMIC_CUDA_SUPPORT)
|
||||||
|
ocv_module_disable(dynamicuda)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(the_description "Dynamic CUDA linkage")
|
||||||
|
|
||||||
|
add_definitions(-DUSE_CUDA)
|
||||||
|
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
|
||||||
|
ocv_module_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include")
|
||||||
|
set(OPENCV_MODULE_TYPE SHARED)
|
||||||
|
if (BUILD_FAT_JAVA_LIB)
|
||||||
|
ocv_define_module(dynamicuda opencv_java PRIVATE_REQUIRED ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||||
|
else()
|
||||||
|
ocv_define_module(dynamicuda opencv_core PRIVATE_REQUIRED ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||||
|
endif()
|
1112
modules/dynamicuda/include/opencv2/dynamicuda/dynamicuda.hpp
Normal file
1112
modules/dynamicuda/include/opencv2/dynamicuda/dynamicuda.hpp
Normal file
File diff suppressed because it is too large
Load Diff
55
modules/dynamicuda/src/main.cpp
Normal file
55
modules/dynamicuda/src/main.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include "cvconfig.h"
|
||||||
|
#include "opencv2/core/core.hpp"
|
||||||
|
#include "opencv2/core/gpumat.hpp"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#ifdef HAVE_CUDA
|
||||||
|
#include <cuda_runtime.h>
|
||||||
|
#include <npp.h>
|
||||||
|
|
||||||
|
#define CUDART_MINIMUM_REQUIRED_VERSION 4020
|
||||||
|
#define NPP_MINIMUM_REQUIRED_VERSION 4200
|
||||||
|
|
||||||
|
#if (CUDART_VERSION < CUDART_MINIMUM_REQUIRED_VERSION)
|
||||||
|
#error "Insufficient Cuda Runtime library version, please update it."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (NPP_VERSION_MAJOR * 1000 + NPP_VERSION_MINOR * 100 + NPP_VERSION_BUILD < NPP_MINIMUM_REQUIRED_VERSION)
|
||||||
|
#error "Insufficient NPP version, please update it."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace cv;
|
||||||
|
using namespace cv::gpu;
|
||||||
|
|
||||||
|
#define throw_nogpu CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support")
|
||||||
|
|
||||||
|
#include "opencv2/dynamicuda/dynamicuda.hpp"
|
||||||
|
|
||||||
|
#ifdef HAVE_CUDA
|
||||||
|
static CudaDeviceInfoFuncTable deviceInfoTable;
|
||||||
|
static CudaFuncTable gpuTable;
|
||||||
|
#else
|
||||||
|
static EmptyDeviceInfoFuncTable deviceInfoTable;
|
||||||
|
static EmptyFuncTable gpuTable;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
DeviceInfoFuncTable* deviceInfoFactory();
|
||||||
|
GpuFuncTable* gpuFactory();
|
||||||
|
|
||||||
|
DeviceInfoFuncTable* deviceInfoFactory()
|
||||||
|
{
|
||||||
|
return (DeviceInfoFuncTable*)&deviceInfoTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
GpuFuncTable* gpuFactory()
|
||||||
|
{
|
||||||
|
return (GpuFuncTable*)&gpuTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,8 @@ if(IOS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(the_description "GPU-accelerated Computer Vision")
|
set(the_description "GPU-accelerated Computer Vision")
|
||||||
ocv_add_module(gpu opencv_imgproc opencv_calib3d opencv_objdetect opencv_video opencv_photo opencv_legacy)
|
ocv_add_module(gpu opencv_imgproc opencv_calib3d opencv_objdetect opencv_video opencv_photo opencv_legacy
|
||||||
|
OPTIONAL ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY} ${CUDA_cublas_LIBRARY} ${CUDA_cufft_LIBRARY})
|
||||||
|
|
||||||
ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/cuda")
|
ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/cuda")
|
||||||
|
|
||||||
|
@ -2,26 +2,28 @@ set(PERF4AU_REQUIRED_DEPS opencv_core opencv_imgproc opencv_highgui opencv_video
|
|||||||
|
|
||||||
ocv_check_dependencies(${PERF4AU_REQUIRED_DEPS})
|
ocv_check_dependencies(${PERF4AU_REQUIRED_DEPS})
|
||||||
|
|
||||||
set(the_target gpu_perf4au)
|
if (OCV_DEPENDENCIES_FOUND)
|
||||||
project(${the_target})
|
set(the_target gpu_perf4au)
|
||||||
|
project(${the_target})
|
||||||
|
|
||||||
ocv_include_modules(${PERF4AU_REQUIRED_DEPS})
|
ocv_include_modules(${PERF4AU_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
|
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
file(GLOB srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h *.hpp)
|
file(GLOB srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.h *.hpp)
|
||||||
add_executable(${the_target} ${srcs})
|
add_executable(${the_target} ${srcs})
|
||||||
|
|
||||||
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${PERF4AU_REQUIRED_DEPS})
|
target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${PERF4AU_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
if(ENABLE_SOLUTION_FOLDERS)
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "tests performance")
|
set_target_properties(${the_target} PROPERTIES FOLDER "tests performance")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
||||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
@ -297,6 +297,12 @@ if(BUILD_FAT_JAVA_LIB)
|
|||||||
list(REMOVE_ITEM __deps ${m})
|
list(REMOVE_ITEM __deps ${m})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
if (ENABLE_DYNAMIC_CUDA)
|
||||||
|
list(REMOVE_ITEM __deps "opencv_dynamicuda")
|
||||||
|
endif()
|
||||||
|
if (ANDROID AND HAVE_opencv_gpu)
|
||||||
|
list(REMOVE_ITEM __deps "opencv_gpu")
|
||||||
|
endif()
|
||||||
ocv_list_unique(__deps)
|
ocv_list_unique(__deps)
|
||||||
set(__extradeps ${__deps})
|
set(__extradeps ${__deps})
|
||||||
ocv_list_filterout(__extradeps "^opencv_")
|
ocv_list_filterout(__extradeps "^opencv_")
|
||||||
|
@ -1,2 +1,6 @@
|
|||||||
set(the_description "Images stitching")
|
set(the_description "Images stitching")
|
||||||
ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect OPTIONAL opencv_gpu opencv_nonfree)
|
if (ENABLE_DYNAMIC_CUDA)
|
||||||
|
ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect OPTIONAL opencv_nonfree)
|
||||||
|
else()
|
||||||
|
ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect OPTIONAL opencv_gpu opencv_nonfree)
|
||||||
|
endif()
|
@ -227,7 +227,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
class CV_EXPORTS GraphCutSeamFinderGpu : public GraphCutSeamFinderBase, public PairwiseSeamFinder
|
class CV_EXPORTS GraphCutSeamFinderGpu : public GraphCutSeamFinderBase, public PairwiseSeamFinder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#include "opencv2/core/core.hpp"
|
#include "opencv2/core/core.hpp"
|
||||||
#include "opencv2/imgproc/imgproc.hpp"
|
#include "opencv2/imgproc/imgproc.hpp"
|
||||||
#include "opencv2/opencv_modules.hpp"
|
#include "opencv2/opencv_modules.hpp"
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
# include "opencv2/gpu/gpu.hpp"
|
# include "opencv2/gpu/gpu.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
class CV_EXPORTS PlaneWarperGpu : public PlaneWarper
|
class CV_EXPORTS PlaneWarperGpu : public PlaneWarper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -145,7 +145,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
class PlaneWarperGpu: public WarperCreator
|
class PlaneWarperGpu: public WarperCreator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -189,7 +189,7 @@ Rect FeatherBlender::createWeightMaps(const vector<Mat> &masks, const vector<Poi
|
|||||||
MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands, int weight_type)
|
MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands, int weight_type)
|
||||||
{
|
{
|
||||||
setNumBands(num_bands);
|
setNumBands(num_bands);
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
can_use_gpu_ = try_gpu && gpu::getCudaEnabledDeviceCount();
|
can_use_gpu_ = try_gpu && gpu::getCudaEnabledDeviceCount();
|
||||||
#else
|
#else
|
||||||
(void)try_gpu;
|
(void)try_gpu;
|
||||||
@ -491,7 +491,7 @@ 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)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(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);
|
||||||
@ -531,7 +531,7 @@ void restoreImageFromLaplacePyr(vector<Mat> &pyr)
|
|||||||
|
|
||||||
void restoreImageFromLaplacePyrGpu(vector<Mat> &pyr)
|
void restoreImageFromLaplacePyrGpu(vector<Mat> &pyr)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
if (pyr.empty())
|
if (pyr.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ using namespace std;
|
|||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace cv::detail;
|
using namespace cv::detail;
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
using namespace cv::gpu;
|
using namespace cv::gpu;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ private:
|
|||||||
float match_conf_;
|
float match_conf_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
class GpuMatcher : public FeaturesMatcher
|
class GpuMatcher : public FeaturesMatcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -204,7 +204,7 @@ void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat
|
|||||||
LOG("1->2 & 2->1 matches: " << matches_info.matches.size() << endl);
|
LOG("1->2 & 2->1 matches: " << matches_info.matches.size() << endl);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(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();
|
||||||
@ -432,7 +432,7 @@ void OrbFeaturesFinder::find(const Mat &image, ImageFeatures &features)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU)
|
#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
SurfFeaturesFinderGpu::SurfFeaturesFinderGpu(double hess_thresh, int num_octaves, int num_layers,
|
SurfFeaturesFinderGpu::SurfFeaturesFinderGpu(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)
|
||||||
{
|
{
|
||||||
@ -533,7 +533,7 @@ 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)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(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
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
#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"
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
#include "opencv2/gpu/gpu.hpp"
|
#include "opencv2/gpu/gpu.hpp"
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_NONFREE
|
#ifdef HAVE_OPENCV_NONFREE
|
||||||
|
@ -1318,7 +1318,7 @@ void GraphCutSeamFinder::find(const vector<Mat> &src, const vector<Point> &corne
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
void GraphCutSeamFinderGpu::find(const vector<Mat> &src, const vector<Point> &corners,
|
void GraphCutSeamFinderGpu::find(const vector<Mat> &src, const vector<Point> &corners,
|
||||||
vector<Mat> &masks)
|
vector<Mat> &masks)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,7 @@ Stitcher Stitcher::createDefault(bool try_use_gpu)
|
|||||||
stitcher.setFeaturesMatcher(new detail::BestOf2NearestMatcher(try_use_gpu));
|
stitcher.setFeaturesMatcher(new detail::BestOf2NearestMatcher(try_use_gpu));
|
||||||
stitcher.setBundleAdjuster(new detail::BundleAdjusterRay());
|
stitcher.setBundleAdjuster(new detail::BundleAdjusterRay());
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
if (try_use_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
if (try_use_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_OPENCV_NONFREE)
|
#if defined(HAVE_OPENCV_NONFREE)
|
||||||
|
@ -212,7 +212,7 @@ void SphericalWarper::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_b
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
Rect PlaneWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap)
|
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);
|
return buildMaps(src_size, K, R, Mat::zeros(3, 1, CV_32F), xmap, ymap);
|
||||||
|
@ -4,4 +4,4 @@ endif()
|
|||||||
|
|
||||||
set(the_description "Super Resolution")
|
set(the_description "Super Resolution")
|
||||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 -Wundef)
|
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 -Wundef)
|
||||||
ocv_define_module(superres opencv_imgproc opencv_video OPTIONAL opencv_gpu opencv_highgui opencv_ocl)
|
ocv_define_module(superres opencv_imgproc opencv_video OPTIONAL opencv_gpu opencv_highgui opencv_ocl ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||||
|
@ -1,2 +1,6 @@
|
|||||||
set(the_description "Video stabilization")
|
set(the_description "Video stabilization")
|
||||||
ocv_define_module(videostab opencv_imgproc opencv_features2d opencv_video opencv_photo opencv_calib3d opencv_highgui OPTIONAL opencv_gpu)
|
if(ENABLE_DYNAMIC_CUDA)
|
||||||
|
ocv_define_module(videostab opencv_imgproc opencv_features2d opencv_video opencv_photo opencv_calib3d opencv_highgui)
|
||||||
|
else()
|
||||||
|
ocv_define_module(videostab opencv_imgproc opencv_features2d opencv_video opencv_photo opencv_calib3d opencv_highgui OPTIONAL opencv_gpu)
|
||||||
|
endif()
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#include "opencv2/core/core.hpp"
|
#include "opencv2/core/core.hpp"
|
||||||
#include "opencv2/opencv_modules.hpp"
|
#include "opencv2/opencv_modules.hpp"
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
# include "opencv2/gpu/gpu.hpp"
|
# include "opencv2/gpu/gpu.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ public:
|
|||||||
OutputArray status, OutputArray errors);
|
OutputArray status, OutputArray errors);
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
class CV_EXPORTS DensePyrLkOptFlowEstimatorGpu
|
class CV_EXPORTS DensePyrLkOptFlowEstimatorGpu
|
||||||
: public PyrLkOptFlowEstimatorBase, public IDenseOptFlowEstimator
|
: public PyrLkOptFlowEstimatorBase, public IDenseOptFlowEstimator
|
||||||
{
|
{
|
||||||
|
@ -323,7 +323,7 @@ public:
|
|||||||
|
|
||||||
MotionInpainter::MotionInpainter()
|
MotionInpainter::MotionInpainter()
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
setOptFlowEstimator(new DensePyrLkOptFlowEstimatorGpu());
|
setOptFlowEstimator(new DensePyrLkOptFlowEstimatorGpu());
|
||||||
#else
|
#else
|
||||||
CV_Error(CV_StsNotImplemented, "Current implementation of MotionInpainter requires GPU");
|
CV_Error(CV_StsNotImplemented, "Current implementation of MotionInpainter requires GPU");
|
||||||
|
@ -59,7 +59,7 @@ void SparsePyrLkOptFlowEstimator::run(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
DensePyrLkOptFlowEstimatorGpu::DensePyrLkOptFlowEstimatorGpu()
|
DensePyrLkOptFlowEstimatorGpu::DensePyrLkOptFlowEstimatorGpu()
|
||||||
{
|
{
|
||||||
CV_Assert(gpu::getCudaEnabledDeviceCount() > 0);
|
CV_Assert(gpu::getCudaEnabledDeviceCount() > 0);
|
||||||
|
@ -355,7 +355,7 @@ int main(int argc, char* argv[])
|
|||||||
Ptr<FeaturesFinder> finder;
|
Ptr<FeaturesFinder> finder;
|
||||||
if (features_type == "surf")
|
if (features_type == "surf")
|
||||||
{
|
{
|
||||||
#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU)
|
#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
||||||
finder = new SurfFeaturesFinderGpu();
|
finder = new SurfFeaturesFinderGpu();
|
||||||
else
|
else
|
||||||
@ -543,7 +543,7 @@ int main(int argc, char* argv[])
|
|||||||
// Warp images and their masks
|
// Warp images and their masks
|
||||||
|
|
||||||
Ptr<WarperCreator> warper_creator;
|
Ptr<WarperCreator> warper_creator;
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
||||||
{
|
{
|
||||||
if (warp_type == "plane") warper_creator = new cv::PlaneWarperGpu();
|
if (warp_type == "plane") warper_creator = new cv::PlaneWarperGpu();
|
||||||
@ -608,7 +608,7 @@ int main(int argc, char* argv[])
|
|||||||
seam_finder = new detail::VoronoiSeamFinder();
|
seam_finder = new detail::VoronoiSeamFinder();
|
||||||
else if (seam_find_type == "gc_color")
|
else if (seam_find_type == "gc_color")
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
||||||
seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR);
|
seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR);
|
||||||
else
|
else
|
||||||
@ -617,7 +617,7 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
else if (seam_find_type == "gc_colorgrad")
|
else if (seam_find_type == "gc_colorgrad")
|
||||||
{
|
{
|
||||||
#ifdef HAVE_OPENCV_GPU
|
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||||
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
||||||
seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR_GRAD);
|
seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR_GRAD);
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user