added assertion for small image sizes to SURF_GPU (ticket #1323)
This commit is contained in:
parent
914ed44e28
commit
b371bd68df
@ -323,7 +323,7 @@ namespace cv { namespace gpu { namespace surf
|
|||||||
const int layer_rows = img_rows >> octave;
|
const int layer_rows = img_rows >> octave;
|
||||||
const int layer_cols = img_cols >> octave;
|
const int layer_cols = img_cols >> octave;
|
||||||
|
|
||||||
int min_margin = ((calcSize(octave, 2) >> 1) >> octave) + 1;
|
const int min_margin = ((calcSize(octave, 2) >> 1) >> octave) + 1;
|
||||||
|
|
||||||
dim3 threads(16, 16);
|
dim3 threads(16, 16);
|
||||||
|
|
||||||
|
@ -84,6 +84,21 @@ using namespace cv::gpu::surf;
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
int calcSize(int octave, int layer)
|
||||||
|
{
|
||||||
|
/* Wavelet size at first layer of first octave. */
|
||||||
|
const int HAAR_SIZE0 = 9;
|
||||||
|
|
||||||
|
/* Wavelet size increment between layers. This should be an even number,
|
||||||
|
such that the wavelet sizes in an octave are either all even or all odd.
|
||||||
|
This ensures that when looking for the neighbours of a sample, the layers
|
||||||
|
|
||||||
|
above and below are aligned correctly. */
|
||||||
|
const int HAAR_SIZE_INC = 6;
|
||||||
|
|
||||||
|
return (HAAR_SIZE0 + HAAR_SIZE_INC * layer) << octave;
|
||||||
|
}
|
||||||
|
|
||||||
class SURF_GPU_Invoker : private CvSURFParams
|
class SURF_GPU_Invoker : private CvSURFParams
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -103,6 +118,16 @@ namespace
|
|||||||
CV_Assert(nOctaves > 0 && nOctaveLayers > 0);
|
CV_Assert(nOctaves > 0 && nOctaveLayers > 0);
|
||||||
CV_Assert(TargetArchs::builtWith(GLOBAL_ATOMICS) && DeviceInfo().supports(GLOBAL_ATOMICS));
|
CV_Assert(TargetArchs::builtWith(GLOBAL_ATOMICS) && DeviceInfo().supports(GLOBAL_ATOMICS));
|
||||||
|
|
||||||
|
const int min_size = calcSize(nOctaves - 1, 0);
|
||||||
|
CV_Assert(img_rows - min_size >= 0);
|
||||||
|
CV_Assert(img_cols - min_size >= 0);
|
||||||
|
|
||||||
|
const int layer_rows = img_rows >> (nOctaves - 1);
|
||||||
|
const int layer_cols = img_cols >> (nOctaves - 1);
|
||||||
|
const int min_margin = ((calcSize((nOctaves - 1), 2) >> 1) >> (nOctaves - 1)) + 1;
|
||||||
|
CV_Assert(layer_rows - 2 * min_margin > 0);
|
||||||
|
CV_Assert(layer_cols - 2 * min_margin > 0);
|
||||||
|
|
||||||
maxFeatures = min(static_cast<int>(img.size().area() * surf.keypointsRatio), 65535);
|
maxFeatures = min(static_cast<int>(img.size().area() * surf.keypointsRatio), 65535);
|
||||||
maxCandidates = min(static_cast<int>(1.5 * maxFeatures), 65535);
|
maxCandidates = min(static_cast<int>(1.5 * maxFeatures), 65535);
|
||||||
|
|
||||||
@ -279,20 +304,6 @@ void cv::gpu::SURF_GPU::uploadKeypoints(const vector<KeyPoint>& keypoints, GpuMa
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
int calcSize(int octave, int layer)
|
|
||||||
{
|
|
||||||
/* Wavelet size at first layer of first octave. */
|
|
||||||
const int HAAR_SIZE0 = 9;
|
|
||||||
|
|
||||||
/* Wavelet size increment between layers. This should be an even number,
|
|
||||||
such that the wavelet sizes in an octave are either all even or all odd.
|
|
||||||
This ensures that when looking for the neighbours of a sample, the layers
|
|
||||||
above and below are aligned correctly. */
|
|
||||||
const int HAAR_SIZE_INC = 6;
|
|
||||||
|
|
||||||
return (HAAR_SIZE0 + HAAR_SIZE_INC * layer) << octave;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getPointOctave(float size, const CvSURFParams& params)
|
int getPointOctave(float size, const CvSURFParams& params)
|
||||||
{
|
{
|
||||||
int best_octave = 0;
|
int best_octave = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user