1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 08:13:04 +04:00

added Harris corner detector into gpu module

This commit is contained in:
Alexey Spizhevoy
2010-11-30 08:04:37 +00:00
parent 6cddef8650
commit 9adfc2cadc
4 changed files with 143 additions and 0 deletions
+58
View File
@@ -603,6 +603,62 @@ void CV_GpuHistogramsTest::run( int )
}
}
////////////////////////////////////////////////////////////////////////
// Corner Harris feature detector
struct CV_GpuCornerHarrisTest: CvTest
{
CV_GpuCornerHarrisTest(): CvTest("GPU-CornerHarrisTest", "cornerHarris") {}
void run(int)
{
try
{
int rows = 1 + rand() % 300, cols = 1 + rand() % 300;
if (!compareToCpuTest(rows, cols, CV_32F, 1 + rand() % 5, -1)) return;
for (int i = 0; i < 3; ++i)
{
rows = 1 + rand() % 300; cols = 1 + rand() % 300;
if (!compareToCpuTest(rows, cols, CV_32F, 1 + rand() % 5, 1 + 2 * (rand() % 4))) return;
}
}
catch (const Exception& e)
{
if (!check_and_treat_gpu_exception(e, ts)) throw;
return;
}
}
bool compareToCpuTest(int rows, int cols, int depth, int blockSize, int apertureSize)
{
RNG rng;
cv::Mat src(rows, cols, depth);
if (depth == CV_32F)
rng.fill(src, RNG::UNIFORM, cv::Scalar(0), cv::Scalar(1));
double k = 0.1;
int borderType = BORDER_DEFAULT;
cv::Mat dst_gold;
cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);
cv::gpu::GpuMat dst;
cv::gpu::cornerHarris(cv::gpu::GpuMat(src), dst, blockSize, apertureSize, k);
cv::Mat dsth = dst;
for (int i = apertureSize + 2; i < dst.rows - apertureSize - 2; ++i)
{
for (int j = apertureSize + 2; j < dst.cols - apertureSize - 2; ++j)
{
float a = dst_gold.at<float>(i, j);
float b = dsth.at<float>(i, j);
if (fabs(a - b) > 1e-3f) return false;
}
}
return true;
}
};
/////////////////////////////////////////////////////////////////////////////
/////////////////// tests registration /////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
@@ -620,3 +676,5 @@ CV_GpuNppImageIntegralTest CV_GpuNppImageIntegral_test;
CV_GpuNppImageCannyTest CV_GpuNppImageCanny_test;
CV_GpuCvtColorTest CV_GpuCvtColor_test;
CV_GpuHistogramsTest CV_GpuHistograms_test;
CV_GpuCornerHarrisTest CV_GpuCornerHarris_test;