+++ /dev/null
-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()
-
+++ /dev/null
-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<KeyPoint>& keypoints,
- GpuMat& keypointsGPU);
- //! download keypoints from device to host memory
- void downloadKeypoints(const GpuMat& keypointsGPU,
- vector<KeyPoint>& keypoints);
-
- //! download descriptors from device to host memory
- void downloadDescriptors(const GpuMat& descriptorsGPU,
- vector<float>& 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<KeyPoint>& keypoints);
-
- void operator()(const GpuMat& img, const GpuMat& mask,
- std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
- bool useProvidedKeypoints = false,
- bool calcOrientation = true);
-
- void operator()(const GpuMat& img, const GpuMat& mask,
- std::vector<KeyPoint>& keypoints,
- std::vector<float>& 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<float>(X_ROW)[i]`` contains x coordinate of the i-th feature.
-* ``keypoints.ptr<float>(Y_ROW)[i]`` contains y coordinate of the i-th feature.
-* ``keypoints.ptr<float>(LAPLACIAN_ROW)[i]`` contains the laplacian sign of the i-th feature.
-* ``keypoints.ptr<float>(OCTAVE_ROW)[i]`` contains the octave of the i-th feature.
-* ``keypoints.ptr<float>(SIZE_ROW)[i]`` contains the size of the i-th feature.
-* ``keypoints.ptr<float>(ANGLE_ROW)[i]`` contain orientation of the i-th feature.
-* ``keypoints.ptr<float>(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`
+++ /dev/null
-******************************************************
-gpunonfree. GPU-accelerated Computer Vision (non free)
-******************************************************
-
-.. toctree::
- :maxdepth: 1
-
- feature_detection_and_description
- video
+++ /dev/null
-#include "perf_precomp.hpp"
-
-using namespace perf;
-
-CV_PERF_TEST_MAIN(gpunonfree, printCudaInfo())
+++ /dev/null
-#include "perf_precomp.hpp"
+++ /dev/null
-#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 <cstdio>
-#include <iostream>
-
-#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
+++ /dev/null
-/*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. */
-
+++ /dev/null
-/*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 <vector>
-
-#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__ */
+++ /dev/null
-/*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<bool>("help"))
- {
- cmd.printParams();
- return 0;
- }
-
- printCudaInfo();
-
- if (cmd.get<bool>("info"))
- {
- return 0;
- }
-
- int device = cmd.get<int>("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
+++ /dev/null
-/*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"
+++ /dev/null
-/*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 <iostream>
-
-#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
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()
-Video Analysis
-==============
+Background Subtraction
+======================
.. highlight:: cpp
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<KeyPoint>& keypoints,
+ GpuMat& keypointsGPU);
+ //! download keypoints from device to host memory
+ void downloadKeypoints(const GpuMat& keypointsGPU,
+ vector<KeyPoint>& keypoints);
+
+ //! download descriptors from device to host memory
+ void downloadDescriptors(const GpuMat& descriptorsGPU,
+ vector<float>& 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<KeyPoint>& keypoints);
+
+ void operator()(const GpuMat& img, const GpuMat& mask,
+ std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
+ bool useProvidedKeypoints = false,
+ bool calcOrientation = true);
+
+ void operator()(const GpuMat& img, const GpuMat& mask,
+ std::vector<KeyPoint>& keypoints,
+ std::vector<float>& 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<float>(X_ROW)[i]`` contains x coordinate of the i-th feature.
+* ``keypoints.ptr<float>(Y_ROW)[i]`` contains y coordinate of the i-th feature.
+* ``keypoints.ptr<float>(LAPLACIAN_ROW)[i]`` contains the laplacian sign of the i-th feature.
+* ``keypoints.ptr<float>(OCTAVE_ROW)[i]`` contains the octave of the i-th feature.
+* ``keypoints.ptr<float>(SIZE_ROW)[i]`` contains the size of the i-th feature.
+* ``keypoints.ptr<float>(ANGLE_ROW)[i]`` contain orientation of the i-th feature.
+* ``keypoints.ptr<float>(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`
:maxdepth: 2
feature_detection
+ background_subtraction
//
//M*/
-#ifndef __OPENCV_GPUNONFREE_HPP__
-#define __OPENCV_GPUNONFREE_HPP__
+#ifndef __OPENCV_NONFREE_GPU_HPP__
+#define __OPENCV_NONFREE_GPU_HPP__
-#ifndef SKIP_INCLUDES
-#include <vector>
-#endif
+#include "opencv2/opencv_modules.hpp"
+
+#if defined(HAVE_OPENCV_GPU)
#include "opencv2/gpu/gpu.hpp"
} // namespace cv
-#endif /* __OPENCV_GPUNONFREE_HPP__ */
+#endif // defined(HAVE_OPENCV_GPU)
+
+#endif // __OPENCV_NONFREE_GPU_HPP__
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<string>("gpu/perf/aloe.png"))
{
declare.time(50.0);
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))
{
FAIL_NO_CPU();
}
}
+
+#endif
#include "perf_precomp.hpp"
-CV_PERF_TEST_MAIN(nonfree)
+CV_PERF_TEST_MAIN(nonfree, perf::printCudaInfo())
#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
#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
#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(); }
void cv::gpu::SURF_GPU::operator()(const GpuMat&, const GpuMat&, vector<KeyPoint>&, vector<float>&, 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
{
maxPosBuffer.release();
}
-#endif /* !defined (HAVE_CUDA) */
+#endif // !defined (HAVE_CUDA)
+
+#endif // defined(HAVE_OPENCV_GPU)
#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(); }
}
#endif
+
+#endif // defined(HAVE_OPENCV_GPU)
#include "test_precomp.hpp"
-#ifdef HAVE_CUDA
+#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA)
using namespace cvtest;
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;
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));
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;
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4)),
WHOLE_SUBMAT));
-#endif // HAVE_CUDA
-
+#endif
#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<bool>("help"))
+ {
+ cmd.printParams();
+ return 0;
+ }
+
+ printCudaInfo();
+
+ if (cmd.get<bool>("info"))
+ {
+ return 0;
+ }
+
+ int device = cmd.get<int>("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
#ifndef __OPENCV_TEST_PRECOMP_HPP__
#define __OPENCV_TEST_PRECOMP_HPP__
+#include <iostream>
+
+#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 <iostream>
+
+#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA)
+ #include "opencv2/ts/gpu_test.hpp"
+ #include "opencv2/nonfree/gpu.hpp"
+#endif
#endif
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)
#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 {
};
-#ifdef HAVE_OPENCV_GPUNONFREE
+#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU)
class CV_EXPORTS SurfFeaturesFinderGpu : public FeaturesFinder
{
public:
}
}
-#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)
{
#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"
#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());
using namespace cv::superres;
using namespace cv::superres::detail;
-#ifndef HAVE_CUDA
+#if !defined(HAVE_CUDA) || !defined(HAVE_OPENCV_GPU)
Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_GPU()
{
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()
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}"
Ptr<FeaturesFinder> 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
"${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)
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
#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;
FGD_STAT,
MOG,
MOG2,
-#ifdef HAVE_OPENCV_GPUNONFREE
+#ifdef HAVE_OPENCV_NONFREE
VIBE,
#endif
GMG
if (method != "fgd"
&& method != "mog"
&& method != "mog2"
- #ifdef HAVE_OPENCV_GPUNONFREE
+ #ifdef HAVE_OPENCV_NONFREE
&& method != "vibe"
#endif
&& method != "gmg")
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;
FGDStatModel fgd_stat;
MOG_GPU mog;
MOG2_GPU mog2;
-#ifdef HAVE_OPENCV_GPUNONFREE
+#ifdef HAVE_OPENCV_NONFREE
VIBE_GPU vibe;
#endif
GMG_GPU gmg;
mog2(d_frame, d_fgmask);
break;
-#ifdef HAVE_OPENCV_GPUNONFREE
+#ifdef HAVE_OPENCV_NONFREE
case VIBE:
vibe.initialize(d_frame);
break;
namedWindow("foreground mask", WINDOW_NORMAL);
namedWindow("foreground image", WINDOW_NORMAL);
if (m != GMG
- #ifdef HAVE_OPENCV_GPUNONFREE
+ #ifdef HAVE_OPENCV_NONFREE
&& m != VIBE
#endif
)
mog2.getBackgroundImage(d_bgimg);
break;
-#ifdef HAVE_OPENCV_GPUNONFREE
+#ifdef HAVE_OPENCV_NONFREE
case VIBE:
vibe(d_frame, d_fgmask);
break;
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
#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
}
}
-#ifdef HAVE_OPENCV_GPUNONFREE
+#ifdef HAVE_OPENCV_NONFREE
TEST(SURF)
{
#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;
int main()
{
- std::cerr << "OpenCV was built without gpunonfree module" << std::endl;
+ std::cerr << "OpenCV was built without nonfree module" << std::endl;
return 0;
}