GPU: updated upsample, downsample functions, added pyrDown, pyrUp, added support of 16S filtering; put spherical warper on GPU (from opencv_stitching)

This commit is contained in:
Alexey Spizhevoy
2011-06-30 14:39:48 +00:00
parent a44d6aacc8
commit 674b763395
19 changed files with 697 additions and 378 deletions

View File

@@ -1372,99 +1372,6 @@ TEST_P(ReprojectImageTo3D, Accuracy)
INSTANTIATE_TEST_CASE_P(ImgProc, ReprojectImageTo3D, testing::ValuesIn(devices()));
////////////////////////////////////////////////////////////////////////////////
// Downsample
struct Downsample : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int> >
{
cv::gpu::DeviceInfo devInfo;
int k;
cv::Size size;
cv::Size dst_gold_size;
virtual void SetUp()
{
devInfo = std::tr1::get<0>(GetParam());
k = std::tr1::get<1>(GetParam());
cv::gpu::setDevice(devInfo.deviceID());
cv::RNG& rng = cvtest::TS::ptr()->get_rng();
size = cv::Size(200 + cvtest::randInt(rng) % 1000, 200 + cvtest::randInt(rng) % 1000);
dst_gold_size = cv::Size((size.width + k - 1) / k, (size.height + k - 1) / k);
}
};
TEST_P(Downsample, Accuracy8U)
{
PRINT_PARAM(devInfo);
PRINT_PARAM(size);
PRINT_PARAM(k);
cv::RNG& rng = cvtest::TS::ptr()->get_rng();
cv::Mat src = cvtest::randomMat(rng, size, CV_8U, 0, 255, false);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpures;
cv::gpu::downsample(cv::gpu::GpuMat(src), gpures, k);
gpures.download(dst);
);
ASSERT_EQ(dst_gold_size, dst.size());
for (int y = 0; y < dst.rows; ++y)
{
for (int x = 0; x < dst.cols; ++x)
{
int gold = src.at<uchar>(y * k, x * k);
int res = dst.at<uchar>(y, x);
ASSERT_EQ(gold, res);
}
}
}
TEST_P(Downsample, Accuracy32F)
{
PRINT_PARAM(devInfo);
PRINT_PARAM(size);
PRINT_PARAM(k);
cv::RNG& rng = cvtest::TS::ptr()->get_rng();
cv::Mat src = cvtest::randomMat(rng, size, CV_32F, 0, 1.0, false);
cv::Mat dst;
ASSERT_NO_THROW(
cv::gpu::GpuMat gpures;
cv::gpu::downsample(cv::gpu::GpuMat(src), gpures, k);
gpures.download(dst);
);
ASSERT_EQ(dst_gold_size, dst.size());
for (int y = 0; y < dst.rows; ++y)
{
for (int x = 0; x < dst.cols; ++x)
{
float gold = src.at<float>(y * k, x * k);
float res = dst.at<float>(y, x);
ASSERT_FLOAT_EQ(gold, res);
}
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, Downsample, testing::Combine(
testing::ValuesIn(devices()),
testing::Range(2, 6)));
////////////////////////////////////////////////////////////////////////////////
// meanShift