From 0a65f2f4afd4ed7cab594575663bec58d24ca332 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Mon, 18 Mar 2013 16:14:37 +0400 Subject: [PATCH] merged gpunonfree and nonfree module --- modules/gpunonfree/CMakeLists.txt | 31 ----- .../doc/feature_detection_and_description.rst | 107 ---------------- modules/gpunonfree/doc/gpunonfree.rst | 9 -- modules/gpunonfree/perf/perf_main.cpp | 5 - modules/gpunonfree/perf/perf_precomp.cpp | 1 - modules/gpunonfree/perf/perf_precomp.hpp | 31 ----- modules/gpunonfree/src/precomp.cpp | 45 ------- modules/gpunonfree/src/precomp.hpp | 71 ----------- modules/gpunonfree/test/test_main.cpp | 119 ------------------ modules/gpunonfree/test/test_precomp.cpp | 42 ------- modules/gpunonfree/test/test_precomp.hpp | 69 ---------- modules/nonfree/CMakeLists.txt | 26 +++- .../doc/background_subtraction.rst} | 4 +- modules/nonfree/doc/feature_detection.rst | 103 +++++++++++++++ modules/nonfree/doc/nonfree.rst | 1 + .../include/opencv2/nonfree/gpu.hpp} | 14 ++- .../perf/perf_gpu.cpp} | 8 +- modules/nonfree/perf/perf_main.cpp | 2 +- modules/nonfree/perf/perf_precomp.hpp | 8 ++ .../{gpunonfree => nonfree}/src/cuda/surf.cu | 0 .../{gpunonfree => nonfree}/src/cuda/vibe.cu | 0 modules/nonfree/src/precomp.hpp | 15 +++ .../src/surf.cpp => nonfree/src/surf_gpu.cpp} | 11 +- .../src/vibe.cpp => nonfree/src/vibe_gpu.cpp} | 4 + .../test/test_gpu.cpp} | 11 +- modules/nonfree/test/test_main.cpp | 70 +++++++++++ modules/nonfree/test/test_precomp.hpp | 11 +- modules/stitching/CMakeLists.txt | 2 +- .../opencv2/stitching/detail/matchers.hpp | 7 +- modules/stitching/src/matchers.cpp | 2 +- modules/stitching/src/precomp.hpp | 9 +- modules/stitching/src/stitcher.cpp | 2 +- modules/superres/src/btv_l1_gpu.cpp | 2 +- samples/cpp/CMakeLists.txt | 7 -- samples/cpp/stitching_detailed.cpp | 2 +- samples/gpu/CMakeLists.txt | 8 +- samples/gpu/bgfg_segm.cpp | 18 +-- samples/gpu/performance/CMakeLists.txt | 4 +- samples/gpu/performance/tests.cpp | 6 +- samples/gpu/surf_keypoint_matcher.cpp | 6 +- 40 files changed, 300 insertions(+), 593 deletions(-) delete mode 100644 modules/gpunonfree/CMakeLists.txt delete mode 100644 modules/gpunonfree/doc/feature_detection_and_description.rst delete mode 100644 modules/gpunonfree/doc/gpunonfree.rst delete mode 100644 modules/gpunonfree/perf/perf_main.cpp delete mode 100644 modules/gpunonfree/perf/perf_precomp.cpp delete mode 100644 modules/gpunonfree/perf/perf_precomp.hpp delete mode 100644 modules/gpunonfree/src/precomp.cpp delete mode 100644 modules/gpunonfree/src/precomp.hpp delete mode 100644 modules/gpunonfree/test/test_main.cpp delete mode 100644 modules/gpunonfree/test/test_precomp.cpp delete mode 100644 modules/gpunonfree/test/test_precomp.hpp rename modules/{gpunonfree/doc/video.rst => nonfree/doc/background_subtraction.rst} (97%) rename modules/{gpunonfree/include/opencv2/gpunonfree/gpunonfree.hpp => nonfree/include/opencv2/nonfree/gpu.hpp} (96%) rename modules/{gpunonfree/perf/perf_gpunonfree.cpp => nonfree/perf/perf_gpu.cpp} (95%) rename modules/{gpunonfree => nonfree}/src/cuda/surf.cu (100%) rename modules/{gpunonfree => nonfree}/src/cuda/vibe.cu (100%) rename modules/{gpunonfree/src/surf.cpp => nonfree/src/surf_gpu.cpp} (99%) rename modules/{gpunonfree/src/vibe.cpp => nonfree/src/vibe_gpu.cpp} (98%) rename modules/{gpunonfree/test/test_gpunonfree.cpp => nonfree/test/test_gpu.cpp} (96%) diff --git a/modules/gpunonfree/CMakeLists.txt b/modules/gpunonfree/CMakeLists.txt deleted file mode 100644 index a975a61a43..0000000000 --- a/modules/gpunonfree/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -if(ANDROID OR IOS) - ocv_module_disable(gpunonfree) -endif() - -set(the_description "GPU-accelerated Computer Vision (non free)") -ocv_add_module(gpunonfree opencv_gpu opencv_nonfree) -ocv_module_include_directories() - -if(HAVE_CUDA) - ocv_source_group("Src\\Cuda" GLOB "src/cuda/*.cu") - ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include" ${CUDA_INCLUDE_DIRS}) - ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) - - file(GLOB lib_cuda "src/cuda/*.cu") - ocv_cuda_compile(cuda_objs ${lib_cuda}) - - set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY}) -else() - set(lib_cuda "") - set(cuda_objs "") - set(cuda_link_libs "") -endif() - -ocv_glob_module_sources(SOURCES ${lib_cuda} ${cuda_objs}) - -ocv_create_module(${cuda_link_libs}) -ocv_add_precompiled_headers(${the_module}) - -ocv_add_accuracy_tests() -ocv_add_perf_tests() - diff --git a/modules/gpunonfree/doc/feature_detection_and_description.rst b/modules/gpunonfree/doc/feature_detection_and_description.rst deleted file mode 100644 index 9cec66f539..0000000000 --- a/modules/gpunonfree/doc/feature_detection_and_description.rst +++ /dev/null @@ -1,107 +0,0 @@ -Feature Detection and Description -================================= - -.. highlight:: cpp - - - -gpu::SURF_GPU -------------- -.. ocv:class:: gpu::SURF_GPU - -Class used for extracting Speeded Up Robust Features (SURF) from an image. :: - - class SURF_GPU - { - public: - enum KeypointLayout - { - X_ROW = 0, - Y_ROW, - LAPLACIAN_ROW, - OCTAVE_ROW, - SIZE_ROW, - ANGLE_ROW, - HESSIAN_ROW, - ROWS_COUNT - }; - - //! the default constructor - SURF_GPU(); - //! the full constructor taking all the necessary parameters - explicit SURF_GPU(double _hessianThreshold, int _nOctaves=4, - int _nOctaveLayers=2, bool _extended=false, float _keypointsRatio=0.01f); - - //! returns the descriptor size in float's (64 or 128) - int descriptorSize() const; - - //! upload host keypoints to device memory - void uploadKeypoints(const vector& keypoints, - GpuMat& keypointsGPU); - //! download keypoints from device to host memory - void downloadKeypoints(const GpuMat& keypointsGPU, - vector& keypoints); - - //! download descriptors from device to host memory - void downloadDescriptors(const GpuMat& descriptorsGPU, - vector& descriptors); - - void operator()(const GpuMat& img, const GpuMat& mask, - GpuMat& keypoints); - - void operator()(const GpuMat& img, const GpuMat& mask, - GpuMat& keypoints, GpuMat& descriptors, - bool useProvidedKeypoints = false, - bool calcOrientation = true); - - void operator()(const GpuMat& img, const GpuMat& mask, - std::vector& keypoints); - - void operator()(const GpuMat& img, const GpuMat& mask, - std::vector& keypoints, GpuMat& descriptors, - bool useProvidedKeypoints = false, - bool calcOrientation = true); - - void operator()(const GpuMat& img, const GpuMat& mask, - std::vector& keypoints, - std::vector& descriptors, - bool useProvidedKeypoints = false, - bool calcOrientation = true); - - void releaseMemory(); - - // SURF parameters - double hessianThreshold; - int nOctaves; - int nOctaveLayers; - bool extended; - bool upright; - - //! max keypoints = keypointsRatio * img.size().area() - float keypointsRatio; - - GpuMat sum, mask1, maskSum, intBuffer; - - GpuMat det, trace; - - GpuMat maxPosBuffer; - }; - - -The class ``SURF_GPU`` implements Speeded Up Robust Features descriptor. There is a fast multi-scale Hessian keypoint detector that can be used to find the keypoints (which is the default option). But the descriptors can also be computed for the user-specified keypoints. Only 8-bit grayscale images are supported. - -The class ``SURF_GPU`` can store results in the GPU and CPU memory. It provides functions to convert results between CPU and GPU version ( ``uploadKeypoints``, ``downloadKeypoints``, ``downloadDescriptors`` ). The format of CPU results is the same as ``SURF`` results. GPU results are stored in ``GpuMat``. The ``keypoints`` matrix is :math:`\texttt{nFeatures} \times 7` matrix with the ``CV_32FC1`` type. - -* ``keypoints.ptr(X_ROW)[i]`` contains x coordinate of the i-th feature. -* ``keypoints.ptr(Y_ROW)[i]`` contains y coordinate of the i-th feature. -* ``keypoints.ptr(LAPLACIAN_ROW)[i]`` contains the laplacian sign of the i-th feature. -* ``keypoints.ptr(OCTAVE_ROW)[i]`` contains the octave of the i-th feature. -* ``keypoints.ptr(SIZE_ROW)[i]`` contains the size of the i-th feature. -* ``keypoints.ptr(ANGLE_ROW)[i]`` contain orientation of the i-th feature. -* ``keypoints.ptr(HESSIAN_ROW)[i]`` contains the response of the i-th feature. - -The ``descriptors`` matrix is :math:`\texttt{nFeatures} \times \texttt{descriptorSize}` matrix with the ``CV_32FC1`` type. - -The class ``SURF_GPU`` uses some buffers and provides access to it. All buffers can be safely released between function calls. - -.. seealso:: :ocv:class:`SURF` diff --git a/modules/gpunonfree/doc/gpunonfree.rst b/modules/gpunonfree/doc/gpunonfree.rst deleted file mode 100644 index 4c2b71fe26..0000000000 --- a/modules/gpunonfree/doc/gpunonfree.rst +++ /dev/null @@ -1,9 +0,0 @@ -****************************************************** -gpunonfree. GPU-accelerated Computer Vision (non free) -****************************************************** - -.. toctree:: - :maxdepth: 1 - - feature_detection_and_description - video diff --git a/modules/gpunonfree/perf/perf_main.cpp b/modules/gpunonfree/perf/perf_main.cpp deleted file mode 100644 index 75e3ca651b..0000000000 --- a/modules/gpunonfree/perf/perf_main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "perf_precomp.hpp" - -using namespace perf; - -CV_PERF_TEST_MAIN(gpunonfree, printCudaInfo()) diff --git a/modules/gpunonfree/perf/perf_precomp.cpp b/modules/gpunonfree/perf/perf_precomp.cpp deleted file mode 100644 index 8552ac3d42..0000000000 --- a/modules/gpunonfree/perf/perf_precomp.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "perf_precomp.hpp" diff --git a/modules/gpunonfree/perf/perf_precomp.hpp b/modules/gpunonfree/perf/perf_precomp.hpp deleted file mode 100644 index 410eaecfdf..0000000000 --- a/modules/gpunonfree/perf/perf_precomp.hpp +++ /dev/null @@ -1,31 +0,0 @@ -#ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wmissing-declarations" -# if defined __clang__ || defined __APPLE__ -# pragma GCC diagnostic ignored "-Wmissing-prototypes" -# pragma GCC diagnostic ignored "-Wextra" -# endif -#endif - -#ifndef __OPENCV_PERF_PRECOMP_HPP__ -#define __OPENCV_PERF_PRECOMP_HPP__ - -#include -#include - -#include "cvconfig.h" - -#include "opencv2/ts/ts.hpp" -#include "opencv2/ts/ts_perf.hpp" -#include "opencv2/ts/gpu_perf.hpp" - -#include "opencv2/core/core.hpp" -#include "opencv2/highgui/highgui.hpp" -#include "opencv2/gpu/gpu.hpp" -#include "opencv2/gpunonfree/gpunonfree.hpp" -#include "opencv2/nonfree/nonfree.hpp" - -#ifdef GTEST_CREATE_SHARED_LIBRARY -#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined -#endif - -#endif diff --git a/modules/gpunonfree/src/precomp.cpp b/modules/gpunonfree/src/precomp.cpp deleted file mode 100644 index 75eb6935d0..0000000000 --- a/modules/gpunonfree/src/precomp.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// Intel License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000, Intel Corporation, all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of Intel Corporation may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ - -#include "precomp.hpp" - -/* End of file. */ - diff --git a/modules/gpunonfree/src/precomp.hpp b/modules/gpunonfree/src/precomp.hpp deleted file mode 100644 index 59a5a2cdec..0000000000 --- a/modules/gpunonfree/src/precomp.hpp +++ /dev/null @@ -1,71 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. -// Copyright (C) 2009, Willow Garage Inc., all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of the copyright holders may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ - -#ifndef __OPENCV_PRECOMP_H__ -#define __OPENCV_PRECOMP_H__ - -#if defined _MSC_VER && _MSC_VER >= 1200 - #pragma warning( disable: 4251 4710 4711 4514 4996 ) -#endif - -#ifdef HAVE_CVCONFIG_H - #include "cvconfig.h" -#endif - -#include - -#include "opencv2/gpu/gpu.hpp" -#include "opencv2/gpunonfree/gpunonfree.hpp" - -#ifdef HAVE_CUDA - #include "opencv2/gpu/stream_accessor.hpp" - #include "opencv2/gpu/device/common.hpp" - - static inline void throw_nogpu() { CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform"); } - -#else /* defined(HAVE_CUDA) */ - - static inline void throw_nogpu() { CV_Error(CV_GpuNotSupported, "The library is compiled without GPU support"); } - -#endif /* defined(HAVE_CUDA) */ - -#endif /* __OPENCV_PRECOMP_H__ */ diff --git a/modules/gpunonfree/test/test_main.cpp b/modules/gpunonfree/test/test_main.cpp deleted file mode 100644 index 4c15ff95e9..0000000000 --- a/modules/gpunonfree/test/test_main.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// Intel License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000, Intel Corporation, all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of Intel Corporation may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ - -#include "test_precomp.hpp" - -#ifdef HAVE_CUDA - -using namespace std; -using namespace cv; -using namespace cv::gpu; -using namespace cvtest; -using namespace testing; - -int main(int argc, char** argv) -{ - try - { - const char* keys = - "{ h | help ? | false | Print help}" - "{ i | info | false | Print information about system and exit }" - "{ d | device | -1 | Device on which tests will be executed (-1 means all devices) }" - ; - - CommandLineParser cmd(argc, (const char**)argv, keys); - - if (cmd.get("help")) - { - cmd.printParams(); - return 0; - } - - printCudaInfo(); - - if (cmd.get("info")) - { - return 0; - } - - int device = cmd.get("device"); - if (device < 0) - { - DeviceManager::instance().loadAll(); - - cout << "Run tests on all supported devices \n" << endl; - } - else - { - DeviceManager::instance().load(device); - - DeviceInfo info(device); - cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl; - } - - TS::ptr()->init("gpu"); - InitGoogleTest(&argc, argv); - - return RUN_ALL_TESTS(); - } - catch (const exception& e) - { - cerr << e.what() << endl; - return -1; - } - catch (...) - { - cerr << "Unknown error" << endl; - return -1; - } - - return 0; -} - -#else // HAVE_CUDA - -int main() -{ - std::cerr << "OpenCV was built without CUDA support" << std::endl; - return 0; -} - -#endif // HAVE_CUDA diff --git a/modules/gpunonfree/test/test_precomp.cpp b/modules/gpunonfree/test/test_precomp.cpp deleted file mode 100644 index 8121ae405b..0000000000 --- a/modules/gpunonfree/test/test_precomp.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// Intel License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000, Intel Corporation, all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of Intel Corporation may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ - -#include "test_precomp.hpp" diff --git a/modules/gpunonfree/test/test_precomp.hpp b/modules/gpunonfree/test/test_precomp.hpp deleted file mode 100644 index 5030a0d391..0000000000 --- a/modules/gpunonfree/test/test_precomp.hpp +++ /dev/null @@ -1,69 +0,0 @@ -/*M/////////////////////////////////////////////////////////////////////////////////////// -// -// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. -// -// By downloading, copying, installing or using the software you agree to this license. -// If you do not agree to this license, do not download, install, -// copy or use the software. -// -// -// Intel License Agreement -// For Open Source Computer Vision Library -// -// Copyright (C) 2000, Intel Corporation, all rights reserved. -// Third party copyrights are property of their respective owners. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// * Redistribution's of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// * Redistribution's in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// * The name of Intel Corporation may not be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// This software is provided by the copyright holders and contributors "as is" and -// any express or implied warranties, including, but not limited to, the implied -// warranties of merchantability and fitness for a particular purpose are disclaimed. -// In no event shall the Intel Corporation or contributors be liable for any direct, -// indirect, incidental, special, exemplary, or consequential damages -// (including, but not limited to, procurement of substitute goods or services; -// loss of use, data, or profits; or business interruption) however caused -// and on any theory of liability, whether in contract, strict liability, -// or tort (including negligence or otherwise) arising in any way out of -// the use of this software, even if advised of the possibility of such damage. -// -//M*/ - -#ifdef __GNUC__ -# pragma GCC diagnostic ignored "-Wmissing-declarations" -# if defined __clang__ || defined __APPLE__ -# pragma GCC diagnostic ignored "-Wmissing-prototypes" -# pragma GCC diagnostic ignored "-Wextra" -# endif -#endif - -#ifndef __OPENCV_TEST_PRECOMP_HPP__ -#define __OPENCV_TEST_PRECOMP_HPP__ - -#include "cvconfig.h" - -#include - -#ifdef HAVE_CUDA - #include "opencv2/ts/ts.hpp" - #include "opencv2/ts/ts_perf.hpp" - #include "opencv2/ts/gpu_test.hpp" - - #include "opencv2/core/core.hpp" - #include "opencv2/highgui/highgui.hpp" - #include "opencv2/gpu/gpu.hpp" - #include "opencv2/gpunonfree/gpunonfree.hpp" - #include "opencv2/nonfree/nonfree.hpp" -#endif - -#endif diff --git a/modules/nonfree/CMakeLists.txt b/modules/nonfree/CMakeLists.txt index eeaf53a6f8..e00cf8f247 100644 --- a/modules/nonfree/CMakeLists.txt +++ b/modules/nonfree/CMakeLists.txt @@ -3,4 +3,28 @@ if(BUILD_ANDROID_PACKAGE) endif() set(the_description "Functionality with possible limitations on the use") -ocv_define_module(nonfree opencv_imgproc opencv_features2d opencv_calib3d) +ocv_add_module(nonfree opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_gpu) +ocv_module_include_directories() + +if(HAVE_CUDA AND HAVE_opencv_gpu) + ocv_source_group("Src\\Cuda" GLOB "src/cuda/*.cu") + ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include" ${CUDA_INCLUDE_DIRS}) + ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) + + file(GLOB lib_cuda "src/cuda/*.cu") + ocv_cuda_compile(cuda_objs ${lib_cuda}) + + set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY}) +else() + set(lib_cuda "") + set(cuda_objs "") + set(cuda_link_libs "") +endif() + +ocv_glob_module_sources(SOURCES ${lib_cuda} ${cuda_objs}) + +ocv_create_module(${cuda_link_libs}) +ocv_add_precompiled_headers(${the_module}) + +ocv_add_accuracy_tests() +ocv_add_perf_tests() diff --git a/modules/gpunonfree/doc/video.rst b/modules/nonfree/doc/background_subtraction.rst similarity index 97% rename from modules/gpunonfree/doc/video.rst rename to modules/nonfree/doc/background_subtraction.rst index 4fdfacc07d..11603ca566 100644 --- a/modules/gpunonfree/doc/video.rst +++ b/modules/nonfree/doc/background_subtraction.rst @@ -1,5 +1,5 @@ -Video Analysis -============== +Background Subtraction +====================== .. highlight:: cpp diff --git a/modules/nonfree/doc/feature_detection.rst b/modules/nonfree/doc/feature_detection.rst index e4ac357429..bb2f6b0387 100644 --- a/modules/nonfree/doc/feature_detection.rst +++ b/modules/nonfree/doc/feature_detection.rst @@ -127,3 +127,106 @@ Detects keypoints and computes SURF descriptors for them. The function is parallelized with the TBB library. If you are using the C version, make sure you call ``cv::initModule_nonfree()`` from ``nonfree/nonfree.hpp``. + + + +gpu::SURF_GPU +------------- +.. ocv:class:: gpu::SURF_GPU + +Class used for extracting Speeded Up Robust Features (SURF) from an image. :: + + class SURF_GPU + { + public: + enum KeypointLayout + { + X_ROW = 0, + Y_ROW, + LAPLACIAN_ROW, + OCTAVE_ROW, + SIZE_ROW, + ANGLE_ROW, + HESSIAN_ROW, + ROWS_COUNT + }; + + //! the default constructor + SURF_GPU(); + //! the full constructor taking all the necessary parameters + explicit SURF_GPU(double _hessianThreshold, int _nOctaves=4, + int _nOctaveLayers=2, bool _extended=false, float _keypointsRatio=0.01f); + + //! returns the descriptor size in float's (64 or 128) + int descriptorSize() const; + + //! upload host keypoints to device memory + void uploadKeypoints(const vector& keypoints, + GpuMat& keypointsGPU); + //! download keypoints from device to host memory + void downloadKeypoints(const GpuMat& keypointsGPU, + vector& keypoints); + + //! download descriptors from device to host memory + void downloadDescriptors(const GpuMat& descriptorsGPU, + vector& descriptors); + + void operator()(const GpuMat& img, const GpuMat& mask, + GpuMat& keypoints); + + void operator()(const GpuMat& img, const GpuMat& mask, + GpuMat& keypoints, GpuMat& descriptors, + bool useProvidedKeypoints = false, + bool calcOrientation = true); + + void operator()(const GpuMat& img, const GpuMat& mask, + std::vector& keypoints); + + void operator()(const GpuMat& img, const GpuMat& mask, + std::vector& keypoints, GpuMat& descriptors, + bool useProvidedKeypoints = false, + bool calcOrientation = true); + + void operator()(const GpuMat& img, const GpuMat& mask, + std::vector& keypoints, + std::vector& descriptors, + bool useProvidedKeypoints = false, + bool calcOrientation = true); + + void releaseMemory(); + + // SURF parameters + double hessianThreshold; + int nOctaves; + int nOctaveLayers; + bool extended; + bool upright; + + //! max keypoints = keypointsRatio * img.size().area() + float keypointsRatio; + + GpuMat sum, mask1, maskSum, intBuffer; + + GpuMat det, trace; + + GpuMat maxPosBuffer; + }; + + +The class ``SURF_GPU`` implements Speeded Up Robust Features descriptor. There is a fast multi-scale Hessian keypoint detector that can be used to find the keypoints (which is the default option). But the descriptors can also be computed for the user-specified keypoints. Only 8-bit grayscale images are supported. + +The class ``SURF_GPU`` can store results in the GPU and CPU memory. It provides functions to convert results between CPU and GPU version ( ``uploadKeypoints``, ``downloadKeypoints``, ``downloadDescriptors`` ). The format of CPU results is the same as ``SURF`` results. GPU results are stored in ``GpuMat``. The ``keypoints`` matrix is :math:`\texttt{nFeatures} \times 7` matrix with the ``CV_32FC1`` type. + +* ``keypoints.ptr(X_ROW)[i]`` contains x coordinate of the i-th feature. +* ``keypoints.ptr(Y_ROW)[i]`` contains y coordinate of the i-th feature. +* ``keypoints.ptr(LAPLACIAN_ROW)[i]`` contains the laplacian sign of the i-th feature. +* ``keypoints.ptr(OCTAVE_ROW)[i]`` contains the octave of the i-th feature. +* ``keypoints.ptr(SIZE_ROW)[i]`` contains the size of the i-th feature. +* ``keypoints.ptr(ANGLE_ROW)[i]`` contain orientation of the i-th feature. +* ``keypoints.ptr(HESSIAN_ROW)[i]`` contains the response of the i-th feature. + +The ``descriptors`` matrix is :math:`\texttt{nFeatures} \times \texttt{descriptorSize}` matrix with the ``CV_32FC1`` type. + +The class ``SURF_GPU`` uses some buffers and provides access to it. All buffers can be safely released between function calls. + +.. seealso:: :ocv:class:`SURF` diff --git a/modules/nonfree/doc/nonfree.rst b/modules/nonfree/doc/nonfree.rst index e524ea82f8..f8fa1d6eba 100644 --- a/modules/nonfree/doc/nonfree.rst +++ b/modules/nonfree/doc/nonfree.rst @@ -8,3 +8,4 @@ The module contains algorithms that may be patented in some countries or have so :maxdepth: 2 feature_detection + background_subtraction diff --git a/modules/gpunonfree/include/opencv2/gpunonfree/gpunonfree.hpp b/modules/nonfree/include/opencv2/nonfree/gpu.hpp similarity index 96% rename from modules/gpunonfree/include/opencv2/gpunonfree/gpunonfree.hpp rename to modules/nonfree/include/opencv2/nonfree/gpu.hpp index 40d9cfd2bc..911022669d 100644 --- a/modules/gpunonfree/include/opencv2/gpunonfree/gpunonfree.hpp +++ b/modules/nonfree/include/opencv2/nonfree/gpu.hpp @@ -40,12 +40,12 @@ // //M*/ -#ifndef __OPENCV_GPUNONFREE_HPP__ -#define __OPENCV_GPUNONFREE_HPP__ +#ifndef __OPENCV_NONFREE_GPU_HPP__ +#define __OPENCV_NONFREE_GPU_HPP__ -#ifndef SKIP_INCLUDES -#include -#endif +#include "opencv2/opencv_modules.hpp" + +#if defined(HAVE_OPENCV_GPU) #include "opencv2/gpu/gpu.hpp" @@ -164,4 +164,6 @@ private: } // namespace cv -#endif /* __OPENCV_GPUNONFREE_HPP__ */ +#endif // defined(HAVE_OPENCV_GPU) + +#endif // __OPENCV_NONFREE_GPU_HPP__ diff --git a/modules/gpunonfree/perf/perf_gpunonfree.cpp b/modules/nonfree/perf/perf_gpu.cpp similarity index 95% rename from modules/gpunonfree/perf/perf_gpunonfree.cpp rename to modules/nonfree/perf/perf_gpu.cpp index 4a27b77258..a68fb6a0ea 100644 --- a/modules/gpunonfree/perf/perf_gpunonfree.cpp +++ b/modules/nonfree/perf/perf_gpu.cpp @@ -4,12 +4,14 @@ using namespace std; using namespace testing; using namespace perf; +#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA) + ////////////////////////////////////////////////////////////////////// // SURF DEF_PARAM_TEST_1(Image, string); -PERF_TEST_P(Image, Features2D_SURF, +PERF_TEST_P(Image, GPU_SURF, Values("gpu/perf/aloe.png")) { declare.time(50.0); @@ -55,7 +57,7 @@ PERF_TEST_P(Image, Features2D_SURF, DEF_PARAM_TEST(Video_Cn, string, int); -PERF_TEST_P(Video_Cn, Video_VIBE, +PERF_TEST_P(Video_Cn, GPU_VIBE, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), GPU_CHANNELS_1_3_4)) { @@ -116,3 +118,5 @@ PERF_TEST_P(Video_Cn, Video_VIBE, FAIL_NO_CPU(); } } + +#endif diff --git a/modules/nonfree/perf/perf_main.cpp b/modules/nonfree/perf/perf_main.cpp index 3fcca19c3c..444ace981a 100644 --- a/modules/nonfree/perf/perf_main.cpp +++ b/modules/nonfree/perf/perf_main.cpp @@ -1,3 +1,3 @@ #include "perf_precomp.hpp" -CV_PERF_TEST_MAIN(nonfree) +CV_PERF_TEST_MAIN(nonfree, perf::printCudaInfo()) diff --git a/modules/nonfree/perf/perf_precomp.hpp b/modules/nonfree/perf/perf_precomp.hpp index 79a368d712..3dafdb206b 100644 --- a/modules/nonfree/perf/perf_precomp.hpp +++ b/modules/nonfree/perf/perf_precomp.hpp @@ -9,10 +9,18 @@ #ifndef __OPENCV_PERF_PRECOMP_HPP__ #define __OPENCV_PERF_PRECOMP_HPP__ +#include "cvconfig.h" +#include "opencv2/opencv_modules.hpp" + #include "opencv2/ts/ts.hpp" +#include "opencv2/ts/gpu_perf.hpp" #include "opencv2/nonfree/nonfree.hpp" #include "opencv2/highgui/highgui.hpp" +#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA) + #include "opencv2/nonfree/gpu.hpp" +#endif + #ifdef GTEST_CREATE_SHARED_LIBRARY #error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined #endif diff --git a/modules/gpunonfree/src/cuda/surf.cu b/modules/nonfree/src/cuda/surf.cu similarity index 100% rename from modules/gpunonfree/src/cuda/surf.cu rename to modules/nonfree/src/cuda/surf.cu diff --git a/modules/gpunonfree/src/cuda/vibe.cu b/modules/nonfree/src/cuda/vibe.cu similarity index 100% rename from modules/gpunonfree/src/cuda/vibe.cu rename to modules/nonfree/src/cuda/vibe.cu diff --git a/modules/nonfree/src/precomp.hpp b/modules/nonfree/src/precomp.hpp index 1730b8b10d..51157d26e2 100644 --- a/modules/nonfree/src/precomp.hpp +++ b/modules/nonfree/src/precomp.hpp @@ -47,8 +47,23 @@ #include "cvconfig.h" #endif +#include "opencv2/opencv_modules.hpp" + #include "opencv2/nonfree/nonfree.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/core/internal.hpp" +#if defined(HAVE_OPENCV_GPU) + #include "opencv2/nonfree/gpu.hpp" + + #if defined(HAVE_CUDA) + #include "opencv2/gpu/stream_accessor.hpp" + #include "opencv2/gpu/device/common.hpp" + + static inline void throw_nogpu() { CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform"); } + #else + static inline void throw_nogpu() { CV_Error(CV_GpuNotSupported, "The library is compiled without GPU support"); } + #endif +#endif + #endif diff --git a/modules/gpunonfree/src/surf.cpp b/modules/nonfree/src/surf_gpu.cpp similarity index 99% rename from modules/gpunonfree/src/surf.cpp rename to modules/nonfree/src/surf_gpu.cpp index 024087fe5a..dec9c0d2dc 100644 --- a/modules/gpunonfree/src/surf.cpp +++ b/modules/nonfree/src/surf_gpu.cpp @@ -42,11 +42,12 @@ #include "precomp.hpp" +#if defined(HAVE_OPENCV_GPU) + using namespace cv; using namespace cv::gpu; -using namespace std; -#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) +#if !defined (HAVE_CUDA) cv::gpu::SURF_GPU::SURF_GPU() { throw_nogpu(); } cv::gpu::SURF_GPU::SURF_GPU(double, int, int, bool, float, bool) { throw_nogpu(); } @@ -61,7 +62,7 @@ void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, vector&, vector&, bool) { throw_nogpu(); } void cv::gpu::SURF_GPU::releaseMemory() { throw_nogpu(); } -#else /* !defined (HAVE_CUDA) */ +#else // !defined (HAVE_CUDA) namespace cv { namespace gpu { namespace device { @@ -416,4 +417,6 @@ void cv::gpu::SURF_GPU::releaseMemory() maxPosBuffer.release(); } -#endif /* !defined (HAVE_CUDA) */ +#endif // !defined (HAVE_CUDA) + +#endif // defined(HAVE_OPENCV_GPU) diff --git a/modules/gpunonfree/src/vibe.cpp b/modules/nonfree/src/vibe_gpu.cpp similarity index 98% rename from modules/gpunonfree/src/vibe.cpp rename to modules/nonfree/src/vibe_gpu.cpp index ff7e58082e..e34862765d 100644 --- a/modules/gpunonfree/src/vibe.cpp +++ b/modules/nonfree/src/vibe_gpu.cpp @@ -42,6 +42,8 @@ #include "precomp.hpp" +#if defined(HAVE_OPENCV_GPU) + #if !defined HAVE_CUDA || defined(CUDA_DISABLER) cv::gpu::VIBE_GPU::VIBE_GPU(unsigned long) { throw_nogpu(); } @@ -135,3 +137,5 @@ void cv::gpu::VIBE_GPU::release() } #endif + +#endif // defined(HAVE_OPENCV_GPU) diff --git a/modules/gpunonfree/test/test_gpunonfree.cpp b/modules/nonfree/test/test_gpu.cpp similarity index 96% rename from modules/gpunonfree/test/test_gpunonfree.cpp rename to modules/nonfree/test/test_gpu.cpp index 2d4e179e19..2993cf5676 100644 --- a/modules/gpunonfree/test/test_gpunonfree.cpp +++ b/modules/nonfree/test/test_gpu.cpp @@ -41,7 +41,7 @@ #include "test_precomp.hpp" -#ifdef HAVE_CUDA +#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA) using namespace cvtest; @@ -81,7 +81,7 @@ PARAM_TEST_CASE(SURF, cv::gpu::DeviceInfo, SURF_HessianThreshold, SURF_Octaves, GPU_TEST_P(SURF, Detector) { - cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE); + cv::Mat image = readImage("../gpu/features2d/aloe.png", cv::IMREAD_GRAYSCALE); ASSERT_FALSE(image.empty()); cv::gpu::SURF_GPU surf; @@ -129,7 +129,7 @@ GPU_TEST_P(SURF, Detector) GPU_TEST_P(SURF, Detector_Masked) { - cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE); + cv::Mat image = readImage("../gpu/features2d/aloe.png", cv::IMREAD_GRAYSCALE); ASSERT_FALSE(image.empty()); cv::Mat mask(image.size(), CV_8UC1, cv::Scalar::all(1)); @@ -180,7 +180,7 @@ GPU_TEST_P(SURF, Detector_Masked) GPU_TEST_P(SURF, Descriptor) { - cv::Mat image = readImage("features2d/aloe.png", cv::IMREAD_GRAYSCALE); + cv::Mat image = readImage("../gpu/features2d/aloe.png", cv::IMREAD_GRAYSCALE); ASSERT_FALSE(image.empty()); cv::gpu::SURF_GPU surf; @@ -282,5 +282,4 @@ INSTANTIATE_TEST_CASE_P(GPU_Video, VIBE, testing::Combine( testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4)), WHOLE_SUBMAT)); -#endif // HAVE_CUDA - +#endif diff --git a/modules/nonfree/test/test_main.cpp b/modules/nonfree/test/test_main.cpp index 6b24993447..bf4c6c0c3b 100644 --- a/modules/nonfree/test/test_main.cpp +++ b/modules/nonfree/test/test_main.cpp @@ -1,3 +1,73 @@ #include "test_precomp.hpp" +#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA) + +using namespace cv; +using namespace cv::gpu; +using namespace cvtest; +using namespace testing; + +int main(int argc, char** argv) +{ + try + { + const char* keys = + "{ h | help ? | false | Print help}" + "{ i | info | false | Print information about system and exit }" + "{ d | device | -1 | Device on which tests will be executed (-1 means all devices) }" + ; + + CommandLineParser cmd(argc, (const char**)argv, keys); + + if (cmd.get("help")) + { + cmd.printParams(); + return 0; + } + + printCudaInfo(); + + if (cmd.get("info")) + { + return 0; + } + + int device = cmd.get("device"); + if (device < 0) + { + DeviceManager::instance().loadAll(); + + std::cout << "Run tests on all supported devices \n" << std::endl; + } + else + { + DeviceManager::instance().load(device); + + DeviceInfo info(device); + std::cout << "Run tests on device " << device << " [" << info.name() << "] \n" << std::endl; + } + + TS::ptr()->init("cv"); + InitGoogleTest(&argc, argv); + + return RUN_ALL_TESTS(); + } + catch (const std::exception& e) + { + std::cerr << e.what() << std::endl; + return -1; + } + catch (...) + { + std::cerr << "Unknown error" << std::endl; + return -1; + } + + return 0; +} + +#else // HAVE_CUDA + CV_TEST_MAIN("cv") + +#endif // HAVE_CUDA diff --git a/modules/nonfree/test/test_precomp.hpp b/modules/nonfree/test/test_precomp.hpp index 062ab7bb13..14c4b2a874 100644 --- a/modules/nonfree/test/test_precomp.hpp +++ b/modules/nonfree/test/test_precomp.hpp @@ -9,10 +9,19 @@ #ifndef __OPENCV_TEST_PRECOMP_HPP__ #define __OPENCV_TEST_PRECOMP_HPP__ +#include + +#include "cvconfig.h" +#include "opencv2/opencv_modules.hpp" + #include "opencv2/ts/ts.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/nonfree/nonfree.hpp" -#include + +#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA) + #include "opencv2/ts/gpu_test.hpp" + #include "opencv2/nonfree/gpu.hpp" +#endif #endif diff --git a/modules/stitching/CMakeLists.txt b/modules/stitching/CMakeLists.txt index b310a8eb65..5d48bd378f 100644 --- a/modules/stitching/CMakeLists.txt +++ b/modules/stitching/CMakeLists.txt @@ -1,3 +1,3 @@ set(the_description "Images stitching") -ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect OPTIONAL opencv_gpu opencv_gpunonfree opencv_nonfree) +ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect OPTIONAL opencv_gpu opencv_nonfree) diff --git a/modules/stitching/include/opencv2/stitching/detail/matchers.hpp b/modules/stitching/include/opencv2/stitching/detail/matchers.hpp index 9332d94660..108cd0face 100644 --- a/modules/stitching/include/opencv2/stitching/detail/matchers.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/matchers.hpp @@ -47,8 +47,9 @@ #include "opencv2/features2d/features2d.hpp" #include "opencv2/opencv_modules.hpp" -#ifdef HAVE_OPENCV_GPUNONFREE -#include "opencv2/gpunonfree/gpunonfree.hpp" + +#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) + #include "opencv2/nonfree/gpu.hpp" #endif namespace cv { @@ -103,7 +104,7 @@ private: }; -#ifdef HAVE_OPENCV_GPUNONFREE +#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) class CV_EXPORTS SurfFeaturesFinderGpu : public FeaturesFinder { public: diff --git a/modules/stitching/src/matchers.cpp b/modules/stitching/src/matchers.cpp index 07845d2770..2231d13681 100644 --- a/modules/stitching/src/matchers.cpp +++ b/modules/stitching/src/matchers.cpp @@ -429,7 +429,7 @@ void OrbFeaturesFinder::find(const Mat &image, ImageFeatures &features) } } -#ifdef HAVE_OPENCV_GPUNONFREE +#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) SurfFeaturesFinderGpu::SurfFeaturesFinderGpu(double hess_thresh, int num_octaves, int num_layers, int num_octaves_descr, int num_layers_descr) { diff --git a/modules/stitching/src/precomp.hpp b/modules/stitching/src/precomp.hpp index 0aade9faa3..4849ace1eb 100644 --- a/modules/stitching/src/precomp.hpp +++ b/modules/stitching/src/precomp.hpp @@ -71,10 +71,11 @@ #include "opencv2/features2d/features2d.hpp" #include "opencv2/calib3d/calib3d.hpp" #ifdef HAVE_OPENCV_GPU -# include "opencv2/gpu/gpu.hpp" -#endif -#ifdef HAVE_OPENCV_GPUNONFREE -# include "opencv2/gpunonfree/gpunonfree.hpp" + #include "opencv2/gpu/gpu.hpp" + + #ifdef HAVE_OPENCV_NONFREE + #include "opencv2/nonfree/gpu.hpp" + #endif #endif #include "../../imgproc/src/gcgraph.hpp" diff --git a/modules/stitching/src/stitcher.cpp b/modules/stitching/src/stitcher.cpp index 2a2fe0f6b1..5da26f6dbf 100644 --- a/modules/stitching/src/stitcher.cpp +++ b/modules/stitching/src/stitcher.cpp @@ -61,7 +61,7 @@ Stitcher Stitcher::createDefault(bool try_use_gpu) #ifdef HAVE_OPENCV_GPU if (try_use_gpu && gpu::getCudaEnabledDeviceCount() > 0) { -#ifdef HAVE_OPENCV_GPUNONFREE +#if defined(HAVE_OPENCV_NONFREE) stitcher.setFeaturesFinder(new detail::SurfFeaturesFinderGpu()); #else stitcher.setFeaturesFinder(new detail::OrbFeaturesFinder()); diff --git a/modules/superres/src/btv_l1_gpu.cpp b/modules/superres/src/btv_l1_gpu.cpp index 4820d716a9..4f7b4f15a4 100644 --- a/modules/superres/src/btv_l1_gpu.cpp +++ b/modules/superres/src/btv_l1_gpu.cpp @@ -51,7 +51,7 @@ using namespace cv::gpu; using namespace cv::superres; using namespace cv::superres::detail; -#ifndef HAVE_CUDA +#if !defined(HAVE_CUDA) || !defined(HAVE_OPENCV_GPU) Ptr cv::superres::createSuperResolution_BTVL1_GPU() { diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index 3f42f43973..f69382ac66 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -20,10 +20,6 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include") endif() - if(HAVE_opencv_gpunonfree) - ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpunonfree/include") - endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function") endif() @@ -48,9 +44,6 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) if(HAVE_opencv_gpu) target_link_libraries(${the_target} opencv_gpu) endif() - if(HAVE_opencv_gpunonfree) - target_link_libraries(${the_target} opencv_gpunonfree) - endif() set_target_properties(${the_target} PROPERTIES OUTPUT_NAME "cpp-${sample_kind}-${name}" diff --git a/samples/cpp/stitching_detailed.cpp b/samples/cpp/stitching_detailed.cpp index fe4ad8779e..e795fdb8f6 100644 --- a/samples/cpp/stitching_detailed.cpp +++ b/samples/cpp/stitching_detailed.cpp @@ -355,7 +355,7 @@ int main(int argc, char* argv[]) Ptr finder; if (features_type == "surf") { -#ifdef HAVE_OPENCV_GPUNONFREE +#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0) finder = new SurfFeaturesFinderGpu(); else diff --git a/samples/gpu/CMakeLists.txt b/samples/gpu/CMakeLists.txt index f68d2cd439..85bee50585 100644 --- a/samples/gpu/CMakeLists.txt +++ b/samples/gpu/CMakeLists.txt @@ -17,8 +17,8 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) "${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia/core" ) - if(HAVE_opencv_gpunonfree) - ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpunonfree/include") + if(HAVE_opencv_nonfree) + ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/nonfree/include") endif() if(HAVE_CUDA) @@ -37,8 +37,8 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) add_executable(${the_target} ${srcs}) target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_GPU_SAMPLES_REQUIRED_DEPS}) - if(HAVE_opencv_gpunonfree) - target_link_libraries(${the_target} opencv_gpunonfree) + if(HAVE_opencv_nonfree) + target_link_libraries(${the_target} opencv_nonfree) endif() set_target_properties(${the_target} PROPERTIES diff --git a/samples/gpu/bgfg_segm.cpp b/samples/gpu/bgfg_segm.cpp index ff538f805f..a77d336a9e 100644 --- a/samples/gpu/bgfg_segm.cpp +++ b/samples/gpu/bgfg_segm.cpp @@ -6,8 +6,8 @@ #include "opencv2/gpu/gpu.hpp" #include "opencv2/highgui/highgui.hpp" -#ifdef HAVE_OPENCV_GPUNONFREE -#include "opencv2/gpunonfree/gpunonfree.hpp" +#ifdef HAVE_OPENCV_NONFREE +#include "opencv2/nonfree/gpu.hpp" #endif using namespace std; @@ -19,7 +19,7 @@ enum Method FGD_STAT, MOG, MOG2, -#ifdef HAVE_OPENCV_GPUNONFREE +#ifdef HAVE_OPENCV_NONFREE VIBE, #endif GMG @@ -48,7 +48,7 @@ int main(int argc, const char** argv) if (method != "fgd" && method != "mog" && method != "mog2" - #ifdef HAVE_OPENCV_GPUNONFREE + #ifdef HAVE_OPENCV_NONFREE && method != "vibe" #endif && method != "gmg") @@ -60,7 +60,7 @@ int main(int argc, const char** argv) Method m = method == "fgd" ? FGD_STAT : method == "mog" ? MOG : method == "mog2" ? MOG2 : - #ifdef HAVE_OPENCV_GPUNONFREE + #ifdef HAVE_OPENCV_NONFREE method == "vibe" ? VIBE : #endif GMG; @@ -86,7 +86,7 @@ int main(int argc, const char** argv) FGDStatModel fgd_stat; MOG_GPU mog; MOG2_GPU mog2; -#ifdef HAVE_OPENCV_GPUNONFREE +#ifdef HAVE_OPENCV_NONFREE VIBE_GPU vibe; #endif GMG_GPU gmg; @@ -114,7 +114,7 @@ int main(int argc, const char** argv) mog2(d_frame, d_fgmask); break; -#ifdef HAVE_OPENCV_GPUNONFREE +#ifdef HAVE_OPENCV_NONFREE case VIBE: vibe.initialize(d_frame); break; @@ -129,7 +129,7 @@ int main(int argc, const char** argv) namedWindow("foreground mask", WINDOW_NORMAL); namedWindow("foreground image", WINDOW_NORMAL); if (m != GMG - #ifdef HAVE_OPENCV_GPUNONFREE + #ifdef HAVE_OPENCV_NONFREE && m != VIBE #endif ) @@ -165,7 +165,7 @@ int main(int argc, const char** argv) mog2.getBackgroundImage(d_bgimg); break; -#ifdef HAVE_OPENCV_GPUNONFREE +#ifdef HAVE_OPENCV_NONFREE case VIBE: vibe(d_frame, d_fgmask); break; diff --git a/samples/gpu/performance/CMakeLists.txt b/samples/gpu/performance/CMakeLists.txt index 2e8677d617..492b4c7900 100644 --- a/samples/gpu/performance/CMakeLists.txt +++ b/samples/gpu/performance/CMakeLists.txt @@ -10,8 +10,8 @@ endif() add_executable(${the_target} ${sources} ${headers}) target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_GPU_SAMPLES_REQUIRED_DEPS}) -if(HAVE_opencv_gpunonfree) - target_link_libraries(${the_target} opencv_gpunonfree opencv_nonfree) +if(HAVE_opencv_nonfree) + target_link_libraries(${the_target} opencv_nonfree) endif() set_target_properties(${the_target} PROPERTIES diff --git a/samples/gpu/performance/tests.cpp b/samples/gpu/performance/tests.cpp index 3c77d59e88..8af4722c38 100644 --- a/samples/gpu/performance/tests.cpp +++ b/samples/gpu/performance/tests.cpp @@ -8,8 +8,8 @@ #include "performance.h" #include "opencv2/opencv_modules.hpp" -#ifdef HAVE_OPENCV_GPUNONFREE -#include "opencv2/gpunonfree/gpunonfree.hpp" +#ifdef HAVE_OPENCV_NONFREE +#include "opencv2/nonfree/gpu.hpp" #include "opencv2/nonfree/nonfree.hpp" #endif @@ -271,7 +271,7 @@ TEST(meanShift) } } -#ifdef HAVE_OPENCV_GPUNONFREE +#ifdef HAVE_OPENCV_NONFREE TEST(SURF) { diff --git a/samples/gpu/surf_keypoint_matcher.cpp b/samples/gpu/surf_keypoint_matcher.cpp index 914867b9ec..f4c5e73f79 100644 --- a/samples/gpu/surf_keypoint_matcher.cpp +++ b/samples/gpu/surf_keypoint_matcher.cpp @@ -2,13 +2,13 @@ #include "opencv2/opencv_modules.hpp" -#ifdef HAVE_OPENCV_GPUNONFREE +#ifdef HAVE_OPENCV_NONFREE #include "opencv2/core/core.hpp" #include "opencv2/features2d/features2d.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/gpu/gpu.hpp" -#include "opencv2/gpunonfree/gpunonfree.hpp" +#include "opencv2/nonfree/gpu.hpp" using namespace std; using namespace cv; @@ -91,7 +91,7 @@ int main(int argc, char* argv[]) int main() { - std::cerr << "OpenCV was built without gpunonfree module" << std::endl; + std::cerr << "OpenCV was built without nonfree module" << std::endl; return 0; }