Commit c865b282 authored by Andrey Kamaev's avatar Andrey Kamaev Committed by OpenCV Buildbot

Merge pull request #591 from jet47:gpu-sanity-tests

parents 79cf292d f533f0dc
...@@ -35,7 +35,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Merge, ...@@ -35,7 +35,7 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Merge,
TEST_CYCLE() cv::gpu::merge(d_src, dst); TEST_CYCLE() cv::gpu::merge(d_src, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -72,8 +72,8 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Split, ...@@ -72,8 +72,8 @@ PERF_TEST_P(Sz_Depth_Cn, Core_Split,
const cv::gpu::GpuMat& dst0 = dst[0]; const cv::gpu::GpuMat& dst0 = dst[0];
const cv::gpu::GpuMat& dst1 = dst[1]; const cv::gpu::GpuMat& dst1 = dst[1];
GPU_SANITY_CHECK(dst0); GPU_SANITY_CHECK(dst0, 1e-10);
GPU_SANITY_CHECK(dst1); GPU_SANITY_CHECK(dst1, 1e-10);
} }
else else
{ {
...@@ -113,7 +113,7 @@ PERF_TEST_P(Sz_Depth, Core_AddMat, ...@@ -113,7 +113,7 @@ PERF_TEST_P(Sz_Depth, Core_AddMat,
TEST_CYCLE() cv::gpu::add(d_src1, d_src2, dst); TEST_CYCLE() cv::gpu::add(d_src1, d_src2, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -148,7 +148,7 @@ PERF_TEST_P(Sz_Depth, Core_AddScalar, ...@@ -148,7 +148,7 @@ PERF_TEST_P(Sz_Depth, Core_AddScalar,
TEST_CYCLE() cv::gpu::add(d_src, s, dst); TEST_CYCLE() cv::gpu::add(d_src, s, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -184,7 +184,7 @@ PERF_TEST_P(Sz_Depth, Core_SubtractMat, ...@@ -184,7 +184,7 @@ PERF_TEST_P(Sz_Depth, Core_SubtractMat,
TEST_CYCLE() cv::gpu::subtract(d_src1, d_src2, dst); TEST_CYCLE() cv::gpu::subtract(d_src1, d_src2, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -219,7 +219,7 @@ PERF_TEST_P(Sz_Depth, Core_SubtractScalar, ...@@ -219,7 +219,7 @@ PERF_TEST_P(Sz_Depth, Core_SubtractScalar,
TEST_CYCLE() cv::gpu::subtract(d_src, s, dst); TEST_CYCLE() cv::gpu::subtract(d_src, s, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -255,7 +255,7 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyMat, ...@@ -255,7 +255,7 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyMat,
TEST_CYCLE() cv::gpu::multiply(d_src1, d_src2, dst); TEST_CYCLE() cv::gpu::multiply(d_src1, d_src2, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-6);
} }
else else
{ {
...@@ -290,7 +290,7 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyScalar, ...@@ -290,7 +290,7 @@ PERF_TEST_P(Sz_Depth, Core_MultiplyScalar,
TEST_CYCLE() cv::gpu::multiply(d_src, s, dst); TEST_CYCLE() cv::gpu::multiply(d_src, s, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-6);
} }
else else
{ {
...@@ -326,7 +326,7 @@ PERF_TEST_P(Sz_Depth, Core_DivideMat, ...@@ -326,7 +326,7 @@ PERF_TEST_P(Sz_Depth, Core_DivideMat,
TEST_CYCLE() cv::gpu::divide(d_src1, d_src2, dst); TEST_CYCLE() cv::gpu::divide(d_src1, d_src2, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-6);
} }
else else
{ {
...@@ -361,7 +361,7 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalar, ...@@ -361,7 +361,7 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalar,
TEST_CYCLE() cv::gpu::divide(d_src, s, dst); TEST_CYCLE() cv::gpu::divide(d_src, s, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-6);
} }
else else
{ {
...@@ -396,7 +396,7 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalarInv, ...@@ -396,7 +396,7 @@ PERF_TEST_P(Sz_Depth, Core_DivideScalarInv,
TEST_CYCLE() cv::gpu::divide(s[0], d_src, dst); TEST_CYCLE() cv::gpu::divide(s[0], d_src, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-6);
} }
else else
{ {
...@@ -432,7 +432,7 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffMat, ...@@ -432,7 +432,7 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffMat,
TEST_CYCLE() cv::gpu::absdiff(d_src1, d_src2, dst); TEST_CYCLE() cv::gpu::absdiff(d_src1, d_src2, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -467,7 +467,7 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar, ...@@ -467,7 +467,7 @@ PERF_TEST_P(Sz_Depth, Core_AbsDiffScalar,
TEST_CYCLE() cv::gpu::absdiff(d_src, s, dst); TEST_CYCLE() cv::gpu::absdiff(d_src, s, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -1247,7 +1247,7 @@ PERF_TEST_P(Sz_3Depth, Core_AddWeighted, ...@@ -1247,7 +1247,7 @@ PERF_TEST_P(Sz_3Depth, Core_AddWeighted,
TEST_CYCLE() cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, dst, dst_depth); TEST_CYCLE() cv::gpu::addWeighted(d_src1, 0.5, d_src2, 0.5, 10.0, dst, dst_depth);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -1296,7 +1296,7 @@ PERF_TEST_P(Sz_Type_Flags, Core_GEMM, ...@@ -1296,7 +1296,7 @@ PERF_TEST_P(Sz_Type_Flags, Core_GEMM,
TEST_CYCLE() cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, dst, flags); TEST_CYCLE() cv::gpu::gemm(d_src1, d_src2, 1.0, d_src3, 1.0, dst, flags);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-6);
} }
else else
{ {
...@@ -1330,7 +1330,7 @@ PERF_TEST_P(Sz_Type, Core_Transpose, ...@@ -1330,7 +1330,7 @@ PERF_TEST_P(Sz_Type, Core_Transpose,
TEST_CYCLE() cv::gpu::transpose(d_src, dst); TEST_CYCLE() cv::gpu::transpose(d_src, dst);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -1605,7 +1605,7 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_Phase, ...@@ -1605,7 +1605,7 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_Phase,
TEST_CYCLE() cv::gpu::phase(d_src1, d_src2, dst, angleInDegrees); TEST_CYCLE() cv::gpu::phase(d_src1, d_src2, dst, angleInDegrees);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
} }
else else
{ {
...@@ -1643,7 +1643,7 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar, ...@@ -1643,7 +1643,7 @@ PERF_TEST_P(Sz_AngleInDegrees, Core_CartToPolar,
TEST_CYCLE() cv::gpu::cartToPolar(d_src1, d_src2, magnitude, angle, angleInDegrees); TEST_CYCLE() cv::gpu::cartToPolar(d_src1, d_src2, magnitude, angle, angleInDegrees);
GPU_SANITY_CHECK(magnitude); GPU_SANITY_CHECK(magnitude);
GPU_SANITY_CHECK(angle); GPU_SANITY_CHECK(angle, 1e-6, ERROR_RELATIVE);
} }
else else
{ {
...@@ -1933,8 +1933,8 @@ PERF_TEST_P(Sz_Depth, Core_MinMax, ...@@ -1933,8 +1933,8 @@ PERF_TEST_P(Sz_Depth, Core_MinMax,
TEST_CYCLE() cv::gpu::minMax(d_src, &gpu_minVal, &gpu_maxVal, cv::gpu::GpuMat(), d_buf); TEST_CYCLE() cv::gpu::minMax(d_src, &gpu_minVal, &gpu_maxVal, cv::gpu::GpuMat(), d_buf);
SANITY_CHECK(gpu_minVal); SANITY_CHECK(gpu_minVal, 1e-10);
SANITY_CHECK(gpu_maxVal); SANITY_CHECK(gpu_maxVal, 1e-10);
} }
else else
{ {
...@@ -1969,8 +1969,8 @@ PERF_TEST_P(Sz_Depth, Core_MinMaxLoc, ...@@ -1969,8 +1969,8 @@ PERF_TEST_P(Sz_Depth, Core_MinMaxLoc,
TEST_CYCLE() cv::gpu::minMaxLoc(d_src, &gpu_minVal, &gpu_maxVal, &gpu_minLoc, &gpu_maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf); TEST_CYCLE() cv::gpu::minMaxLoc(d_src, &gpu_minVal, &gpu_maxVal, &gpu_minLoc, &gpu_maxLoc, cv::gpu::GpuMat(), d_valbuf, d_locbuf);
SANITY_CHECK(gpu_minVal); SANITY_CHECK(gpu_minVal, 1e-10);
SANITY_CHECK(gpu_maxVal); SANITY_CHECK(gpu_maxVal, 1e-10);
} }
else else
{ {
......
...@@ -86,7 +86,7 @@ PERF_TEST_P(Image, Features2D_SURF, ...@@ -86,7 +86,7 @@ PERF_TEST_P(Image, Features2D_SURF,
sortKeyPoints(gpu_keypoints, gpu_descriptors); sortKeyPoints(gpu_keypoints, gpu_descriptors);
SANITY_CHECK_KEYPOINTS(gpu_keypoints); SANITY_CHECK_KEYPOINTS(gpu_keypoints);
SANITY_CHECK(gpu_descriptors); SANITY_CHECK(gpu_descriptors, 1e-3);
} }
else else
{ {
......
...@@ -106,7 +106,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, ...@@ -106,7 +106,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize,
Combine(GPU_TYPICAL_MAT_SIZES, Combine(GPU_TYPICAL_MAT_SIZES,
Values(CV_8U, CV_16U, CV_32F), Values(CV_8U, CV_16U, CV_32F),
GPU_CHANNELS_1_3_4, GPU_CHANNELS_1_3_4,
ALL_INTERPOLATIONS, Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
Values(0.5, 0.3, 2.0))) Values(0.5, 0.3, 2.0)))
{ {
declare.time(20.0); declare.time(20.0);
...@@ -129,7 +129,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize, ...@@ -129,7 +129,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Scale, ImgProc_Resize,
TEST_CYCLE() cv::gpu::resize(d_src, dst, cv::Size(), f, f, interpolation); TEST_CYCLE() cv::gpu::resize(d_src, dst, cv::Size(), f, f, interpolation);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-3, ERROR_RELATIVE);
} }
else else
{ {
...@@ -224,7 +224,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine, ...@@ -224,7 +224,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpAffine,
TEST_CYCLE() cv::gpu::warpAffine(d_src, dst, M, size, interpolation, borderMode); TEST_CYCLE() cv::gpu::warpAffine(d_src, dst, M, size, interpolation, borderMode);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1);
} }
else else
{ {
...@@ -272,7 +272,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective, ...@@ -272,7 +272,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter_Border, ImgProc_WarpPerspective,
TEST_CYCLE() cv::gpu::warpPerspective(d_src, dst, M, size, interpolation, borderMode); TEST_CYCLE() cv::gpu::warpPerspective(d_src, dst, M, size, interpolation, borderMode);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1);
} }
else else
{ {
...@@ -351,7 +351,7 @@ PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold, ...@@ -351,7 +351,7 @@ PERF_TEST_P(Sz_Depth_Op, ImgProc_Threshold,
TEST_CYCLE() cv::gpu::threshold(d_src, dst, 100.0, 255.0, threshOp); TEST_CYCLE() cv::gpu::threshold(d_src, dst, 100.0, 255.0, threshOp);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -1199,7 +1199,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate, ...@@ -1199,7 +1199,7 @@ PERF_TEST_P(Sz_Depth_Cn_Inter, ImgProc_Rotate,
TEST_CYCLE() cv::gpu::rotate(d_src, dst, size, 30.0, 0, 0, interpolation); TEST_CYCLE() cv::gpu::rotate(d_src, dst, size, 30.0, 0, 0, interpolation);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-3, ERROR_RELATIVE);
} }
else else
{ {
...@@ -1425,7 +1425,7 @@ PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp, ...@@ -1425,7 +1425,7 @@ PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp,
TEST_CYCLE() cv::gpu::alphaComp(d_img1, d_img2, dst, alpha_op); TEST_CYCLE() cv::gpu::alphaComp(d_img1, d_img2, dst, alpha_op);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-3, ERROR_RELATIVE);
} }
else else
{ {
......
...@@ -98,7 +98,7 @@ struct GreedyLabeling ...@@ -98,7 +98,7 @@ struct GreedyLabeling
dot* stack; dot* stack;
}; };
PERF_TEST_P(Image, Labeling_ConnectivityMask, PERF_TEST_P(Image, DISABLED_Labeling_ConnectivityMask,
Values<string>("gpu/labeling/aloe-disp.png")) Values<string>("gpu/labeling/aloe-disp.png"))
{ {
declare.time(1.0); declare.time(1.0);
...@@ -121,7 +121,7 @@ PERF_TEST_P(Image, Labeling_ConnectivityMask, ...@@ -121,7 +121,7 @@ PERF_TEST_P(Image, Labeling_ConnectivityMask,
} }
} }
PERF_TEST_P(Image, Labeling_ConnectedComponents, PERF_TEST_P(Image, DISABLED_Labeling_ConnectedComponents,
Values<string>("gpu/labeling/aloe-disp.png")) Values<string>("gpu/labeling/aloe-disp.png"))
{ {
declare.time(1.0); declare.time(1.0);
......
...@@ -64,7 +64,7 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, ...@@ -64,7 +64,7 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked,
TEST_CYCLE() dst.setTo(val, d_mask); TEST_CYCLE() dst.setTo(val, d_mask);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -102,7 +102,7 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, ...@@ -102,7 +102,7 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked,
TEST_CYCLE() d_src.copyTo(dst, d_mask); TEST_CYCLE() d_src.copyTo(dst, d_mask);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
...@@ -141,7 +141,7 @@ PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, ...@@ -141,7 +141,7 @@ PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo,
TEST_CYCLE() d_src.convertTo(dst, depth2, a, b); TEST_CYCLE() d_src.convertTo(dst, depth2, a, b);
GPU_SANITY_CHECK(dst); GPU_SANITY_CHECK(dst, 1e-10);
} }
else else
{ {
......
...@@ -372,8 +372,8 @@ PERF_TEST_P(ImagePair, Video_OpticalFlowDual_TVL1, ...@@ -372,8 +372,8 @@ PERF_TEST_P(ImagePair, Video_OpticalFlowDual_TVL1,
TEST_CYCLE() d_alg(d_frame0, d_frame1, u, v); TEST_CYCLE() d_alg(d_frame0, d_frame1, u, v);
GPU_SANITY_CHECK(u); GPU_SANITY_CHECK(u, 1e-4);
GPU_SANITY_CHECK(v); GPU_SANITY_CHECK(v, 1e-4);
} }
else else
{ {
...@@ -470,8 +470,8 @@ PERF_TEST_P(ImagePair, Video_FastOpticalFlowBM, ...@@ -470,8 +470,8 @@ PERF_TEST_P(ImagePair, Video_FastOpticalFlowBM,
TEST_CYCLE() fastBM(d_frame0, d_frame1, u, v, max_range.width, block_size.width); TEST_CYCLE() fastBM(d_frame0, d_frame1, u, v, max_range.width, block_size.width);
GPU_SANITY_CHECK(u); GPU_SANITY_CHECK(u, 2);
GPU_SANITY_CHECK(v); GPU_SANITY_CHECK(v, 2);
} }
else else
{ {
...@@ -675,8 +675,10 @@ PERF_TEST_P(Video_Cn, Video_MOG2, ...@@ -675,8 +675,10 @@ PERF_TEST_P(Video_Cn, Video_MOG2,
if (PERF_RUN_GPU()) if (PERF_RUN_GPU())
{ {
cv::gpu::GpuMat d_frame(frame);
cv::gpu::MOG2_GPU d_mog2; cv::gpu::MOG2_GPU d_mog2;
d_mog2.bShadowDetection = false;
cv::gpu::GpuMat d_frame(frame);
cv::gpu::GpuMat foreground; cv::gpu::GpuMat foreground;
d_mog2(d_frame, foreground); d_mog2(d_frame, foreground);
...@@ -708,6 +710,8 @@ PERF_TEST_P(Video_Cn, Video_MOG2, ...@@ -708,6 +710,8 @@ PERF_TEST_P(Video_Cn, Video_MOG2,
else else
{ {
cv::BackgroundSubtractorMOG2 mog2; cv::BackgroundSubtractorMOG2 mog2;
mog2.set("detectShadows", false);
cv::Mat foreground; cv::Mat foreground;
mog2(frame, foreground); mog2(frame, foreground);
......
...@@ -648,7 +648,7 @@ namespace cv { namespace gpu { namespace device ...@@ -648,7 +648,7 @@ namespace cv { namespace gpu { namespace device
tWeight += gmm_weight(mode * frame.rows + y, x); tWeight += gmm_weight(mode * frame.rows + y, x);
if (tWeight > c_TB) if (tWeight > c_TB)
break; break;
}; }
} }
fgmask(y, x) = background ? 0 : isShadow ? c_shadowVal : 255; fgmask(y, x) = background ? 0 : isShadow ? c_shadowVal : 255;
......
...@@ -194,10 +194,10 @@ namespace cv { namespace gpu { namespace device ...@@ -194,10 +194,10 @@ namespace cv { namespace gpu { namespace device
if ( y > 0 && connected(intensity, image(y - 1, x))) if ( y > 0 && connected(intensity, image(y - 1, x)))
c |= UP; c |= UP;
if ( x - 1 < image.cols && connected(intensity, image(y, x + 1))) if ( x + 1 < image.cols && connected(intensity, image(y, x + 1)))
c |= RIGHT; c |= RIGHT;
if ( y - 1 < image.rows && connected(intensity, image(y + 1, x))) if ( y + 1 < image.rows && connected(intensity, image(y + 1, x)))
c |= DOWN; c |= DOWN;
components(y, x) = c; components(y, x) = c;
......
...@@ -207,11 +207,17 @@ INSTANTIATE_TEST_CASE_P(GPU_Video, MOG, testing::Combine( ...@@ -207,11 +207,17 @@ INSTANTIATE_TEST_CASE_P(GPU_Video, MOG, testing::Combine(
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
// MOG2 // MOG2
PARAM_TEST_CASE(MOG2, cv::gpu::DeviceInfo, std::string, UseGray, UseRoi) namespace
{
IMPLEMENT_PARAM_CLASS(DetectShadow, bool)
}
PARAM_TEST_CASE(MOG2, cv::gpu::DeviceInfo, std::string, UseGray, DetectShadow, UseRoi)
{ {
cv::gpu::DeviceInfo devInfo; cv::gpu::DeviceInfo devInfo;
std::string inputFile; std::string inputFile;
bool useGray; bool useGray;
bool detectShadow;
bool useRoi; bool useRoi;
virtual void SetUp() virtual void SetUp()
...@@ -220,10 +226,9 @@ PARAM_TEST_CASE(MOG2, cv::gpu::DeviceInfo, std::string, UseGray, UseRoi) ...@@ -220,10 +226,9 @@ PARAM_TEST_CASE(MOG2, cv::gpu::DeviceInfo, std::string, UseGray, UseRoi)
cv::gpu::setDevice(devInfo.deviceID()); cv::gpu::setDevice(devInfo.deviceID());
inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "video/" + GET_PARAM(1); inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "video/" + GET_PARAM(1);
useGray = GET_PARAM(2); useGray = GET_PARAM(2);
detectShadow = GET_PARAM(3);
useRoi = GET_PARAM(3); useRoi = GET_PARAM(4);
} }
}; };
...@@ -237,9 +242,11 @@ GPU_TEST_P(MOG2, Update) ...@@ -237,9 +242,11 @@ GPU_TEST_P(MOG2, Update)
ASSERT_FALSE(frame.empty()); ASSERT_FALSE(frame.empty());
cv::gpu::MOG2_GPU mog2; cv::gpu::MOG2_GPU mog2;
mog2.bShadowDetection = detectShadow;
cv::gpu::GpuMat foreground = createMat(frame.size(), CV_8UC1, useRoi); cv::gpu::GpuMat foreground = createMat(frame.size(), CV_8UC1, useRoi);
cv::BackgroundSubtractorMOG2 mog2_gold; cv::BackgroundSubtractorMOG2 mog2_gold;
mog2_gold.set("detectShadows", detectShadow);
cv::Mat foreground_gold; cv::Mat foreground_gold;
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
...@@ -258,11 +265,14 @@ GPU_TEST_P(MOG2, Update) ...@@ -258,11 +265,14 @@ GPU_TEST_P(MOG2, Update)
mog2_gold(frame, foreground_gold); mog2_gold(frame, foreground_gold);
double norm = cv::norm(foreground_gold, cv::Mat(foreground), cv::NORM_L1); if (detectShadow)
{
norm /= foreground_gold.size().area(); ASSERT_MAT_SIMILAR(foreground_gold, foreground, 1e-2);
}
ASSERT_LE(norm, 0.09); else
{
ASSERT_MAT_NEAR(foreground_gold, foreground, 0);
}
} }
} }
...@@ -277,9 +287,11 @@ GPU_TEST_P(MOG2, getBackgroundImage) ...@@ -277,9 +287,11 @@ GPU_TEST_P(MOG2, getBackgroundImage)
cv::Mat frame; cv::Mat frame;
cv::gpu::MOG2_GPU mog2; cv::gpu::MOG2_GPU mog2;
mog2.bShadowDetection = detectShadow;
cv::gpu::GpuMat foreground; cv::gpu::GpuMat foreground;
cv::BackgroundSubtractorMOG2 mog2_gold; cv::BackgroundSubtractorMOG2 mog2_gold;
mog2_gold.set("detectShadows", detectShadow);
cv::Mat foreground_gold; cv::Mat foreground_gold;
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
...@@ -305,6 +317,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Video, MOG2, testing::Combine( ...@@ -305,6 +317,7 @@ INSTANTIATE_TEST_CASE_P(GPU_Video, MOG2, testing::Combine(
ALL_DEVICES, ALL_DEVICES,
testing::Values(std::string("768x576.avi")), testing::Values(std::string("768x576.avi")),
testing::Values(UseGray(true), UseGray(false)), testing::Values(UseGray(true), UseGray(false)),
testing::Values(DetectShadow(true), DetectShadow(false)),
WHOLE_SUBMAT)); WHOLE_SUBMAT));
////////////////////////////////////////////////////// //////////////////////////////////////////////////////
......
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