2011-01-24 11:33:01 +01:00
|
|
|
#include <opencv2/imgproc/imgproc.hpp>
|
2011-01-25 12:45:29 +01:00
|
|
|
#include <opencv2/highgui/highgui.hpp>
|
2011-01-24 11:33:01 +01:00
|
|
|
#include <opencv2/gpu/gpu.hpp>
|
|
|
|
#include "performance.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
INIT(matchTemplate)
|
2011-01-25 15:43:54 +01:00
|
|
|
{
|
2011-01-26 08:49:56 +01:00
|
|
|
Mat src; gen(src, 500, 500, CV_32F, 0, 1);
|
|
|
|
Mat templ; gen(templ, 500, 500, CV_32F, 0, 1);
|
2011-01-25 15:43:54 +01:00
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
gpu::GpuMat d_src(src), d_templ(templ), d_dst;
|
2011-01-25 15:43:54 +01:00
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
gpu::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR);
|
2011-01-25 15:43:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-24 11:33:01 +01:00
|
|
|
TEST(matchTemplate)
|
|
|
|
{
|
2011-01-26 08:49:56 +01:00
|
|
|
Mat src, templ, dst;
|
2011-01-25 15:43:54 +01:00
|
|
|
gen(src, 3000, 3000, CV_32F, 0, 1);
|
2011-01-25 09:32:45 +01:00
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
gpu::GpuMat d_src(src), d_templ, d_dst;
|
2011-01-25 09:32:45 +01:00
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
for (int templ_size = 5; templ_size < 200; templ_size *= 5)
|
2011-01-24 11:33:01 +01:00
|
|
|
{
|
2011-01-25 15:43:54 +01:00
|
|
|
SUBTEST << "src " << src.rows << ", templ " << templ_size << ", 32F, CCORR";
|
2011-01-24 11:33:01 +01:00
|
|
|
|
2011-01-25 12:45:29 +01:00
|
|
|
gen(templ, templ_size, templ_size, CV_32F, 0, 1);
|
2011-01-26 08:49:56 +01:00
|
|
|
dst.create(src.rows - templ.rows + 1, src.cols - templ.cols + 1, CV_32F);
|
2011-01-24 11:33:01 +01:00
|
|
|
|
|
|
|
CPU_ON;
|
2011-01-26 08:49:56 +01:00
|
|
|
matchTemplate(src, templ, dst, CV_TM_CCORR);
|
2011-01-24 11:33:01 +01:00
|
|
|
CPU_OFF;
|
|
|
|
|
2011-01-25 09:32:45 +01:00
|
|
|
d_templ = templ;
|
2011-01-26 08:49:56 +01:00
|
|
|
d_dst.create(d_src.rows - d_templ.rows + 1, d_src.cols - d_templ.cols + 1, CV_32F);
|
2011-01-24 11:33:01 +01:00
|
|
|
|
|
|
|
GPU_ON;
|
2011-01-26 08:49:56 +01:00
|
|
|
gpu::matchTemplate(d_src, d_templ, d_dst, CV_TM_CCORR);
|
2011-01-24 11:33:01 +01:00
|
|
|
GPU_OFF;
|
|
|
|
}
|
|
|
|
}
|
2011-01-25 09:32:45 +01:00
|
|
|
|
|
|
|
|
2011-01-25 10:54:17 +01:00
|
|
|
TEST(minMaxLoc)
|
2011-01-25 09:32:45 +01:00
|
|
|
{
|
|
|
|
Mat src;
|
|
|
|
gpu::GpuMat d_src;
|
|
|
|
|
|
|
|
double min_val, max_val;
|
|
|
|
Point min_loc, max_loc;
|
|
|
|
|
|
|
|
for (int size = 2000; size <= 8000; size *= 2)
|
|
|
|
{
|
2011-01-25 15:43:54 +01:00
|
|
|
SUBTEST << "src " << size << ", 32F, no mask";
|
2011-01-25 09:32:45 +01:00
|
|
|
|
2011-01-25 12:45:29 +01:00
|
|
|
gen(src, size, size, CV_32F, 0, 1);
|
2011-01-25 09:32:45 +01:00
|
|
|
|
|
|
|
CPU_ON;
|
|
|
|
minMaxLoc(src, &min_val, &max_val, &min_loc, &max_loc);
|
|
|
|
CPU_OFF;
|
|
|
|
|
|
|
|
d_src = src;
|
|
|
|
|
|
|
|
GPU_ON;
|
|
|
|
gpu::minMaxLoc(d_src, &min_val, &max_val, &min_loc, &max_loc);
|
|
|
|
GPU_OFF;
|
|
|
|
}
|
2011-01-25 10:54:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(remap)
|
|
|
|
{
|
|
|
|
Mat src, dst, xmap, ymap;
|
|
|
|
gpu::GpuMat d_src, d_dst, d_xmap, d_ymap;
|
|
|
|
|
|
|
|
for (int size = 1000; size <= 8000; size *= 2)
|
|
|
|
{
|
2011-01-25 15:43:54 +01:00
|
|
|
SUBTEST << "src " << size << " and 8UC1, 32FC1 maps";
|
2011-01-25 10:54:17 +01:00
|
|
|
|
2011-01-25 12:45:29 +01:00
|
|
|
gen(src, size, size, CV_8UC1, 0, 256);
|
|
|
|
gen(xmap, size, size, CV_32F, 0, size);
|
|
|
|
gen(ymap, size, size, CV_32F, 0, size);
|
2011-01-26 08:49:56 +01:00
|
|
|
dst.create(xmap.size(), src.type());
|
2011-01-25 10:54:17 +01:00
|
|
|
|
|
|
|
CPU_ON;
|
|
|
|
remap(src, dst, xmap, ymap, INTER_LINEAR);
|
|
|
|
CPU_OFF;
|
|
|
|
|
|
|
|
d_src = src;
|
|
|
|
d_xmap = xmap;
|
|
|
|
d_ymap = ymap;
|
2011-01-26 08:49:56 +01:00
|
|
|
d_dst.create(d_xmap.size(), d_src.type());
|
2011-01-25 10:54:17 +01:00
|
|
|
|
|
|
|
GPU_ON;
|
|
|
|
gpu::remap(d_src, d_dst, d_xmap, d_ymap);
|
|
|
|
GPU_OFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(dft)
|
|
|
|
{
|
|
|
|
Mat src, dst;
|
|
|
|
gpu::GpuMat d_src, d_dst;
|
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
for (int size = 1000; size <= 4000; size *= 2)
|
2011-01-25 10:54:17 +01:00
|
|
|
{
|
|
|
|
SUBTEST << "size " << size << ", 32FC2, complex-to-complex";
|
|
|
|
|
2011-01-25 12:45:29 +01:00
|
|
|
gen(src, size, size, CV_32FC2, Scalar::all(0), Scalar::all(1));
|
2011-01-26 08:49:56 +01:00
|
|
|
dst.create(src.size(), src.type());
|
2011-01-25 10:54:17 +01:00
|
|
|
|
|
|
|
CPU_ON;
|
|
|
|
dft(src, dst);
|
|
|
|
CPU_OFF;
|
|
|
|
|
|
|
|
d_src = src;
|
2011-01-26 08:49:56 +01:00
|
|
|
d_dst.create(d_src.size(), d_src.type());
|
2011-01-25 10:54:17 +01:00
|
|
|
|
|
|
|
GPU_ON;
|
|
|
|
gpu::dft(d_src, d_dst, Size(size, size));
|
|
|
|
GPU_OFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(cornerHarris)
|
|
|
|
{
|
|
|
|
Mat src, dst;
|
|
|
|
gpu::GpuMat d_src, d_dst;
|
|
|
|
|
|
|
|
for (int size = 2000; size <= 4000; size *= 2)
|
|
|
|
{
|
|
|
|
SUBTEST << "size " << size << ", 32FC1";
|
|
|
|
|
2011-01-25 12:45:29 +01:00
|
|
|
gen(src, size, size, CV_32F, 0, 1);
|
2011-01-26 08:49:56 +01:00
|
|
|
dst.create(src.size(), src.type());
|
2011-01-25 10:54:17 +01:00
|
|
|
|
|
|
|
CPU_ON;
|
|
|
|
cornerHarris(src, dst, 5, 7, 0.1, BORDER_REFLECT101);
|
|
|
|
CPU_OFF;
|
|
|
|
|
|
|
|
d_src = src;
|
2011-01-26 08:49:56 +01:00
|
|
|
d_dst.create(src.size(), src.type());
|
2011-01-25 10:54:17 +01:00
|
|
|
|
|
|
|
GPU_ON;
|
|
|
|
gpu::cornerHarris(d_src, d_dst, 5, 7, 0.1);
|
|
|
|
GPU_OFF;
|
|
|
|
}
|
2011-01-25 11:37:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
TEST(integral)
|
2011-01-25 11:37:48 +01:00
|
|
|
{
|
2011-01-26 08:49:56 +01:00
|
|
|
Mat src, sum;
|
|
|
|
gpu::GpuMat d_src, d_sum;
|
|
|
|
|
|
|
|
for (int size = 1000; size <= 8000; size *= 2)
|
|
|
|
{
|
|
|
|
SUBTEST << "size " << size << ", 8U";
|
2011-01-25 11:37:48 +01:00
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
gen(src, size, size, CV_8U, 0, 256);
|
|
|
|
sum.create(size + 1, size + 1, CV_32S);
|
2011-01-25 11:37:48 +01:00
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
CPU_ON;
|
|
|
|
integral(src, sum);
|
|
|
|
CPU_OFF;
|
2011-01-25 11:37:48 +01:00
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
d_src = src;
|
|
|
|
d_sum.create(size + 1, size + 1, CV_32S);
|
2011-01-25 11:37:48 +01:00
|
|
|
|
2011-01-26 08:49:56 +01:00
|
|
|
GPU_ON;
|
|
|
|
gpu::integral(d_src, d_sum);
|
|
|
|
GPU_OFF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TEST(norm)
|
|
|
|
{
|
|
|
|
Mat src;
|
|
|
|
gpu::GpuMat d_src;
|
|
|
|
|
|
|
|
for (int size = 1000; size <= 8000; size *= 2)
|
|
|
|
{
|
|
|
|
SUBTEST << "size " << size << ", 8U";
|
|
|
|
|
|
|
|
gen(src, size, size, CV_8U, 0, 256);
|
|
|
|
|
|
|
|
CPU_ON;
|
|
|
|
norm(src);
|
|
|
|
CPU_OFF;
|
|
|
|
|
|
|
|
d_src = src;
|
|
|
|
|
|
|
|
GPU_ON;
|
|
|
|
gpu::norm(d_src);
|
|
|
|
GPU_OFF;
|
|
|
|
}
|
2011-01-25 11:37:48 +01:00
|
|
|
}
|