From 7544ddbfefe8ca2b8650ab1198d5da611482cd02 Mon Sep 17 00:00:00 2001 From: Vladislav Vinogradov Date: Thu, 18 Apr 2013 10:26:16 +0400 Subject: [PATCH] gpufeatures2d module 2d for feature detection and matching --- modules/gpu/CMakeLists.txt | 2 +- modules/gpu/doc/gpu.rst | 1 - modules/gpu/include/opencv2/gpu.hpp | 299 +---------------- modules/gpufeatures2d/CMakeLists.txt | 9 + .../doc/feature_detection_and_description.rst | 0 modules/gpufeatures2d/doc/gpufeatures2d.rst | 8 + .../include/opencv2/gpufeatures2d.hpp | 361 +++++++++++++++++++++ .../perf/perf_features2d.cpp | 10 +- modules/gpufeatures2d/perf/perf_main.cpp | 47 +++ modules/gpufeatures2d/perf/perf_precomp.cpp | 43 +++ modules/gpufeatures2d/perf/perf_precomp.hpp | 64 ++++ .../src/brute_force_matcher.cpp | 0 .../{gpu => gpufeatures2d}/src/cuda/bf_knnmatch.cu | 0 .../{gpu => gpufeatures2d}/src/cuda/bf_match.cu | 0 .../src/cuda/bf_radius_match.cu | 0 modules/{gpu => gpufeatures2d}/src/cuda/fast.cu | 0 modules/{gpu => gpufeatures2d}/src/cuda/orb.cu | 0 modules/{gpu => gpufeatures2d}/src/fast.cpp | 0 modules/{gpu => gpufeatures2d}/src/orb.cpp | 12 +- modules/gpufeatures2d/src/precomp.cpp | 43 +++ modules/gpufeatures2d/src/precomp.hpp | 58 ++++ .../test/test_features2d.cpp | 0 modules/gpufeatures2d/test/test_main.cpp | 45 +++ modules/gpufeatures2d/test/test_precomp.cpp | 43 +++ modules/gpufeatures2d/test/test_precomp.hpp | 60 ++++ samples/cpp/CMakeLists.txt | 1 + samples/gpu/CMakeLists.txt | 2 +- 27 files changed, 796 insertions(+), 312 deletions(-) create mode 100644 modules/gpufeatures2d/CMakeLists.txt rename modules/{gpu => gpufeatures2d}/doc/feature_detection_and_description.rst (100%) create mode 100644 modules/gpufeatures2d/doc/gpufeatures2d.rst create mode 100644 modules/gpufeatures2d/include/opencv2/gpufeatures2d.hpp rename modules/{gpu => gpufeatures2d}/perf/perf_features2d.cpp (97%) create mode 100644 modules/gpufeatures2d/perf/perf_main.cpp create mode 100644 modules/gpufeatures2d/perf/perf_precomp.cpp create mode 100644 modules/gpufeatures2d/perf/perf_precomp.hpp rename modules/{gpu => gpufeatures2d}/src/brute_force_matcher.cpp (100%) rename modules/{gpu => gpufeatures2d}/src/cuda/bf_knnmatch.cu (100%) rename modules/{gpu => gpufeatures2d}/src/cuda/bf_match.cu (100%) rename modules/{gpu => gpufeatures2d}/src/cuda/bf_radius_match.cu (100%) rename modules/{gpu => gpufeatures2d}/src/cuda/fast.cu (100%) rename modules/{gpu => gpufeatures2d}/src/cuda/orb.cu (100%) rename modules/{gpu => gpufeatures2d}/src/fast.cpp (100%) rename modules/{gpu => gpufeatures2d}/src/orb.cpp (98%) create mode 100644 modules/gpufeatures2d/src/precomp.cpp create mode 100644 modules/gpufeatures2d/src/precomp.hpp rename modules/{gpu => gpufeatures2d}/test/test_features2d.cpp (100%) create mode 100644 modules/gpufeatures2d/test/test_main.cpp create mode 100644 modules/gpufeatures2d/test/test_precomp.cpp create mode 100644 modules/gpufeatures2d/test/test_precomp.hpp diff --git a/modules/gpu/CMakeLists.txt b/modules/gpu/CMakeLists.txt index ee66608..fffc9bc 100644 --- a/modules/gpu/CMakeLists.txt +++ b/modules/gpu/CMakeLists.txt @@ -4,7 +4,7 @@ endif() set(the_description "GPU-accelerated Computer Vision") -ocv_add_module(gpu opencv_imgproc opencv_calib3d opencv_objdetect opencv_video opencv_photo opencv_legacy opencv_gpuarithm opencv_gpufilters opencv_gpuimgproc OPTIONAL opencv_gpunvidia) +ocv_add_module(gpu opencv_imgproc opencv_calib3d opencv_objdetect opencv_video opencv_photo opencv_legacy opencv_gpuarithm opencv_gpufilters opencv_gpuimgproc opencv_gpufeatures2d OPTIONAL opencv_gpunvidia) ocv_module_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src/cuda") diff --git a/modules/gpu/doc/gpu.rst b/modules/gpu/doc/gpu.rst index 6c082cc..68d7fc2 100644 --- a/modules/gpu/doc/gpu.rst +++ b/modules/gpu/doc/gpu.rst @@ -9,6 +9,5 @@ gpu. GPU-accelerated Computer Vision initalization_and_information data_structures object_detection - feature_detection_and_description camera_calibration_and_3d_reconstruction video diff --git a/modules/gpu/include/opencv2/gpu.hpp b/modules/gpu/include/opencv2/gpu.hpp index 7397321..db8e224 100644 --- a/modules/gpu/include/opencv2/gpu.hpp +++ b/modules/gpu/include/opencv2/gpu.hpp @@ -53,6 +53,7 @@ #include "opencv2/gpuarithm.hpp" #include "opencv2/gpufilters.hpp" #include "opencv2/gpuimgproc.hpp" +#include "opencv2/gpufeatures2d.hpp" #include "opencv2/imgproc.hpp" #include "opencv2/objdetect.hpp" @@ -368,156 +369,7 @@ protected: ////////////////////////////////// BruteForceMatcher ////////////////////////////////// -class CV_EXPORTS BFMatcher_GPU -{ -public: - explicit BFMatcher_GPU(int norm = cv::NORM_L2); - - // Add descriptors to train descriptor collection - void add(const std::vector& descCollection); - - // Get train descriptors collection - const std::vector& getTrainDescriptors() const; - // Clear train descriptors collection - void clear(); - - // Return true if there are not train descriptors in collection - bool empty() const; - - // Return true if the matcher supports mask in match methods - bool isMaskSupported() const; - - // Find one best match for each query descriptor - void matchSingle(const GpuMat& query, const GpuMat& train, - GpuMat& trainIdx, GpuMat& distance, - const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null()); - - // Download trainIdx and distance and convert it to CPU vector with DMatch - static void matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector& matches); - // Convert trainIdx and distance to vector with DMatch - static void matchConvert(const Mat& trainIdx, const Mat& distance, std::vector& matches); - - // Find one best match for each query descriptor - void match(const GpuMat& query, const GpuMat& train, std::vector& matches, const GpuMat& mask = GpuMat()); - - // Make gpu collection of trains and masks in suitable format for matchCollection function - void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection, const std::vector& masks = std::vector()); - - // Find one best match from train collection for each query descriptor - void matchCollection(const GpuMat& query, const GpuMat& trainCollection, - GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, - const GpuMat& masks = GpuMat(), Stream& stream = Stream::Null()); - - // Download trainIdx, imgIdx and distance and convert it to vector with DMatch - static void matchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, std::vector& matches); - // Convert trainIdx, imgIdx and distance to vector with DMatch - static void matchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, std::vector& matches); - - // Find one best match from train collection for each query descriptor. - void match(const GpuMat& query, std::vector& matches, const std::vector& masks = std::vector()); - - // Find k best matches for each query descriptor (in increasing order of distances) - void knnMatchSingle(const GpuMat& query, const GpuMat& train, - GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, - const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null()); - - // Download trainIdx and distance and convert it to vector with DMatch - // compactResult is used when mask is not empty. If compactResult is false matches - // vector will have the same size as queryDescriptors rows. If compactResult is true - // matches vector will not contain matches for fully masked out query descriptors. - static void knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, - std::vector< std::vector >& matches, bool compactResult = false); - // Convert trainIdx and distance to vector with DMatch - static void knnMatchConvert(const Mat& trainIdx, const Mat& distance, - std::vector< std::vector >& matches, bool compactResult = false); - - // Find k best matches for each query descriptor (in increasing order of distances). - // compactResult is used when mask is not empty. If compactResult is false matches - // vector will have the same size as queryDescriptors rows. If compactResult is true - // matches vector will not contain matches for fully masked out query descriptors. - void knnMatch(const GpuMat& query, const GpuMat& train, - std::vector< std::vector >& matches, int k, const GpuMat& mask = GpuMat(), - bool compactResult = false); - - // Find k best matches from train collection for each query descriptor (in increasing order of distances) - void knnMatch2Collection(const GpuMat& query, const GpuMat& trainCollection, - GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, - const GpuMat& maskCollection = GpuMat(), Stream& stream = Stream::Null()); - - // Download trainIdx and distance and convert it to vector with DMatch - // compactResult is used when mask is not empty. If compactResult is false matches - // vector will have the same size as queryDescriptors rows. If compactResult is true - // matches vector will not contain matches for fully masked out query descriptors. - static void knnMatch2Download(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, - std::vector< std::vector >& matches, bool compactResult = false); - // Convert trainIdx and distance to vector with DMatch - static void knnMatch2Convert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, - std::vector< std::vector >& matches, bool compactResult = false); - - // Find k best matches for each query descriptor (in increasing order of distances). - // compactResult is used when mask is not empty. If compactResult is false matches - // vector will have the same size as queryDescriptors rows. If compactResult is true - // matches vector will not contain matches for fully masked out query descriptors. - void knnMatch(const GpuMat& query, std::vector< std::vector >& matches, int k, - const std::vector& masks = std::vector(), bool compactResult = false); - - // Find best matches for each query descriptor which have distance less than maxDistance. - // nMatches.at(0, queryIdx) will contain matches count for queryIdx. - // carefully nMatches can be greater than trainIdx.cols - it means that matcher didn't find all matches, - // because it didn't have enough memory. - // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x max((nTrain / 100), 10), - // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches - // Matches doesn't sorted. - void radiusMatchSingle(const GpuMat& query, const GpuMat& train, - GpuMat& trainIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance, - const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null()); - - // Download trainIdx, nMatches and distance and convert it to vector with DMatch. - // matches will be sorted in increasing order of distances. - // compactResult is used when mask is not empty. If compactResult is false matches - // vector will have the same size as queryDescriptors rows. If compactResult is true - // matches vector will not contain matches for fully masked out query descriptors. - static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, const GpuMat& nMatches, - std::vector< std::vector >& matches, bool compactResult = false); - // Convert trainIdx, nMatches and distance to vector with DMatch. - static void radiusMatchConvert(const Mat& trainIdx, const Mat& distance, const Mat& nMatches, - std::vector< std::vector >& matches, bool compactResult = false); - - // Find best matches for each query descriptor which have distance less than maxDistance - // in increasing order of distances). - void radiusMatch(const GpuMat& query, const GpuMat& train, - std::vector< std::vector >& matches, float maxDistance, - const GpuMat& mask = GpuMat(), bool compactResult = false); - - // Find best matches for each query descriptor which have distance less than maxDistance. - // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x max((nQuery / 100), 10), - // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches - // Matches doesn't sorted. - void radiusMatchCollection(const GpuMat& query, GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance, - const std::vector& masks = std::vector(), Stream& stream = Stream::Null()); - - // Download trainIdx, imgIdx, nMatches and distance and convert it to vector with DMatch. - // matches will be sorted in increasing order of distances. - // compactResult is used when mask is not empty. If compactResult is false matches - // vector will have the same size as queryDescriptors rows. If compactResult is true - // matches vector will not contain matches for fully masked out query descriptors. - static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, const GpuMat& nMatches, - std::vector< std::vector >& matches, bool compactResult = false); - // Convert trainIdx, nMatches and distance to vector with DMatch. - static void radiusMatchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, const Mat& nMatches, - std::vector< std::vector >& matches, bool compactResult = false); - - // Find best matches from train collection for each query descriptor which have distance less than - // maxDistance (in increasing order of distances). - void radiusMatch(const GpuMat& query, std::vector< std::vector >& matches, float maxDistance, - const std::vector& masks = std::vector(), bool compactResult = false); - - int norm; - -private: - std::vector trainDescCollection; -}; template class CV_EXPORTS BruteForceMatcher_GPU; @@ -575,160 +427,11 @@ private: ////////////////////////////////// FAST ////////////////////////////////////////// -class CV_EXPORTS FAST_GPU -{ -public: - enum - { - LOCATION_ROW = 0, - RESPONSE_ROW, - ROWS_COUNT - }; - - // all features have same size - static const int FEATURE_SIZE = 7; - explicit FAST_GPU(int threshold, bool nonmaxSupression = true, double keypointsRatio = 0.05); - - //! finds the keypoints using FAST detector - //! supports only CV_8UC1 images - void operator ()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints); - void operator ()(const GpuMat& image, const GpuMat& mask, std::vector& keypoints); - - //! download keypoints from device to host memory - static void downloadKeypoints(const GpuMat& d_keypoints, std::vector& keypoints); - - //! convert keypoints to KeyPoint vector - static void convertKeypoints(const Mat& h_keypoints, std::vector& keypoints); - - //! release temporary buffer's memory - void release(); - - bool nonmaxSupression; - - int threshold; - - //! max keypoints = keypointsRatio * img.size().area() - double keypointsRatio; - - //! find keypoints and compute it's response if nonmaxSupression is true - //! return count of detected keypoints - int calcKeyPointsLocation(const GpuMat& image, const GpuMat& mask); - - //! get final array of keypoints - //! performs nonmax supression if needed - //! return final count of keypoints - int getKeyPoints(GpuMat& keypoints); - -private: - GpuMat kpLoc_; - int count_; - - GpuMat score_; - - GpuMat d_keypoints_; -}; ////////////////////////////////// ORB ////////////////////////////////////////// -class CV_EXPORTS ORB_GPU -{ -public: - enum - { - X_ROW = 0, - Y_ROW, - RESPONSE_ROW, - ANGLE_ROW, - OCTAVE_ROW, - SIZE_ROW, - ROWS_COUNT - }; - - enum - { - DEFAULT_FAST_THRESHOLD = 20 - }; - - //! Constructor - explicit ORB_GPU(int nFeatures = 500, float scaleFactor = 1.2f, int nLevels = 8, int edgeThreshold = 31, - int firstLevel = 0, int WTA_K = 2, int scoreType = 0, int patchSize = 31); - - //! Compute the ORB features on an image - //! image - the image to compute the features (supports only CV_8UC1 images) - //! mask - the mask to apply - //! keypoints - the resulting keypoints - void operator()(const GpuMat& image, const GpuMat& mask, std::vector& keypoints); - void operator()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints); - - //! Compute the ORB features and descriptors on an image - //! image - the image to compute the features (supports only CV_8UC1 images) - //! mask - the mask to apply - //! keypoints - the resulting keypoints - //! descriptors - descriptors array - void operator()(const GpuMat& image, const GpuMat& mask, std::vector& keypoints, GpuMat& descriptors); - void operator()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors); - - //! download keypoints from device to host memory - static void downloadKeyPoints(const GpuMat& d_keypoints, std::vector& keypoints); - //! convert keypoints to KeyPoint vector - static void convertKeyPoints(const Mat& d_keypoints, std::vector& keypoints); - - //! returns the descriptor size in bytes - inline int descriptorSize() const { return kBytes; } - - inline void setFastParams(int threshold, bool nonmaxSupression = true) - { - fastDetector_.threshold = threshold; - fastDetector_.nonmaxSupression = nonmaxSupression; - } - - //! release temporary buffer's memory - void release(); - - //! if true, image will be blurred before descriptors calculation - bool blurForDescriptor; - -private: - enum { kBytes = 32 }; - void buildScalePyramids(const GpuMat& image, const GpuMat& mask); - - void computeKeyPointsPyramid(); - - void computeDescriptors(GpuMat& descriptors); - - void mergeKeyPoints(GpuMat& keypoints); - - int nFeatures_; - float scaleFactor_; - int nLevels_; - int edgeThreshold_; - int firstLevel_; - int WTA_K_; - int scoreType_; - int patchSize_; - - // The number of desired features per scale - std::vector n_features_per_level_; - - // Points to compute BRIEF descriptors from - GpuMat pattern_; - - std::vector imagePyr_; - std::vector maskPyr_; - - GpuMat buf_; - - std::vector keyPointsPyr_; - std::vector keyPointsCount_; - - FAST_GPU fastDetector_; - - Ptr blurFilter; - - GpuMat d_keypoints_; -}; ////////////////////////////////// Optical Flow ////////////////////////////////////////// diff --git a/modules/gpufeatures2d/CMakeLists.txt b/modules/gpufeatures2d/CMakeLists.txt new file mode 100644 index 0000000..4a93be3 --- /dev/null +++ b/modules/gpufeatures2d/CMakeLists.txt @@ -0,0 +1,9 @@ +if(ANDROID OR IOS) + ocv_module_disable(gpufeatures2d) +endif() + +set(the_description "GPU-accelerated Feature Detection and Description") + +ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4100 /wd4324 /wd4512 -Wundef -Wmissing-declarations -Wshadow -Wunused-parameter) + +ocv_define_module(gpufeatures2d opencv_features2d opencv_gpufilters opencv_gpuimgproc) diff --git a/modules/gpu/doc/feature_detection_and_description.rst b/modules/gpufeatures2d/doc/feature_detection_and_description.rst similarity index 100% rename from modules/gpu/doc/feature_detection_and_description.rst rename to modules/gpufeatures2d/doc/feature_detection_and_description.rst diff --git a/modules/gpufeatures2d/doc/gpufeatures2d.rst b/modules/gpufeatures2d/doc/gpufeatures2d.rst new file mode 100644 index 0000000..5679b1d --- /dev/null +++ b/modules/gpufeatures2d/doc/gpufeatures2d.rst @@ -0,0 +1,8 @@ +**************************************************************** +gpufeatures2d. GPU-accelerated Feature Detection and Description +**************************************************************** + +.. toctree:: + :maxdepth: 1 + + feature_detection_and_description diff --git a/modules/gpufeatures2d/include/opencv2/gpufeatures2d.hpp b/modules/gpufeatures2d/include/opencv2/gpufeatures2d.hpp new file mode 100644 index 0000000..08313b1 --- /dev/null +++ b/modules/gpufeatures2d/include/opencv2/gpufeatures2d.hpp @@ -0,0 +1,361 @@ +/*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_GPUFEATURES2D_HPP__ +#define __OPENCV_GPUFEATURES2D_HPP__ + +#ifndef __cplusplus +# error gpufeatures2d.hpp header must be compiled as C++ +#endif + +#include "opencv2/core/gpumat.hpp" +#include "opencv2/gpufilters.hpp" + +namespace cv { namespace gpu { + +class CV_EXPORTS BFMatcher_GPU +{ +public: + explicit BFMatcher_GPU(int norm = cv::NORM_L2); + + // Add descriptors to train descriptor collection + void add(const std::vector& descCollection); + + // Get train descriptors collection + const std::vector& getTrainDescriptors() const; + + // Clear train descriptors collection + void clear(); + + // Return true if there are not train descriptors in collection + bool empty() const; + + // Return true if the matcher supports mask in match methods + bool isMaskSupported() const; + + // Find one best match for each query descriptor + void matchSingle(const GpuMat& query, const GpuMat& train, + GpuMat& trainIdx, GpuMat& distance, + const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null()); + + // Download trainIdx and distance and convert it to CPU vector with DMatch + static void matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector& matches); + // Convert trainIdx and distance to vector with DMatch + static void matchConvert(const Mat& trainIdx, const Mat& distance, std::vector& matches); + + // Find one best match for each query descriptor + void match(const GpuMat& query, const GpuMat& train, std::vector& matches, const GpuMat& mask = GpuMat()); + + // Make gpu collection of trains and masks in suitable format for matchCollection function + void makeGpuCollection(GpuMat& trainCollection, GpuMat& maskCollection, const std::vector& masks = std::vector()); + + // Find one best match from train collection for each query descriptor + void matchCollection(const GpuMat& query, const GpuMat& trainCollection, + GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, + const GpuMat& masks = GpuMat(), Stream& stream = Stream::Null()); + + // Download trainIdx, imgIdx and distance and convert it to vector with DMatch + static void matchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, std::vector& matches); + // Convert trainIdx, imgIdx and distance to vector with DMatch + static void matchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, std::vector& matches); + + // Find one best match from train collection for each query descriptor. + void match(const GpuMat& query, std::vector& matches, const std::vector& masks = std::vector()); + + // Find k best matches for each query descriptor (in increasing order of distances) + void knnMatchSingle(const GpuMat& query, const GpuMat& train, + GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, + const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null()); + + // Download trainIdx and distance and convert it to vector with DMatch + // compactResult is used when mask is not empty. If compactResult is false matches + // vector will have the same size as queryDescriptors rows. If compactResult is true + // matches vector will not contain matches for fully masked out query descriptors. + static void knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, + std::vector< std::vector >& matches, bool compactResult = false); + // Convert trainIdx and distance to vector with DMatch + static void knnMatchConvert(const Mat& trainIdx, const Mat& distance, + std::vector< std::vector >& matches, bool compactResult = false); + + // Find k best matches for each query descriptor (in increasing order of distances). + // compactResult is used when mask is not empty. If compactResult is false matches + // vector will have the same size as queryDescriptors rows. If compactResult is true + // matches vector will not contain matches for fully masked out query descriptors. + void knnMatch(const GpuMat& query, const GpuMat& train, + std::vector< std::vector >& matches, int k, const GpuMat& mask = GpuMat(), + bool compactResult = false); + + // Find k best matches from train collection for each query descriptor (in increasing order of distances) + void knnMatch2Collection(const GpuMat& query, const GpuMat& trainCollection, + GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, + const GpuMat& maskCollection = GpuMat(), Stream& stream = Stream::Null()); + + // Download trainIdx and distance and convert it to vector with DMatch + // compactResult is used when mask is not empty. If compactResult is false matches + // vector will have the same size as queryDescriptors rows. If compactResult is true + // matches vector will not contain matches for fully masked out query descriptors. + static void knnMatch2Download(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, + std::vector< std::vector >& matches, bool compactResult = false); + // Convert trainIdx and distance to vector with DMatch + static void knnMatch2Convert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, + std::vector< std::vector >& matches, bool compactResult = false); + + // Find k best matches for each query descriptor (in increasing order of distances). + // compactResult is used when mask is not empty. If compactResult is false matches + // vector will have the same size as queryDescriptors rows. If compactResult is true + // matches vector will not contain matches for fully masked out query descriptors. + void knnMatch(const GpuMat& query, std::vector< std::vector >& matches, int k, + const std::vector& masks = std::vector(), bool compactResult = false); + + // Find best matches for each query descriptor which have distance less than maxDistance. + // nMatches.at(0, queryIdx) will contain matches count for queryIdx. + // carefully nMatches can be greater than trainIdx.cols - it means that matcher didn't find all matches, + // because it didn't have enough memory. + // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x max((nTrain / 100), 10), + // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches + // Matches doesn't sorted. + void radiusMatchSingle(const GpuMat& query, const GpuMat& train, + GpuMat& trainIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance, + const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null()); + + // Download trainIdx, nMatches and distance and convert it to vector with DMatch. + // matches will be sorted in increasing order of distances. + // compactResult is used when mask is not empty. If compactResult is false matches + // vector will have the same size as queryDescriptors rows. If compactResult is true + // matches vector will not contain matches for fully masked out query descriptors. + static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& distance, const GpuMat& nMatches, + std::vector< std::vector >& matches, bool compactResult = false); + // Convert trainIdx, nMatches and distance to vector with DMatch. + static void radiusMatchConvert(const Mat& trainIdx, const Mat& distance, const Mat& nMatches, + std::vector< std::vector >& matches, bool compactResult = false); + + // Find best matches for each query descriptor which have distance less than maxDistance + // in increasing order of distances). + void radiusMatch(const GpuMat& query, const GpuMat& train, + std::vector< std::vector >& matches, float maxDistance, + const GpuMat& mask = GpuMat(), bool compactResult = false); + + // Find best matches for each query descriptor which have distance less than maxDistance. + // If trainIdx is empty, then trainIdx and distance will be created with size nQuery x max((nQuery / 100), 10), + // otherwize user can pass own allocated trainIdx and distance with size nQuery x nMaxMatches + // Matches doesn't sorted. + void radiusMatchCollection(const GpuMat& query, GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, GpuMat& nMatches, float maxDistance, + const std::vector& masks = std::vector(), Stream& stream = Stream::Null()); + + // Download trainIdx, imgIdx, nMatches and distance and convert it to vector with DMatch. + // matches will be sorted in increasing order of distances. + // compactResult is used when mask is not empty. If compactResult is false matches + // vector will have the same size as queryDescriptors rows. If compactResult is true + // matches vector will not contain matches for fully masked out query descriptors. + static void radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance, const GpuMat& nMatches, + std::vector< std::vector >& matches, bool compactResult = false); + // Convert trainIdx, nMatches and distance to vector with DMatch. + static void radiusMatchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, const Mat& nMatches, + std::vector< std::vector >& matches, bool compactResult = false); + + // Find best matches from train collection for each query descriptor which have distance less than + // maxDistance (in increasing order of distances). + void radiusMatch(const GpuMat& query, std::vector< std::vector >& matches, float maxDistance, + const std::vector& masks = std::vector(), bool compactResult = false); + + int norm; + +private: + std::vector trainDescCollection; +}; + +class CV_EXPORTS FAST_GPU +{ +public: + enum + { + LOCATION_ROW = 0, + RESPONSE_ROW, + ROWS_COUNT + }; + + // all features have same size + static const int FEATURE_SIZE = 7; + + explicit FAST_GPU(int threshold, bool nonmaxSupression = true, double keypointsRatio = 0.05); + + //! finds the keypoints using FAST detector + //! supports only CV_8UC1 images + void operator ()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints); + void operator ()(const GpuMat& image, const GpuMat& mask, std::vector& keypoints); + + //! download keypoints from device to host memory + static void downloadKeypoints(const GpuMat& d_keypoints, std::vector& keypoints); + + //! convert keypoints to KeyPoint vector + static void convertKeypoints(const Mat& h_keypoints, std::vector& keypoints); + + //! release temporary buffer's memory + void release(); + + bool nonmaxSupression; + + int threshold; + + //! max keypoints = keypointsRatio * img.size().area() + double keypointsRatio; + + //! find keypoints and compute it's response if nonmaxSupression is true + //! return count of detected keypoints + int calcKeyPointsLocation(const GpuMat& image, const GpuMat& mask); + + //! get final array of keypoints + //! performs nonmax supression if needed + //! return final count of keypoints + int getKeyPoints(GpuMat& keypoints); + +private: + GpuMat kpLoc_; + int count_; + + GpuMat score_; + + GpuMat d_keypoints_; +}; + +class CV_EXPORTS ORB_GPU +{ +public: + enum + { + X_ROW = 0, + Y_ROW, + RESPONSE_ROW, + ANGLE_ROW, + OCTAVE_ROW, + SIZE_ROW, + ROWS_COUNT + }; + + enum + { + DEFAULT_FAST_THRESHOLD = 20 + }; + + //! Constructor + explicit ORB_GPU(int nFeatures = 500, float scaleFactor = 1.2f, int nLevels = 8, int edgeThreshold = 31, + int firstLevel = 0, int WTA_K = 2, int scoreType = 0, int patchSize = 31); + + //! Compute the ORB features on an image + //! image - the image to compute the features (supports only CV_8UC1 images) + //! mask - the mask to apply + //! keypoints - the resulting keypoints + void operator()(const GpuMat& image, const GpuMat& mask, std::vector& keypoints); + void operator()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints); + + //! Compute the ORB features and descriptors on an image + //! image - the image to compute the features (supports only CV_8UC1 images) + //! mask - the mask to apply + //! keypoints - the resulting keypoints + //! descriptors - descriptors array + void operator()(const GpuMat& image, const GpuMat& mask, std::vector& keypoints, GpuMat& descriptors); + void operator()(const GpuMat& image, const GpuMat& mask, GpuMat& keypoints, GpuMat& descriptors); + + //! download keypoints from device to host memory + static void downloadKeyPoints(const GpuMat& d_keypoints, std::vector& keypoints); + //! convert keypoints to KeyPoint vector + static void convertKeyPoints(const Mat& d_keypoints, std::vector& keypoints); + + //! returns the descriptor size in bytes + inline int descriptorSize() const { return kBytes; } + + inline void setFastParams(int threshold, bool nonmaxSupression = true) + { + fastDetector_.threshold = threshold; + fastDetector_.nonmaxSupression = nonmaxSupression; + } + + //! release temporary buffer's memory + void release(); + + //! if true, image will be blurred before descriptors calculation + bool blurForDescriptor; + +private: + enum { kBytes = 32 }; + + void buildScalePyramids(const GpuMat& image, const GpuMat& mask); + + void computeKeyPointsPyramid(); + + void computeDescriptors(GpuMat& descriptors); + + void mergeKeyPoints(GpuMat& keypoints); + + int nFeatures_; + float scaleFactor_; + int nLevels_; + int edgeThreshold_; + int firstLevel_; + int WTA_K_; + int scoreType_; + int patchSize_; + + // The number of desired features per scale + std::vector n_features_per_level_; + + // Points to compute BRIEF descriptors from + GpuMat pattern_; + + std::vector imagePyr_; + std::vector maskPyr_; + + GpuMat buf_; + + std::vector keyPointsPyr_; + std::vector keyPointsCount_; + + FAST_GPU fastDetector_; + + Ptr blurFilter; + + GpuMat d_keypoints_; +}; + +}} // namespace cv { namespace gpu { + +#endif /* __OPENCV_GPUFEATURES2D_HPP__ */ diff --git a/modules/gpu/perf/perf_features2d.cpp b/modules/gpufeatures2d/perf/perf_features2d.cpp similarity index 97% rename from modules/gpu/perf/perf_features2d.cpp rename to modules/gpufeatures2d/perf/perf_features2d.cpp index feee3a9..9396ba2 100644 --- a/modules/gpu/perf/perf_features2d.cpp +++ b/modules/gpufeatures2d/perf/perf_features2d.cpp @@ -51,7 +51,7 @@ using namespace perf; DEF_PARAM_TEST(Image_Threshold_NonMaxSupression, string, int, bool); -PERF_TEST_P(Image_Threshold_NonMaxSupression, Features2D_FAST, +PERF_TEST_P(Image_Threshold_NonMaxSupression, FAST, Combine(Values("gpu/perf/aloe.png"), Values(20), Bool())) @@ -93,7 +93,7 @@ PERF_TEST_P(Image_Threshold_NonMaxSupression, Features2D_FAST, DEF_PARAM_TEST(Image_NFeatures, string, int); -PERF_TEST_P(Image_NFeatures, Features2D_ORB, +PERF_TEST_P(Image_NFeatures, ORB, Combine(Values("gpu/perf/aloe.png"), Values(4000))) { @@ -145,7 +145,7 @@ PERF_TEST_P(Image_NFeatures, Features2D_ORB, DEF_PARAM_TEST(DescSize_Norm, int, NormType); -PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, +PERF_TEST_P(DescSize_Norm, BFMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING)))) { @@ -202,7 +202,7 @@ static void toOneRowMatches(const std::vector< std::vector >& src, s DEF_PARAM_TEST(DescSize_K_Norm, int, int, NormType); -PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, +PERF_TEST_P(DescSize_K_Norm, BFKnnMatch, Combine(Values(64, 128, 256), Values(2, 3), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2)))) @@ -257,7 +257,7 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, ////////////////////////////////////////////////////////////////////// // BFRadiusMatch -PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, +PERF_TEST_P(DescSize_Norm, BFRadiusMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2)))) { diff --git a/modules/gpufeatures2d/perf/perf_main.cpp b/modules/gpufeatures2d/perf/perf_main.cpp new file mode 100644 index 0000000..0fd79fd --- /dev/null +++ b/modules/gpufeatures2d/perf/perf_main.cpp @@ -0,0 +1,47 @@ +/*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*/ + +#include "perf_precomp.hpp" + +using namespace perf; + +CV_PERF_TEST_MAIN(gpufeatures2d, printCudaInfo()) diff --git a/modules/gpufeatures2d/perf/perf_precomp.cpp b/modules/gpufeatures2d/perf/perf_precomp.cpp new file mode 100644 index 0000000..81f16e8 --- /dev/null +++ b/modules/gpufeatures2d/perf/perf_precomp.cpp @@ -0,0 +1,43 @@ +/*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*/ + +#include "perf_precomp.hpp" diff --git a/modules/gpufeatures2d/perf/perf_precomp.hpp b/modules/gpufeatures2d/perf/perf_precomp.hpp new file mode 100644 index 0000000..4f767c4 --- /dev/null +++ b/modules/gpufeatures2d/perf/perf_precomp.hpp @@ -0,0 +1,64 @@ +/*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*/ + +#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 "opencv2/ts.hpp" +#include "opencv2/ts/gpu_perf.hpp" + +#include "opencv2/gpufeatures2d.hpp" +#include "opencv2/features2d.hpp" + +#ifdef GTEST_CREATE_SHARED_LIBRARY +#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined +#endif + +#endif diff --git a/modules/gpu/src/brute_force_matcher.cpp b/modules/gpufeatures2d/src/brute_force_matcher.cpp similarity index 100% rename from modules/gpu/src/brute_force_matcher.cpp rename to modules/gpufeatures2d/src/brute_force_matcher.cpp diff --git a/modules/gpu/src/cuda/bf_knnmatch.cu b/modules/gpufeatures2d/src/cuda/bf_knnmatch.cu similarity index 100% rename from modules/gpu/src/cuda/bf_knnmatch.cu rename to modules/gpufeatures2d/src/cuda/bf_knnmatch.cu diff --git a/modules/gpu/src/cuda/bf_match.cu b/modules/gpufeatures2d/src/cuda/bf_match.cu similarity index 100% rename from modules/gpu/src/cuda/bf_match.cu rename to modules/gpufeatures2d/src/cuda/bf_match.cu diff --git a/modules/gpu/src/cuda/bf_radius_match.cu b/modules/gpufeatures2d/src/cuda/bf_radius_match.cu similarity index 100% rename from modules/gpu/src/cuda/bf_radius_match.cu rename to modules/gpufeatures2d/src/cuda/bf_radius_match.cu diff --git a/modules/gpu/src/cuda/fast.cu b/modules/gpufeatures2d/src/cuda/fast.cu similarity index 100% rename from modules/gpu/src/cuda/fast.cu rename to modules/gpufeatures2d/src/cuda/fast.cu diff --git a/modules/gpu/src/cuda/orb.cu b/modules/gpufeatures2d/src/cuda/orb.cu similarity index 100% rename from modules/gpu/src/cuda/orb.cu rename to modules/gpufeatures2d/src/cuda/orb.cu diff --git a/modules/gpu/src/fast.cpp b/modules/gpufeatures2d/src/fast.cpp similarity index 100% rename from modules/gpu/src/fast.cpp rename to modules/gpufeatures2d/src/fast.cpp diff --git a/modules/gpu/src/orb.cpp b/modules/gpufeatures2d/src/orb.cpp similarity index 98% rename from modules/gpu/src/orb.cpp rename to modules/gpufeatures2d/src/orb.cpp index 2d40416..495ca3f 100644 --- a/modules/gpu/src/orb.cpp +++ b/modules/gpufeatures2d/src/orb.cpp @@ -504,19 +504,19 @@ void cv::gpu::ORB_GPU::buildScalePyramids(const GpuMat& image, const GpuMat& mas { if (level < firstLevel_) { - resize(image, imagePyr_[level], sz, 0, 0, INTER_LINEAR); + gpu::resize(image, imagePyr_[level], sz, 0, 0, INTER_LINEAR); if (!mask.empty()) - resize(mask, maskPyr_[level], sz, 0, 0, INTER_LINEAR); + gpu::resize(mask, maskPyr_[level], sz, 0, 0, INTER_LINEAR); } else { - resize(imagePyr_[level - 1], imagePyr_[level], sz, 0, 0, INTER_LINEAR); + gpu::resize(imagePyr_[level - 1], imagePyr_[level], sz, 0, 0, INTER_LINEAR); if (!mask.empty()) { - resize(maskPyr_[level - 1], maskPyr_[level], sz, 0, 0, INTER_LINEAR); - threshold(maskPyr_[level], maskPyr_[level], 254, 0, THRESH_TOZERO); + gpu::resize(maskPyr_[level - 1], maskPyr_[level], sz, 0, 0, INTER_LINEAR); + gpu::threshold(maskPyr_[level], maskPyr_[level], 254, 0, THRESH_TOZERO); } } } @@ -534,7 +534,7 @@ void cv::gpu::ORB_GPU::buildScalePyramids(const GpuMat& image, const GpuMat& mas Rect inner(edgeThreshold_, edgeThreshold_, sz.width - 2 * edgeThreshold_, sz.height - 2 * edgeThreshold_); buf_(inner).setTo(Scalar::all(255)); - bitwise_and(maskPyr_[level], buf_, maskPyr_[level]); + gpu::bitwise_and(maskPyr_[level], buf_, maskPyr_[level]); } } diff --git a/modules/gpufeatures2d/src/precomp.cpp b/modules/gpufeatures2d/src/precomp.cpp new file mode 100644 index 0000000..3c01a25 --- /dev/null +++ b/modules/gpufeatures2d/src/precomp.cpp @@ -0,0 +1,43 @@ +/*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*/ + +#include "precomp.hpp" diff --git a/modules/gpufeatures2d/src/precomp.hpp b/modules/gpufeatures2d/src/precomp.hpp new file mode 100644 index 0000000..d393626 --- /dev/null +++ b/modules/gpufeatures2d/src/precomp.hpp @@ -0,0 +1,58 @@ +/*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__ + +#include +#include +#include + +#include "opencv2/gpufeatures2d.hpp" +#include "opencv2/gpuarithm.hpp" +#include "opencv2/gpuimgproc.hpp" + +#include "opencv2/features2d.hpp" + +#include "opencv2/core/gpu_private.hpp" + +#endif /* __OPENCV_PRECOMP_H__ */ diff --git a/modules/gpu/test/test_features2d.cpp b/modules/gpufeatures2d/test/test_features2d.cpp similarity index 100% rename from modules/gpu/test/test_features2d.cpp rename to modules/gpufeatures2d/test/test_features2d.cpp diff --git a/modules/gpufeatures2d/test/test_main.cpp b/modules/gpufeatures2d/test/test_main.cpp new file mode 100644 index 0000000..eea3d7c --- /dev/null +++ b/modules/gpufeatures2d/test/test_main.cpp @@ -0,0 +1,45 @@ +/*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*/ + +#include "test_precomp.hpp" + +CV_GPU_TEST_MAIN("gpu") diff --git a/modules/gpufeatures2d/test/test_precomp.cpp b/modules/gpufeatures2d/test/test_precomp.cpp new file mode 100644 index 0000000..0fb6521 --- /dev/null +++ b/modules/gpufeatures2d/test/test_precomp.cpp @@ -0,0 +1,43 @@ +/*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*/ + +#include "test_precomp.hpp" diff --git a/modules/gpufeatures2d/test/test_precomp.hpp b/modules/gpufeatures2d/test/test_precomp.hpp new file mode 100644 index 0000000..7725d3f --- /dev/null +++ b/modules/gpufeatures2d/test/test_precomp.hpp @@ -0,0 +1,60 @@ +/*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*/ + +#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 "opencv2/ts.hpp" +#include "opencv2/ts/gpu_test.hpp" + +#include "opencv2/gpufeatures2d.hpp" +#include "opencv2/features2d.hpp" + +#endif diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index bb444f0..06ccb4d 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -20,6 +20,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpuarithm/include") ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpufilters/include") ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpuimgproc/include") + ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpufeatures2d/include") ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include") endif() diff --git a/samples/gpu/CMakeLists.txt b/samples/gpu/CMakeLists.txt index 57fdeb0..f138226 100644 --- a/samples/gpu/CMakeLists.txt +++ b/samples/gpu/CMakeLists.txt @@ -2,7 +2,7 @@ SET(OPENCV_GPU_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc ope opencv_ml opencv_video opencv_objdetect opencv_features2d opencv_calib3d opencv_legacy opencv_contrib opencv_gpu opencv_nonfree opencv_softcascade opencv_superres - opencv_gpucodec opencv_gpuarithm opencv_gpufilters opencv_gpunvidia opencv_gpuimgproc) + opencv_gpucodec opencv_gpuarithm opencv_gpufilters opencv_gpunvidia opencv_gpuimgproc opencv_gpufeatures2d) ocv_check_dependencies(${OPENCV_GPU_SAMPLES_REQUIRED_DEPS}) -- 2.7.4