|
|
|
@ -624,6 +624,9 @@ TEST_P(MOG2, Update) |
|
|
|
|
|
|
|
|
|
TEST_P(MOG2, getBackgroundImage) |
|
|
|
|
{ |
|
|
|
|
if (useGray) |
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
cv::VideoCapture cap(inputFile); |
|
|
|
|
ASSERT_TRUE(cap.isOpened()); |
|
|
|
|
|
|
|
|
@ -640,13 +643,6 @@ TEST_P(MOG2, getBackgroundImage) |
|
|
|
|
cap >> frame; |
|
|
|
|
ASSERT_FALSE(frame.empty()); |
|
|
|
|
|
|
|
|
|
// if (useGray)
|
|
|
|
|
// {
|
|
|
|
|
// cv::Mat temp;
|
|
|
|
|
// cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
|
|
|
|
|
// cv::swap(temp, frame);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
mog2(loadMat(frame, useRoi), foreground); |
|
|
|
|
|
|
|
|
|
mog2_gold(frame, foreground_gold); |
|
|
|
@ -667,6 +663,101 @@ INSTANTIATE_TEST_CASE_P(GPU_Video, MOG2, testing::Combine( |
|
|
|
|
testing::Values(UseGray(true), UseGray(false)), |
|
|
|
|
WHOLE_SUBMAT)); |
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
|
// VIBE
|
|
|
|
|
|
|
|
|
|
PARAM_TEST_CASE(VIBE, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi) |
|
|
|
|
{ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST_P(VIBE, Accuracy) |
|
|
|
|
{ |
|
|
|
|
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0); |
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID()); |
|
|
|
|
const cv::Size size = GET_PARAM(1); |
|
|
|
|
const int type = GET_PARAM(2); |
|
|
|
|
const bool useRoi = GET_PARAM(3); |
|
|
|
|
|
|
|
|
|
const cv::Mat fullfg(size, CV_8UC1, cv::Scalar::all(255)); |
|
|
|
|
|
|
|
|
|
cv::Mat frame = randomMat(size, type, 0.0, 100); |
|
|
|
|
cv::gpu::GpuMat d_frame = loadMat(frame, useRoi); |
|
|
|
|
|
|
|
|
|
cv::gpu::VIBE_GPU vibe; |
|
|
|
|
cv::gpu::GpuMat d_fgmask = createMat(size, CV_8UC1, useRoi); |
|
|
|
|
vibe.initialize(d_frame); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 20; ++i) |
|
|
|
|
vibe(d_frame, d_fgmask); |
|
|
|
|
|
|
|
|
|
frame = randomMat(size, type, 160, 255); |
|
|
|
|
d_frame = loadMat(frame, useRoi); |
|
|
|
|
vibe(d_frame, d_fgmask); |
|
|
|
|
|
|
|
|
|
// now fgmask should be entirely foreground
|
|
|
|
|
ASSERT_MAT_NEAR(fullfg, d_fgmask, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(GPU_Video, VIBE, testing::Combine( |
|
|
|
|
ALL_DEVICES, |
|
|
|
|
DIFFERENT_SIZES, |
|
|
|
|
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4)), |
|
|
|
|
WHOLE_SUBMAT)); |
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
|
// GMG
|
|
|
|
|
|
|
|
|
|
PARAM_TEST_CASE(GMG, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels, UseRoi) |
|
|
|
|
{ |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
TEST_P(GMG, Accuracy) |
|
|
|
|
{ |
|
|
|
|
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0); |
|
|
|
|
cv::gpu::setDevice(devInfo.deviceID()); |
|
|
|
|
const cv::Size size = GET_PARAM(1); |
|
|
|
|
const int depth = GET_PARAM(2); |
|
|
|
|
const int channels = GET_PARAM(3); |
|
|
|
|
const bool useRoi = GET_PARAM(4); |
|
|
|
|
|
|
|
|
|
const int type = CV_MAKE_TYPE(depth, channels); |
|
|
|
|
|
|
|
|
|
const cv::Mat zeros(size, CV_8UC1, cv::Scalar::all(0)); |
|
|
|
|
const cv::Mat fullfg(size, CV_8UC1, cv::Scalar::all(255)); |
|
|
|
|
|
|
|
|
|
cv::Mat frame = randomMat(size, type, 0, 100); |
|
|
|
|
cv::gpu::GpuMat d_frame = loadMat(frame, useRoi); |
|
|
|
|
|
|
|
|
|
cv::gpu::GMG_GPU gmg; |
|
|
|
|
gmg.numInitializationFrames = 5; |
|
|
|
|
gmg.smoothingRadius = 0; |
|
|
|
|
gmg.initialize(d_frame.size(), 0, 255); |
|
|
|
|
|
|
|
|
|
cv::gpu::GpuMat d_fgmask = createMat(size, CV_8UC1, useRoi); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < gmg.numInitializationFrames; ++i) |
|
|
|
|
{ |
|
|
|
|
gmg(d_frame, d_fgmask); |
|
|
|
|
|
|
|
|
|
// fgmask should be entirely background during training
|
|
|
|
|
ASSERT_MAT_NEAR(zeros, d_fgmask, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
frame = randomMat(size, type, 160, 255); |
|
|
|
|
d_frame = loadMat(frame, useRoi); |
|
|
|
|
gmg(d_frame, d_fgmask); |
|
|
|
|
|
|
|
|
|
// now fgmask should be entirely foreground
|
|
|
|
|
ASSERT_MAT_NEAR(fullfg, d_fgmask, 0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(GPU_Video, GMG, testing::Combine( |
|
|
|
|
ALL_DEVICES, |
|
|
|
|
DIFFERENT_SIZES, |
|
|
|
|
testing::Values(MatType(CV_8U), MatType(CV_16U), MatType(CV_32F)), |
|
|
|
|
testing::Values(Channels(1), Channels(3), Channels(4)), |
|
|
|
|
WHOLE_SUBMAT)); |
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
|
// VideoWriter
|
|
|
|
|
|
|
|
|
|