Commit 0e45a637 authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

added SURF_GPU.

added support of CV_32FC1 type to gpu copyMakeBorder.
parent a2ace58b
...@@ -591,7 +591,7 @@ namespace cv ...@@ -591,7 +591,7 @@ namespace cv
CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR); CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR);
//! copies 2D array to a larger destination array and pads borders with user-specifiable constant //! copies 2D array to a larger destination array and pads borders with user-specifiable constant
//! supports CV_8UC1, CV_8UC4, CV_32SC1 types //! supports CV_8UC1, CV_8UC4, CV_32SC1 and CV_32FC1 types
CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar()); CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar());
//! computes the integral image and integral for the squared image //! computes the integral image and integral for the squared image
...@@ -1366,6 +1366,100 @@ namespace cv ...@@ -1366,6 +1366,100 @@ namespace cv
Ptr<CvHaarClassifierCascade> oldCascade; Ptr<CvHaarClassifierCascade> oldCascade;
}; };
////////////////////////////////// SURF //////////////////////////////////////////
struct CV_EXPORTS SURFParams_GPU
{
SURFParams_GPU() :
threshold(0.1f),
nOctaves(4),
nIntervals(4),
initialScale(2.f),
l1(3.f/1.5f),
l2(5.f/1.5f),
l3(3.f/1.5f),
l4(1.f/1.5f),
edgeScale(0.81f),
initialStep(1),
extended(true),
featuresRatio(0.01f)
{
}
//! The interest operator threshold
float threshold;
//! The number of octaves to process
int nOctaves;
//! The number of intervals in each octave
int nIntervals;
//! The scale associated with the first interval of the first octave
float initialScale;
//! mask parameter l_1
float l1;
//! mask parameter l_2
float l2;
//! mask parameter l_3
float l3;
//! mask parameter l_4
float l4;
//! The amount to scale the edge rejection mask
float edgeScale;
//! The initial sampling step in pixels.
int initialStep;
//! True, if generate 128-len descriptors, false - 64-len descriptors
bool extended;
//! max features = featuresRatio * img.size().srea()
float featuresRatio;
};
class CV_EXPORTS SURF_GPU : public SURFParams_GPU
{
public:
//! returns the descriptor size in float's (64 or 128)
int descriptorSize() const;
//! upload host keypoints to device memory
static void uploadKeypoints(const vector<KeyPoint>& keypoints, GpuMat& keypointsGPU);
//! download keypoints from device to host memory
static void downloadKeypoints(const GpuMat& keypointsGPU, vector<KeyPoint>& keypoints);
//! download descriptors from device to host memory
static void downloadDescriptors(const GpuMat& descriptorsGPU, vector<float>& descriptors);
//! finds the keypoints using fast hessian detector used in SURF
//! supports CV_8UC1 (0..255) and CV_32FC1 (0..1) images
//! keypoints will have 1 row and type CV_32FC(6)
//! keypoints.at<float6>(1, i) contains i'th keypoint
//! format: (x, y, size, response, angle, octave)
void operator()(const GpuMat& img, GpuMat& keypoints);
//! finds the keypoints and computes their descriptors.
//! Optionally it can compute descriptors for the user-provided keypoints and recompute keypoints direction
void operator()(const GpuMat& img, GpuMat& keypoints, GpuMat& descriptors,
bool useProvidedKeypoints = false, bool calcOrientation = true);
void operator()(const GpuMat& img, std::vector<KeyPoint>& keypoints);
void operator()(const GpuMat& img, std::vector<KeyPoint>& keypoints, GpuMat& descriptors,
bool useProvidedKeypoints = false, bool calcOrientation = true);
void operator()(const GpuMat& img, std::vector<KeyPoint>& keypoints, std::vector<float>& descriptors,
bool useProvidedKeypoints = false, bool calcOrientation = true);
GpuMat img_float;
GpuMat img_float_tr;
GpuMat sum;
GpuMat hessianBuffer;
GpuMat maxPosBuffer;
GpuMat featuresBuffer;
};
} }
//! Speckle filtering - filters small connected components on diparity image. //! Speckle filtering - filters small connected components on diparity image.
......
...@@ -493,9 +493,7 @@ void cv::gpu::BruteForceMatcher_GPU_base::radiusMatch(const GpuMat& queryDescs, ...@@ -493,9 +493,7 @@ void cv::gpu::BruteForceMatcher_GPU_base::radiusMatch(const GpuMat& queryDescs,
} }
}; };
int major, minor; CV_Assert(hasAtomicsSupport(getDevice()));
getComputeCapability(getDevice(), major, minor);
CV_Assert(100 * major + 10 * minor >= 110); // works onle on device with CC >= 1.1
const int nQuery = queryDescs.rows; const int nQuery = queryDescs.rows;
const int nTrain = trainDescs.rows; const int nTrain = trainDescs.rows;
......
This diff is collapsed.
/*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_SURF_KEY_POINT_H__
#define __OPENCV_SURF_KEY_POINT_H__
namespace cv
{
namespace gpu
{
namespace surf
{
struct KeyPoint_GPU
{
float x;
float y;
float size;
float response;
float angle;
float octave;
};
enum KeypointLayout
{
SF_X,
SF_Y,
SF_SIZE,
SF_RESPONSE,
SF_ANGLE,
SF_OCTAVE,
SF_FEATURE_STRIDE
};
}
}
}
#endif // __OPENCV_SURF_KEY_POINT_H__
...@@ -304,7 +304,7 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub ...@@ -304,7 +304,7 @@ void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, doub
void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value) void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value)
{ {
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_8UC4 || src.type() == CV_32SC1); CV_Assert(src.type() == CV_8UC1 || src.type() == CV_8UC4 || src.type() == CV_32SC1 || src.type() == CV_32FC1);
dst.create(src.rows + top + bottom, src.cols + left + right, src.type()); dst.create(src.rows + top + bottom, src.cols + left + right, src.type());
...@@ -338,6 +338,14 @@ void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom ...@@ -338,6 +338,14 @@ void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom
dst.ptr<Npp32s>(), dst.step, dstsz, top, left, nVal) ); dst.ptr<Npp32s>(), dst.step, dstsz, top, left, nVal) );
break; break;
} }
case CV_32FC1:
{
float val = static_cast<float>(value[0]);
Npp32s nVal = *(reinterpret_cast<Npp32s*>(&val));
nppSafeCall( nppiCopyConstBorder_32s_C1R(src.ptr<Npp32s>(), src.step, srcsz,
dst.ptr<Npp32s>(), dst.step, dstsz, top, left, nVal) );
break;
}
default: default:
CV_Assert(!"Unsupported source type"); CV_Assert(!"Unsupported source type");
} }
......
...@@ -67,6 +67,7 @@ ...@@ -67,6 +67,7 @@
#include "opencv2/gpu/stream_accessor.hpp" #include "opencv2/gpu/stream_accessor.hpp"
#include "npp.h" #include "npp.h"
#include "npp_staging.h" #include "npp_staging.h"
#include "surf_key_point.h"
#define CUDART_MINIMUM_REQUIRED_VERSION 3020 #define CUDART_MINIMUM_REQUIRED_VERSION 3020
#define NPP_MINIMUM_REQUIRED_VERSION 3216 #define NPP_MINIMUM_REQUIRED_VERSION 3216
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment