added min eigen val based corner detector into gpu module

This commit is contained in:
Alexey Spizhevoy
2010-11-30 08:44:04 +00:00
parent 9adfc2cadc
commit 493d7a6e45
4 changed files with 150 additions and 18 deletions

View File

@@ -69,6 +69,7 @@ void cv::gpu::histEven(const GpuMat&, GpuMat*, int*, int*, int*) { throw_nogpu()
void cv::gpu::histRange(const GpuMat&, GpuMat&, const GpuMat&) { throw_nogpu(); }
void cv::gpu::histRange(const GpuMat&, GpuMat*, const GpuMat*) { throw_nogpu(); }
void cv::gpu::cornerHarris(const GpuMat&, GpuMat&, int, int, double) { throw_nogpu(); }
void cv::gpu::cornerMinEigenVal(const GpuMat&, GpuMat&, int, int) { throw_nogpu(); }
#else /* !defined (HAVE_CUDA) */
@@ -861,32 +862,48 @@ void cv::gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4
namespace cv { namespace gpu { namespace imgproc {
void cornerHarris_caller(const int block_size, const float k, const DevMem2D Dx, const DevMem2D Dy, DevMem2D dst);
void cornerMinEigenVal_caller(const int block_size, const DevMem2D Dx, const DevMem2D Dy, DevMem2D dst);
}}}
void cv::gpu::cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int apertureSize, double k)
namespace
{
CV_Assert(src.type() == CV_32F);
void computeGradients(const GpuMat& src, GpuMat& Dx, GpuMat& Dy, int blockSize, int ksize)
{
CV_Assert(src.type() == CV_32F);
double scale = (double)(1 << ((apertureSize > 0 ? apertureSize : 3) - 1)) * blockSize;
if (apertureSize < 0) scale *= 2.;
scale = 1./scale;
double scale = (double)(1 << ((ksize > 0 ? ksize : 3) - 1)) * blockSize;
if (ksize < 0) scale *= 2.;
scale = 1./scale;
if (ksize > 0)
{
Sobel(src, Dx, CV_32F, 1, 0, ksize, scale);
Sobel(src, Dy, CV_32F, 0, 1, ksize, scale);
}
else
{
Scharr(src, Dx, CV_32F, 1, 0, scale);
Scharr(src, Dy, CV_32F, 0, 1, scale);
}
}
}
void cv::gpu::cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k)
{
GpuMat Dx, Dy;
if (apertureSize > 0)
{
Sobel(src, Dx, CV_32F, 1, 0, apertureSize, scale);
Sobel(src, Dy, CV_32F, 0, 1, apertureSize, scale);
}
else
{
Scharr(src, Dx, CV_32F, 1, 0, scale);
Scharr(src, Dy, CV_32F, 0, 1, scale);
}
computeGradients(src, Dx, Dy, blockSize, ksize);
dst.create(src.size(), CV_32F);
imgproc::cornerHarris_caller(blockSize, (float)k, Dx, Dy, dst);
}
void cv::gpu::cornerMinEigenVal(const GpuMat& src, GpuMat& dst, int blockSize, int ksize)
{
GpuMat Dx, Dy;
computeGradients(src, Dx, Dy, blockSize, ksize);
dst.create(src.size(), CV_32F);
imgproc::cornerMinEigenVal_caller(blockSize, Dx, Dy, dst);
}
#endif /* !defined (HAVE_CUDA) */