Commit ea2f5b13 authored by Vladislav Vinogradov's avatar Vladislav Vinogradov

added BORDER_REFLECT and BORDER_WRAP support to gpu module

switched to gpu::remap in opencv_stitching
parent a5df21bf
...@@ -151,7 +151,7 @@ namespace cv { namespace gpu { namespace filters ...@@ -151,7 +151,7 @@ namespace cv { namespace gpu { namespace filters
void linearRowFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream) void linearRowFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream)
{ {
typedef void (*caller_t)(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor, cudaStream_t stream); typedef void (*caller_t)(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor, cudaStream_t stream);
static const caller_t callers[3][17] = static const caller_t callers[5][17] =
{ {
{ {
0, 0,
...@@ -170,7 +170,7 @@ namespace cv { namespace gpu { namespace filters ...@@ -170,7 +170,7 @@ namespace cv { namespace gpu { namespace filters
linearRowFilter_caller<13, T, D, BrdRowReflect101>, linearRowFilter_caller<13, T, D, BrdRowReflect101>,
linearRowFilter_caller<14, T, D, BrdRowReflect101>, linearRowFilter_caller<14, T, D, BrdRowReflect101>,
linearRowFilter_caller<15, T, D, BrdRowReflect101>, linearRowFilter_caller<15, T, D, BrdRowReflect101>,
linearRowFilter_caller<16, T, D, BrdRowReflect101>, linearRowFilter_caller<16, T, D, BrdRowReflect101>
}, },
{ {
0, 0,
...@@ -189,7 +189,7 @@ namespace cv { namespace gpu { namespace filters ...@@ -189,7 +189,7 @@ namespace cv { namespace gpu { namespace filters
linearRowFilter_caller<13, T, D, BrdRowReplicate>, linearRowFilter_caller<13, T, D, BrdRowReplicate>,
linearRowFilter_caller<14, T, D, BrdRowReplicate>, linearRowFilter_caller<14, T, D, BrdRowReplicate>,
linearRowFilter_caller<15, T, D, BrdRowReplicate>, linearRowFilter_caller<15, T, D, BrdRowReplicate>,
linearRowFilter_caller<16, T, D, BrdRowReplicate>, linearRowFilter_caller<16, T, D, BrdRowReplicate>
}, },
{ {
0, 0,
...@@ -208,7 +208,45 @@ namespace cv { namespace gpu { namespace filters ...@@ -208,7 +208,45 @@ namespace cv { namespace gpu { namespace filters
linearRowFilter_caller<13, T, D, BrdRowConstant>, linearRowFilter_caller<13, T, D, BrdRowConstant>,
linearRowFilter_caller<14, T, D, BrdRowConstant>, linearRowFilter_caller<14, T, D, BrdRowConstant>,
linearRowFilter_caller<15, T, D, BrdRowConstant>, linearRowFilter_caller<15, T, D, BrdRowConstant>,
linearRowFilter_caller<16, T, D, BrdRowConstant>, linearRowFilter_caller<16, T, D, BrdRowConstant>
},
{
0,
linearRowFilter_caller<1 , T, D, BrdRowReflect>,
linearRowFilter_caller<2 , T, D, BrdRowReflect>,
linearRowFilter_caller<3 , T, D, BrdRowReflect>,
linearRowFilter_caller<4 , T, D, BrdRowReflect>,
linearRowFilter_caller<5 , T, D, BrdRowReflect>,
linearRowFilter_caller<6 , T, D, BrdRowReflect>,
linearRowFilter_caller<7 , T, D, BrdRowReflect>,
linearRowFilter_caller<8 , T, D, BrdRowReflect>,
linearRowFilter_caller<9 , T, D, BrdRowReflect>,
linearRowFilter_caller<10, T, D, BrdRowReflect>,
linearRowFilter_caller<11, T, D, BrdRowReflect>,
linearRowFilter_caller<12, T, D, BrdRowReflect>,
linearRowFilter_caller<13, T, D, BrdRowReflect>,
linearRowFilter_caller<14, T, D, BrdRowReflect>,
linearRowFilter_caller<15, T, D, BrdRowReflect>,
linearRowFilter_caller<16, T, D, BrdRowReflect>
},
{
0,
linearRowFilter_caller<1 , T, D, BrdRowWrap>,
linearRowFilter_caller<2 , T, D, BrdRowWrap>,
linearRowFilter_caller<3 , T, D, BrdRowWrap>,
linearRowFilter_caller<4 , T, D, BrdRowWrap>,
linearRowFilter_caller<5 , T, D, BrdRowWrap>,
linearRowFilter_caller<6 , T, D, BrdRowWrap>,
linearRowFilter_caller<7 , T, D, BrdRowWrap>,
linearRowFilter_caller<8 , T, D, BrdRowWrap>,
linearRowFilter_caller<9 , T, D, BrdRowWrap>,
linearRowFilter_caller<10, T, D, BrdRowWrap>,
linearRowFilter_caller<11, T, D, BrdRowWrap>,
linearRowFilter_caller<12, T, D, BrdRowWrap>,
linearRowFilter_caller<13, T, D, BrdRowWrap>,
linearRowFilter_caller<14, T, D, BrdRowWrap>,
linearRowFilter_caller<15, T, D, BrdRowWrap>,
linearRowFilter_caller<16, T, D, BrdRowWrap>
} }
}; };
...@@ -292,7 +330,7 @@ namespace cv { namespace gpu { namespace filters ...@@ -292,7 +330,7 @@ namespace cv { namespace gpu { namespace filters
void linearColumnFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream) void linearColumnFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream)
{ {
typedef void (*caller_t)(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor, cudaStream_t stream); typedef void (*caller_t)(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor, cudaStream_t stream);
static const caller_t callers[3][17] = static const caller_t callers[5][17] =
{ {
{ {
0, 0,
...@@ -311,7 +349,7 @@ namespace cv { namespace gpu { namespace filters ...@@ -311,7 +349,7 @@ namespace cv { namespace gpu { namespace filters
linearColumnFilter_caller<13, T, D, BrdColReflect101>, linearColumnFilter_caller<13, T, D, BrdColReflect101>,
linearColumnFilter_caller<14, T, D, BrdColReflect101>, linearColumnFilter_caller<14, T, D, BrdColReflect101>,
linearColumnFilter_caller<15, T, D, BrdColReflect101>, linearColumnFilter_caller<15, T, D, BrdColReflect101>,
linearColumnFilter_caller<16, T, D, BrdColReflect101>, linearColumnFilter_caller<16, T, D, BrdColReflect101>
}, },
{ {
0, 0,
...@@ -330,7 +368,7 @@ namespace cv { namespace gpu { namespace filters ...@@ -330,7 +368,7 @@ namespace cv { namespace gpu { namespace filters
linearColumnFilter_caller<13, T, D, BrdColReplicate>, linearColumnFilter_caller<13, T, D, BrdColReplicate>,
linearColumnFilter_caller<14, T, D, BrdColReplicate>, linearColumnFilter_caller<14, T, D, BrdColReplicate>,
linearColumnFilter_caller<15, T, D, BrdColReplicate>, linearColumnFilter_caller<15, T, D, BrdColReplicate>,
linearColumnFilter_caller<16, T, D, BrdColReplicate>, linearColumnFilter_caller<16, T, D, BrdColReplicate>
}, },
{ {
0, 0,
...@@ -349,7 +387,45 @@ namespace cv { namespace gpu { namespace filters ...@@ -349,7 +387,45 @@ namespace cv { namespace gpu { namespace filters
linearColumnFilter_caller<13, T, D, BrdColConstant>, linearColumnFilter_caller<13, T, D, BrdColConstant>,
linearColumnFilter_caller<14, T, D, BrdColConstant>, linearColumnFilter_caller<14, T, D, BrdColConstant>,
linearColumnFilter_caller<15, T, D, BrdColConstant>, linearColumnFilter_caller<15, T, D, BrdColConstant>,
linearColumnFilter_caller<16, T, D, BrdColConstant>, linearColumnFilter_caller<16, T, D, BrdColConstant>
},
{
0,
linearColumnFilter_caller<1 , T, D, BrdColReflect>,
linearColumnFilter_caller<2 , T, D, BrdColReflect>,
linearColumnFilter_caller<3 , T, D, BrdColReflect>,
linearColumnFilter_caller<4 , T, D, BrdColReflect>,
linearColumnFilter_caller<5 , T, D, BrdColReflect>,
linearColumnFilter_caller<6 , T, D, BrdColReflect>,
linearColumnFilter_caller<7 , T, D, BrdColReflect>,
linearColumnFilter_caller<8 , T, D, BrdColReflect>,
linearColumnFilter_caller<9 , T, D, BrdColReflect>,
linearColumnFilter_caller<10, T, D, BrdColReflect>,
linearColumnFilter_caller<11, T, D, BrdColReflect>,
linearColumnFilter_caller<12, T, D, BrdColReflect>,
linearColumnFilter_caller<13, T, D, BrdColReflect>,
linearColumnFilter_caller<14, T, D, BrdColReflect>,
linearColumnFilter_caller<15, T, D, BrdColReflect>,
linearColumnFilter_caller<16, T, D, BrdColReflect>
},
{
0,
linearColumnFilter_caller<1 , T, D, BrdColWrap>,
linearColumnFilter_caller<2 , T, D, BrdColWrap>,
linearColumnFilter_caller<3 , T, D, BrdColWrap>,
linearColumnFilter_caller<4 , T, D, BrdColWrap>,
linearColumnFilter_caller<5 , T, D, BrdColWrap>,
linearColumnFilter_caller<6 , T, D, BrdColWrap>,
linearColumnFilter_caller<7 , T, D, BrdColWrap>,
linearColumnFilter_caller<8 , T, D, BrdColWrap>,
linearColumnFilter_caller<9 , T, D, BrdColWrap>,
linearColumnFilter_caller<10, T, D, BrdColWrap>,
linearColumnFilter_caller<11, T, D, BrdColWrap>,
linearColumnFilter_caller<12, T, D, BrdColWrap>,
linearColumnFilter_caller<13, T, D, BrdColWrap>,
linearColumnFilter_caller<14, T, D, BrdColWrap>,
linearColumnFilter_caller<15, T, D, BrdColWrap>,
linearColumnFilter_caller<16, T, D, BrdColWrap>,
} }
}; };
......
...@@ -120,10 +120,10 @@ namespace cv { namespace gpu { namespace imgproc ...@@ -120,10 +120,10 @@ namespace cv { namespace gpu { namespace imgproc
{ {
typedef void (*caller_t)(const DevMem2D_<T>& src, const DevMem2Df& xmap, const DevMem2Df& ymap, const DevMem2D_<T>& dst, T borderValue); typedef void (*caller_t)(const DevMem2D_<T>& src, const DevMem2Df& xmap, const DevMem2Df& ymap, const DevMem2D_<T>& dst, T borderValue);
static const caller_t callers[2][3] = static const caller_t callers[2][5] =
{ {
{ remap_caller<PointFilter, BrdReflect101>, remap_caller<PointFilter, BrdReplicate>, remap_caller<PointFilter, BrdConstant> }, { remap_caller<PointFilter, BrdReflect101>, remap_caller<PointFilter, BrdReplicate>, remap_caller<PointFilter, BrdConstant>, remap_caller<PointFilter, BrdReflect>, remap_caller<PointFilter, BrdWrap> },
{ remap_caller<LinearFilter, BrdReflect101>, remap_caller<LinearFilter, BrdReplicate>, remap_caller<LinearFilter, BrdConstant> } { remap_caller<LinearFilter, BrdReflect101>, remap_caller<LinearFilter, BrdReplicate>, remap_caller<LinearFilter, BrdConstant>, remap_caller<LinearFilter, BrdReflect>, remap_caller<LinearFilter, BrdWrap> }
}; };
typename VecTraits<T>::elem_type brd[] = {(typename VecTraits<T>::elem_type)borderValue[0], (typename VecTraits<T>::elem_type)borderValue[1], (typename VecTraits<T>::elem_type)borderValue[2], (typename VecTraits<T>::elem_type)borderValue[3]}; typename VecTraits<T>::elem_type brd[] = {(typename VecTraits<T>::elem_type)borderValue[0], (typename VecTraits<T>::elem_type)borderValue[1], (typename VecTraits<T>::elem_type)borderValue[2], (typename VecTraits<T>::elem_type)borderValue[3]};
...@@ -1089,7 +1089,7 @@ namespace cv { namespace gpu { namespace imgproc ...@@ -1089,7 +1089,7 @@ namespace cv { namespace gpu { namespace imgproc
static const caller_t callers[] = static const caller_t callers[] =
{ {
pyrDown_caller<type, BrdReflect101>, pyrDown_caller<type, BrdReplicate>, pyrDown_caller<type, BrdConstant> pyrDown_caller<type, BrdReflect101>, pyrDown_caller<type, BrdReplicate>, pyrDown_caller<type, BrdConstant>, pyrDown_caller<type, BrdReflect>, pyrDown_caller<type, BrdWrap>
}; };
callers[borderType](static_cast< DevMem2D_<type> >(src), static_cast< DevMem2D_<type> >(dst), stream); callers[borderType](static_cast< DevMem2D_<type> >(src), static_cast< DevMem2D_<type> >(dst), stream);
...@@ -1219,7 +1219,7 @@ namespace cv { namespace gpu { namespace imgproc ...@@ -1219,7 +1219,7 @@ namespace cv { namespace gpu { namespace imgproc
static const caller_t callers[] = static const caller_t callers[] =
{ {
pyrUp_caller<type, BrdReflect101>, pyrUp_caller<type, BrdReplicate>, pyrUp_caller<type, BrdConstant> pyrUp_caller<type, BrdReflect101>, pyrUp_caller<type, BrdReplicate>, pyrUp_caller<type, BrdConstant>, pyrUp_caller<type, BrdReflect>, pyrUp_caller<type, BrdWrap>
}; };
callers[borderType](static_cast< DevMem2D_<type> >(src), static_cast< DevMem2D_<type> >(dst), stream); callers[borderType](static_cast< DevMem2D_<type> >(src), static_cast< DevMem2D_<type> >(dst), stream);
......
...@@ -70,7 +70,9 @@ namespace cv ...@@ -70,7 +70,9 @@ namespace cv
{ {
BORDER_REFLECT101_GPU = 0, BORDER_REFLECT101_GPU = 0,
BORDER_REPLICATE_GPU, BORDER_REPLICATE_GPU,
BORDER_CONSTANT_GPU BORDER_CONSTANT_GPU,
BORDER_REFLECT_GPU,
BORDER_WRAP_GPU
}; };
// Converts CPU border extrapolation mode into GPU internal analogue. // Converts CPU border extrapolation mode into GPU internal analogue.
......
...@@ -718,7 +718,7 @@ Ptr<BaseRowFilter_GPU> cv::gpu::getLinearRowFilter_GPU(int srcType, int bufType, ...@@ -718,7 +718,7 @@ Ptr<BaseRowFilter_GPU> cv::gpu::getLinearRowFilter_GPU(int srcType, int bufType,
nppFilter1D_callers[CV_MAT_CN(srcType)])); nppFilter1D_callers[CV_MAT_CN(srcType)]));
} }
CV_Assert(borderType == BORDER_REFLECT101 || borderType == BORDER_REPLICATE || borderType == BORDER_CONSTANT); CV_Assert(borderType == BORDER_REFLECT101 || borderType == BORDER_REPLICATE || borderType == BORDER_CONSTANT || borderType == BORDER_REFLECT || borderType == BORDER_WRAP);
int gpuBorderType; int gpuBorderType;
CV_Assert(tryConvertToGpuBorderType(borderType, gpuBorderType)); CV_Assert(tryConvertToGpuBorderType(borderType, gpuBorderType));
...@@ -833,7 +833,7 @@ Ptr<BaseColumnFilter_GPU> cv::gpu::getLinearColumnFilter_GPU(int bufType, int ds ...@@ -833,7 +833,7 @@ Ptr<BaseColumnFilter_GPU> cv::gpu::getLinearColumnFilter_GPU(int bufType, int ds
nppFilter1D_callers[CV_MAT_CN(bufType)])); nppFilter1D_callers[CV_MAT_CN(bufType)]));
} }
CV_Assert(borderType == BORDER_REFLECT101 || borderType == BORDER_REPLICATE || borderType == BORDER_CONSTANT); CV_Assert(borderType == BORDER_REFLECT101 || borderType == BORDER_REPLICATE || borderType == BORDER_CONSTANT || borderType == BORDER_REFLECT || borderType == BORDER_WRAP);
int gpuBorderType; int gpuBorderType;
CV_Assert(tryConvertToGpuBorderType(borderType, gpuBorderType)); CV_Assert(tryConvertToGpuBorderType(borderType, gpuBorderType));
......
...@@ -133,7 +133,7 @@ void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const Gp ...@@ -133,7 +133,7 @@ void cv::gpu::remap(const GpuMat& src, GpuMat& dst, const GpuMat& xmap, const Gp
CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR); CV_Assert(interpolation == INTER_NEAREST || interpolation == INTER_LINEAR);
CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT); CV_Assert(borderMode == BORDER_REFLECT101 || borderMode == BORDER_REPLICATE || borderMode == BORDER_CONSTANT || borderMode == BORDER_REFLECT || borderMode == BORDER_WRAP);
int gpuBorderType; int gpuBorderType;
CV_Assert(tryConvertToGpuBorderType(borderMode, gpuBorderType)); CV_Assert(tryConvertToGpuBorderType(borderMode, gpuBorderType));
...@@ -1228,24 +1228,26 @@ namespace ...@@ -1228,24 +1228,26 @@ namespace
bool cv::gpu::tryConvertToGpuBorderType(int cpuBorderType, int& gpuBorderType) bool cv::gpu::tryConvertToGpuBorderType(int cpuBorderType, int& gpuBorderType)
{ {
if (cpuBorderType == cv::BORDER_REFLECT101) switch (cpuBorderType)
{ {
case cv::BORDER_REFLECT101:
gpuBorderType = cv::gpu::BORDER_REFLECT101_GPU; gpuBorderType = cv::gpu::BORDER_REFLECT101_GPU;
return true; return true;
} case cv::BORDER_REPLICATE:
if (cpuBorderType == cv::BORDER_REPLICATE)
{
gpuBorderType = cv::gpu::BORDER_REPLICATE_GPU; gpuBorderType = cv::gpu::BORDER_REPLICATE_GPU;
return true; return true;
} case cv::BORDER_CONSTANT:
if (cpuBorderType == cv::BORDER_CONSTANT)
{
gpuBorderType = cv::gpu::BORDER_CONSTANT_GPU; gpuBorderType = cv::gpu::BORDER_CONSTANT_GPU;
return true; return true;
} case cv::BORDER_REFLECT:
gpuBorderType = cv::gpu::BORDER_REFLECT_GPU;
return true;
case cv::BORDER_WRAP:
gpuBorderType = cv::gpu::BORDER_WRAP_GPU;
return true;
default:
return false;
};
return false; return false;
} }
...@@ -1647,7 +1649,7 @@ void cv::gpu::pyrDown(const GpuMat& src, GpuMat& dst, int borderType, Stream& st ...@@ -1647,7 +1649,7 @@ void cv::gpu::pyrDown(const GpuMat& src, GpuMat& dst, int borderType, Stream& st
CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); CV_Assert(src.depth() <= CV_32F && src.channels() <= 4);
CV_Assert(borderType == BORDER_REFLECT101 || borderType == BORDER_REPLICATE || borderType == BORDER_CONSTANT); CV_Assert(borderType == BORDER_REFLECT101 || borderType == BORDER_REPLICATE || borderType == BORDER_CONSTANT || borderType == BORDER_REFLECT || borderType == BORDER_WRAP);
int gpuBorderType; int gpuBorderType;
CV_Assert(tryConvertToGpuBorderType(borderType, gpuBorderType)); CV_Assert(tryConvertToGpuBorderType(borderType, gpuBorderType));
...@@ -1683,7 +1685,7 @@ void cv::gpu::pyrUp(const GpuMat& src, GpuMat& dst, int borderType, Stream& stre ...@@ -1683,7 +1685,7 @@ void cv::gpu::pyrUp(const GpuMat& src, GpuMat& dst, int borderType, Stream& stre
CV_Assert(src.depth() <= CV_32F && src.channels() <= 4); CV_Assert(src.depth() <= CV_32F && src.channels() <= 4);
CV_Assert(borderType == BORDER_REFLECT101 || borderType == BORDER_REPLICATE || borderType == BORDER_CONSTANT); CV_Assert(borderType == BORDER_REFLECT101 || borderType == BORDER_REPLICATE || borderType == BORDER_CONSTANT || borderType == BORDER_REFLECT || borderType == BORDER_WRAP);
int gpuBorderType; int gpuBorderType;
CV_Assert(tryConvertToGpuBorderType(borderType, gpuBorderType)); CV_Assert(tryConvertToGpuBorderType(borderType, gpuBorderType));
......
...@@ -192,7 +192,6 @@ struct Remap : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, ...@@ -192,7 +192,6 @@ struct Remap : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int,
cv::Mat src; cv::Mat src;
cv::Mat xmap; cv::Mat xmap;
cv::Mat ymap; cv::Mat ymap;
cv::Scalar borderValue;
cv::Mat dst_gold; cv::Mat dst_gold;
...@@ -221,17 +220,12 @@ struct Remap : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int, ...@@ -221,17 +220,12 @@ struct Remap : testing::TestWithParam< std::tr1::tuple<cv::gpu::DeviceInfo, int,
for (int x = 0; x < src.cols; ++x) for (int x = 0; x < src.cols; ++x)
{ {
xmap_row[x] = src.cols - 1 - x; xmap_row[x] = src.cols - 1 - x + 10;
ymap_row[x] = src.rows - 1 - y; ymap_row[x] = src.rows - 1 - y + 10;
} }
} }
borderValue[0] = rng.uniform(0.0, 256.0);
borderValue[1] = rng.uniform(0.0, 256.0);
borderValue[2] = rng.uniform(0.0, 256.0);
borderValue[3] = rng.uniform(0.0, 256.0);
cv::remap(src, dst_gold, xmap, ymap, interpolation, borderType, borderValue); cv::remap(src, dst_gold, xmap, ymap, interpolation, borderType);
} }
}; };
...@@ -248,18 +242,23 @@ TEST_P(Remap, Accuracy) ...@@ -248,18 +242,23 @@ TEST_P(Remap, Accuracy)
PRINT_PARAM(interpolationStr); PRINT_PARAM(interpolationStr);
PRINT_PARAM(borderTypeStr); PRINT_PARAM(borderTypeStr);
PRINT_PARAM(size); PRINT_PARAM(size);
PRINT_PARAM(borderValue);
cv::Mat dst; cv::Mat dst;
ASSERT_NO_THROW( ASSERT_NO_THROW(
cv::gpu::GpuMat gpuRes; cv::gpu::GpuMat gpuRes;
cv::gpu::remap(cv::gpu::GpuMat(src), gpuRes, cv::gpu::GpuMat(xmap), cv::gpu::GpuMat(ymap), interpolation, borderType, borderValue); cv::gpu::remap(cv::gpu::GpuMat(src), gpuRes, cv::gpu::GpuMat(xmap), cv::gpu::GpuMat(ymap), interpolation, borderType);
gpuRes.download(dst); gpuRes.download(dst);
); );
if (dst_gold.depth() == CV_32F)
{
dst_gold.convertTo(dst_gold, CV_8U);
dst.convertTo(dst, CV_8U);
}
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5); EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
} }
...@@ -274,7 +273,7 @@ INSTANTIATE_TEST_CASE_P ...@@ -274,7 +273,7 @@ INSTANTIATE_TEST_CASE_P
CV_32FC1, CV_32FC3, CV_32FC4 CV_32FC1, CV_32FC3, CV_32FC4
), ),
testing::Values(cv::INTER_NEAREST, cv::INTER_LINEAR), testing::Values(cv::INTER_NEAREST, cv::INTER_LINEAR),
testing::Values(cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT) testing::Values(cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
) )
); );
......
...@@ -411,15 +411,7 @@ namespace ...@@ -411,15 +411,7 @@ namespace
BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf, int num_matches_thresh1, int num_matches_thresh2) BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf, int num_matches_thresh1, int num_matches_thresh2)
{ {
bool use_gpu = false;
if (try_use_gpu && getCudaEnabledDeviceCount() > 0) if (try_use_gpu && getCudaEnabledDeviceCount() > 0)
{
DeviceInfo info;
if (info.majorVersion() >= 2 && cv::getNumberOfCPUs() < 4)
use_gpu = true;
}
if (use_gpu)
impl_ = new GpuMatcher(match_conf); impl_ = new GpuMatcher(match_conf);
else else
impl_ = new CpuMatcher(match_conf); impl_ = new CpuMatcher(match_conf);
......
...@@ -118,8 +118,14 @@ Point PlaneWarperGpu::warp(const Mat &src, float focal, const cv::Mat &R, cv::Ma ...@@ -118,8 +118,14 @@ Point PlaneWarperGpu::warp(const Mat &src, float focal, const cv::Mat &R, cv::Ma
gpu::buildWarpPlaneMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)), gpu::buildWarpPlaneMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)),
R, focal, projector_.scale, projector_.plane_dist, d_xmap_, d_ymap_); R, focal, projector_.scale, projector_.plane_dist, d_xmap_, d_ymap_);
dst.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, src.type()); gpu::ensureSizeIsEnough(src.size(), src.type(), d_src_);
remap(src, dst, Mat(d_xmap_), Mat(d_ymap_), interp_mode, border_mode); d_src_.upload(src);
gpu::ensureSizeIsEnough(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, src.type(), d_dst_);
gpu::remap(d_src_, d_dst_, d_xmap_, d_ymap_, interp_mode, border_mode);
d_dst_.download(dst);
return dst_tl; return dst_tl;
} }
...@@ -183,8 +189,14 @@ Point SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &d ...@@ -183,8 +189,14 @@ Point SphericalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat &d
gpu::buildWarpSphericalMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)), gpu::buildWarpSphericalMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)),
R, focal, projector_.scale, d_xmap_, d_ymap_); R, focal, projector_.scale, d_xmap_, d_ymap_);
dst.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, src.type()); gpu::ensureSizeIsEnough(src.size(), src.type(), d_src_);
remap(src, dst, Mat(d_xmap_), Mat(d_ymap_), interp_mode, border_mode); d_src_.upload(src);
gpu::ensureSizeIsEnough(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, src.type(), d_dst_);
gpu::remap(d_src_, d_dst_, d_xmap_, d_ymap_, interp_mode, border_mode);
d_dst_.download(dst);
return dst_tl; return dst_tl;
} }
...@@ -204,8 +216,14 @@ Point CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat ...@@ -204,8 +216,14 @@ Point CylindricalWarperGpu::warp(const Mat &src, float focal, const Mat &R, Mat
gpu::buildWarpCylindricalMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)), gpu::buildWarpCylindricalMaps(src.size(), Rect(dst_tl, Point(dst_br.x+1, dst_br.y+1)),
R, focal, projector_.scale, d_xmap_, d_ymap_); R, focal, projector_.scale, d_xmap_, d_ymap_);
dst.create(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, src.type()); gpu::ensureSizeIsEnough(src.size(), src.type(), d_src_);
remap(src, dst, Mat(d_xmap_), Mat(d_ymap_), interp_mode, border_mode); d_src_.upload(src);
gpu::ensureSizeIsEnough(dst_br.y - dst_tl.y + 1, dst_br.x - dst_tl.x + 1, src.type(), d_dst_);
gpu::remap(d_src_, d_dst_, d_xmap_, d_ymap_, interp_mode, border_mode);
d_dst_.download(dst);
return dst_tl; return dst_tl;
} }
...@@ -122,7 +122,7 @@ public: ...@@ -122,7 +122,7 @@ public:
int interp_mode, int border_mode); int interp_mode, int border_mode);
private: private:
cv::gpu::GpuMat d_xmap_, d_ymap_, d_dst_; cv::gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
}; };
...@@ -153,7 +153,7 @@ public: ...@@ -153,7 +153,7 @@ public:
int interp_mode, int border_mode); int interp_mode, int border_mode);
private: private:
cv::gpu::GpuMat d_xmap_, d_ymap_, d_dst_; cv::gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
}; };
...@@ -186,7 +186,7 @@ public: ...@@ -186,7 +186,7 @@ public:
int interp_mode, int border_mode); int interp_mode, int border_mode);
private: private:
cv::gpu::GpuMat d_xmap_, d_ymap_, d_dst_; cv::gpu::GpuMat d_xmap_, d_ymap_, d_dst_, d_src_;
}; };
#include "warpers_inl.hpp" #include "warpers_inl.hpp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment