mirror of
https://github.com/opencv/opencv.git
synced 2024-12-01 06:49:50 +08:00
added upright parameter to SURF_GPU
This commit is contained in:
parent
b6eb12c8dd
commit
9342c4b076
@ -1545,7 +1545,7 @@ namespace cv
|
|||||||
SURF_GPU();
|
SURF_GPU();
|
||||||
//! the full constructor taking all the necessary parameters
|
//! the full constructor taking all the necessary parameters
|
||||||
explicit SURF_GPU(double _hessianThreshold, int _nOctaves=4,
|
explicit SURF_GPU(double _hessianThreshold, int _nOctaves=4,
|
||||||
int _nOctaveLayers=2, bool _extended=false, float _keypointsRatio=0.01f);
|
int _nOctaveLayers=2, bool _extended=false, float _keypointsRatio=0.01f, bool _upright = false);
|
||||||
|
|
||||||
//! returns the descriptor size in float's (64 or 128)
|
//! returns the descriptor size in float's (64 or 128)
|
||||||
int descriptorSize() const;
|
int descriptorSize() const;
|
||||||
@ -1579,6 +1579,8 @@ namespace cv
|
|||||||
//! max keypoints = keypointsRatio * img.size().area()
|
//! max keypoints = keypointsRatio * img.size().area()
|
||||||
float keypointsRatio;
|
float keypointsRatio;
|
||||||
|
|
||||||
|
bool upright;
|
||||||
|
|
||||||
GpuMat sum, mask1, maskSum, intBuffer;
|
GpuMat sum, mask1, maskSum, intBuffer;
|
||||||
|
|
||||||
GpuMat det, trace;
|
GpuMat det, trace;
|
||||||
|
@ -49,7 +49,7 @@ using namespace std;
|
|||||||
#if !defined (HAVE_CUDA)
|
#if !defined (HAVE_CUDA)
|
||||||
|
|
||||||
cv::gpu::SURF_GPU::SURF_GPU() { throw_nogpu(); }
|
cv::gpu::SURF_GPU::SURF_GPU() { throw_nogpu(); }
|
||||||
cv::gpu::SURF_GPU::SURF_GPU(double, int, int, bool, float) { throw_nogpu(); }
|
cv::gpu::SURF_GPU::SURF_GPU(double, int, int, bool, float, bool) { throw_nogpu(); }
|
||||||
int cv::gpu::SURF_GPU::descriptorSize() const { throw_nogpu(); return 0;}
|
int cv::gpu::SURF_GPU::descriptorSize() const { throw_nogpu(); return 0;}
|
||||||
void cv::gpu::SURF_GPU::uploadKeypoints(const vector<KeyPoint>&, GpuMat&) { throw_nogpu(); }
|
void cv::gpu::SURF_GPU::uploadKeypoints(const vector<KeyPoint>&, GpuMat&) { throw_nogpu(); }
|
||||||
void cv::gpu::SURF_GPU::downloadKeypoints(const GpuMat&, vector<KeyPoint>&) { throw_nogpu(); }
|
void cv::gpu::SURF_GPU::downloadKeypoints(const GpuMat&, vector<KeyPoint>&) { throw_nogpu(); }
|
||||||
@ -92,7 +92,9 @@ namespace
|
|||||||
|
|
||||||
img_cols(img.cols), img_rows(img.rows),
|
img_cols(img.cols), img_rows(img.rows),
|
||||||
|
|
||||||
use_mask(!mask.empty())
|
use_mask(!mask.empty()),
|
||||||
|
|
||||||
|
upright(surf.upright)
|
||||||
{
|
{
|
||||||
CV_Assert(!img.empty() && img.type() == CV_8UC1);
|
CV_Assert(!img.empty() && img.type() == CV_8UC1);
|
||||||
CV_Assert(mask.empty() || (mask.size() == img.size() && mask.type() == CV_8UC1));
|
CV_Assert(mask.empty() || (mask.size() == img.size() && mask.type() == CV_8UC1));
|
||||||
@ -176,7 +178,15 @@ namespace
|
|||||||
cudaSafeCall( cudaMemcpy(&featureCounter, d_counters, sizeof(unsigned int), cudaMemcpyDeviceToHost) );
|
cudaSafeCall( cudaMemcpy(&featureCounter, d_counters, sizeof(unsigned int), cudaMemcpyDeviceToHost) );
|
||||||
featureCounter = std::min(featureCounter, static_cast<unsigned int>(maxFeatures));
|
featureCounter = std::min(featureCounter, static_cast<unsigned int>(maxFeatures));
|
||||||
|
|
||||||
|
if (!upright)
|
||||||
findOrientation(featuresBuffer.colRange(0, featureCounter), keypoints);
|
findOrientation(featuresBuffer.colRange(0, featureCounter), keypoints);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (featureCounter > 0)
|
||||||
|
featuresBuffer.colRange(0, featureCounter).copyTo(keypoints);
|
||||||
|
else
|
||||||
|
keypoints.release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void findOrientation(const GpuMat& features, GpuMat& keypoints)
|
void findOrientation(const GpuMat& features, GpuMat& keypoints)
|
||||||
@ -225,6 +235,8 @@ namespace
|
|||||||
|
|
||||||
bool use_mask;
|
bool use_mask;
|
||||||
|
|
||||||
|
bool upright;
|
||||||
|
|
||||||
int maxCandidates;
|
int maxCandidates;
|
||||||
int maxFeatures;
|
int maxFeatures;
|
||||||
int maxKeypoints;
|
int maxKeypoints;
|
||||||
@ -240,15 +252,17 @@ cv::gpu::SURF_GPU::SURF_GPU()
|
|||||||
nOctaves = 4;
|
nOctaves = 4;
|
||||||
nOctaveLayers = 2;
|
nOctaveLayers = 2;
|
||||||
keypointsRatio = 0.01f;
|
keypointsRatio = 0.01f;
|
||||||
|
upright = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cv::gpu::SURF_GPU::SURF_GPU(double _threshold, int _nOctaves, int _nOctaveLayers, bool _extended, float _keypointsRatio)
|
cv::gpu::SURF_GPU::SURF_GPU(double _threshold, int _nOctaves, int _nOctaveLayers, bool _extended, float _keypointsRatio, bool _upright)
|
||||||
{
|
{
|
||||||
hessianThreshold = _threshold;
|
hessianThreshold = _threshold;
|
||||||
extended = _extended;
|
extended = _extended;
|
||||||
nOctaves = _nOctaves;
|
nOctaves = _nOctaves;
|
||||||
nOctaveLayers = _nOctaveLayers;
|
nOctaveLayers = _nOctaveLayers;
|
||||||
keypointsRatio = _keypointsRatio;
|
keypointsRatio = _keypointsRatio;
|
||||||
|
upright = _upright;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cv::gpu::SURF_GPU::descriptorSize() const
|
int cv::gpu::SURF_GPU::descriptorSize() const
|
||||||
@ -387,7 +401,7 @@ void cv::gpu::SURF_GPU::operator()(const GpuMat& img, const GpuMat& mask, GpuMat
|
|||||||
|
|
||||||
if (!useProvidedKeypoints)
|
if (!useProvidedKeypoints)
|
||||||
surf.detectKeypoints(keypoints);
|
surf.detectKeypoints(keypoints);
|
||||||
else
|
else if (!upright)
|
||||||
{
|
{
|
||||||
GpuMat keypointsBuf;
|
GpuMat keypointsBuf;
|
||||||
surf.findOrientation(keypoints, keypointsBuf);
|
surf.findOrientation(keypoints, keypointsBuf);
|
||||||
|
Loading…
Reference in New Issue
Block a user