removed unnecessary code from gpu::matchTemplate

pull/13383/head
Alexey Spizhevoy 14 years ago
parent 655120febc
commit d091ae5746
  1. 24
      modules/gpu/src/cuda/match_template.cu
  2. 4
      tests/gpu/src/match_template.cpp

@ -559,8 +559,8 @@ __global__ void matchTemplatePreparedKernel_CCOFF_NORMED_8U(
float image_sqsum_ = (float)( float image_sqsum_ = (float)(
(image_sqsum.ptr(y + h)[x + w] - image_sqsum.ptr(y)[x + w]) - (image_sqsum.ptr(y + h)[x + w] - image_sqsum.ptr(y)[x + w]) -
(image_sqsum.ptr(y + h)[x] - image_sqsum.ptr(y)[x])); (image_sqsum.ptr(y + h)[x] - image_sqsum.ptr(y)[x]));
result.ptr(y)[x] = min(1.f, (ccorr - image_sum_ * templ_sum_scale) * result.ptr(y)[x] = (ccorr - image_sum_ * templ_sum_scale) *
rsqrtf(templ_sqsum_scale * max(1.f, image_sqsum_ - weight * image_sum_ * image_sum_))); rsqrtf(templ_sqsum_scale * max(1.f, image_sqsum_ - weight * image_sum_ * image_sum_));
} }
} }
@ -612,8 +612,8 @@ __global__ void matchTemplatePreparedKernel_CCOFF_NORMED_8UC2(
float ccorr = result.ptr(y)[x]; float ccorr = result.ptr(y)[x];
float rdenom = rsqrtf(templ_sqsum_scale * max(1.f, image_sqsum_r_ - weight * image_sum_r_ * image_sum_r_ float rdenom = rsqrtf(templ_sqsum_scale * max(1.f, image_sqsum_r_ - weight * image_sum_r_ * image_sum_r_
+ image_sqsum_g_ - weight * image_sum_g_ * image_sum_g_)); + image_sqsum_g_ - weight * image_sum_g_ * image_sum_g_));
result.ptr(y)[x] = min(1.f, (ccorr - image_sum_r_ * templ_sum_scale_r result.ptr(y)[x] = (ccorr - image_sum_r_ * templ_sum_scale_r
- image_sum_g_ * templ_sum_scale_g) * rdenom); - image_sum_g_ * templ_sum_scale_g) * rdenom;
} }
} }
@ -681,9 +681,9 @@ __global__ void matchTemplatePreparedKernel_CCOFF_NORMED_8UC3(
float rdenom = rsqrtf(templ_sqsum_scale * max(1.f, image_sqsum_r_ - weight * image_sum_r_ * image_sum_r_ float rdenom = rsqrtf(templ_sqsum_scale * max(1.f, image_sqsum_r_ - weight * image_sum_r_ * image_sum_r_
+ image_sqsum_g_ - weight * image_sum_g_ * image_sum_g_ + image_sqsum_g_ - weight * image_sum_g_ * image_sum_g_
+ image_sqsum_b_ - weight * image_sum_b_ * image_sum_b_)); + image_sqsum_b_ - weight * image_sum_b_ * image_sum_b_));
result.ptr(y)[x] = min(1.f, (ccorr - image_sum_r_ * templ_sum_scale_r result.ptr(y)[x] = (ccorr - image_sum_r_ * templ_sum_scale_r
- image_sum_g_ * templ_sum_scale_g - image_sum_g_ * templ_sum_scale_g
- image_sum_b_ * templ_sum_scale_b) * rdenom); - image_sum_b_ * templ_sum_scale_b) * rdenom;
} }
} }
@ -764,10 +764,10 @@ __global__ void matchTemplatePreparedKernel_CCOFF_NORMED_8UC4(
+ image_sqsum_g_ - weight * image_sum_g_ * image_sum_g_ + image_sqsum_g_ - weight * image_sum_g_ * image_sum_g_
+ image_sqsum_b_ - weight * image_sum_b_ * image_sum_b_ + image_sqsum_b_ - weight * image_sum_b_ * image_sum_b_
+ image_sqsum_a_ - weight * image_sum_a_ * image_sum_a_)); + image_sqsum_a_ - weight * image_sum_a_ * image_sum_a_));
result.ptr(y)[x] = min(1.f, (ccorr - image_sum_r_ * templ_sum_scale_r result.ptr(y)[x] = (ccorr - image_sum_r_ * templ_sum_scale_r
- image_sum_g_ * templ_sum_scale_g - image_sum_g_ * templ_sum_scale_g
- image_sum_b_ * templ_sum_scale_b - image_sum_b_ * templ_sum_scale_b
- image_sum_a_ * templ_sum_scale_a) * rdenom); - image_sum_a_ * templ_sum_scale_a) * rdenom;
} }
} }
@ -822,7 +822,7 @@ __global__ void normalizeKernel_8U(
float image_sqsum_ = (float)( float image_sqsum_ = (float)(
(image_sqsum.ptr(y + h)[(x + w) * cn] - image_sqsum.ptr(y)[(x + w) * cn]) - (image_sqsum.ptr(y + h)[(x + w) * cn] - image_sqsum.ptr(y)[(x + w) * cn]) -
(image_sqsum.ptr(y + h)[x * cn] - image_sqsum.ptr(y)[x * cn])); (image_sqsum.ptr(y + h)[x * cn] - image_sqsum.ptr(y)[x * cn]));
result.ptr(y)[x] = min(1.f, result.ptr(y)[x] * rsqrtf(max(1.f, image_sqsum_) * templ_sqsum)); result.ptr(y)[x] = result.ptr(y)[x] * rsqrtf(max(1.f, image_sqsum_) * templ_sqsum);
} }
} }

@ -124,7 +124,7 @@ struct CV_GpuMatchTemplateTest: CvTest
F(t = clock();) F(t = clock();)
gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCORR_NORMED); gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCORR_NORMED);
F(cout << "gpu_block: " << clock() - t << endl;) F(cout << "gpu_block: " << clock() - t << endl;)
if (!check(dst_gold, Mat(dst), h * w * 1e-4f)) return; if (!check(dst_gold, Mat(dst), h * w * 1e-6f)) return;
gen(image, n, m, CV_8U, cn); gen(image, n, m, CV_8U, cn);
gen(templ, h, w, CV_8U, cn); gen(templ, h, w, CV_8U, cn);
@ -146,7 +146,7 @@ struct CV_GpuMatchTemplateTest: CvTest
F(t = clock();) F(t = clock();)
gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCOEFF_NORMED); gpu::matchTemplate(gpu::GpuMat(image), gpu::GpuMat(templ), dst, CV_TM_CCOEFF_NORMED);
F(cout << "gpu_block: " << clock() - t << endl;) F(cout << "gpu_block: " << clock() - t << endl;)
if (!check(dst_gold, Mat(dst), h * w * 1e-4f)) return; if (!check(dst_gold, Mat(dst), h * w * 1e-6f)) return;
gen(image, n, m, CV_32F, cn); gen(image, n, m, CV_32F, cn);
gen(templ, h, w, CV_32F, cn); gen(templ, h, w, CV_32F, cn);

Loading…
Cancel
Save