fixed perf tests for bgfg segmentation

pull/1885/head
Vladislav Vinogradov 11 years ago
parent d5ead208b7
commit 7c43daccba
  1. 248
      modules/gpu/perf/perf_video.cpp

@ -544,6 +544,8 @@ DEF_PARAM_TEST_1(Video, string);
PERF_TEST_P(Video, Video_FGDStatModel, PERF_TEST_P(Video, Video_FGDStatModel,
Values(string("gpu/video/768x576.avi"))) Values(string("gpu/video/768x576.avi")))
{ {
const int numIters = 10;
declare.time(60); declare.time(60);
const string inputFile = perf::TestBase::getDataPath(GetParam()); const string inputFile = perf::TestBase::getDataPath(GetParam());
@ -562,18 +564,36 @@ PERF_TEST_P(Video, Video_FGDStatModel,
cv::gpu::FGDStatModel d_model(4); cv::gpu::FGDStatModel d_model(4);
d_model.create(d_frame); d_model.create(d_frame);
for (int i = 0; i < 10; ++i) int i = 0;
// collect performance data
for (; i < numIters; ++i)
{ {
cap >> frame; cap >> frame;
ASSERT_FALSE(frame.empty()); ASSERT_FALSE(frame.empty());
d_frame.upload(frame); d_frame.upload(frame);
startTimer(); next(); startTimer();
if(!next())
break;
d_model.update(d_frame); d_model.update(d_frame);
stopTimer(); stopTimer();
} }
// process last frame in sequence to get data for sanity test
for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
d_frame.upload(frame);
d_model.update(d_frame);
}
const cv::gpu::GpuMat background = d_model.background; const cv::gpu::GpuMat background = d_model.background;
const cv::gpu::GpuMat foreground = d_model.foreground; const cv::gpu::GpuMat foreground = d_model.foreground;
@ -585,18 +605,36 @@ PERF_TEST_P(Video, Video_FGDStatModel,
IplImage ipl_frame = frame; IplImage ipl_frame = frame;
cv::Ptr<CvBGStatModel> model(cvCreateFGDStatModel(&ipl_frame)); cv::Ptr<CvBGStatModel> model(cvCreateFGDStatModel(&ipl_frame));
for (int i = 0; i < 10; ++i) int i = 0;
// collect performance data
for (; i < numIters; ++i)
{ {
cap >> frame; cap >> frame;
ASSERT_FALSE(frame.empty()); ASSERT_FALSE(frame.empty());
ipl_frame = frame; ipl_frame = frame;
startTimer(); next(); startTimer();
if(!next())
break;
cvUpdateBGStatModel(&ipl_frame, model); cvUpdateBGStatModel(&ipl_frame, model);
stopTimer(); stopTimer();
} }
// process last frame in sequence to get data for sanity test
for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
ipl_frame = frame;
cvUpdateBGStatModel(&ipl_frame, model);
}
const cv::Mat background = model->background; const cv::Mat background = model->background;
const cv::Mat foreground = model->foreground; const cv::Mat foreground = model->foreground;
@ -619,6 +657,8 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG,
GPU_CHANNELS_1_3_4, GPU_CHANNELS_1_3_4,
Values(0.0, 0.01))) Values(0.0, 0.01)))
{ {
const int numIters = 10;
const string inputFile = perf::TestBase::getDataPath(GET_PARAM(0)); const string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
const int cn = GET_PARAM(1); const int cn = GET_PARAM(1);
const float learningRate = static_cast<float>(GET_PARAM(2)); const float learningRate = static_cast<float>(GET_PARAM(2));
@ -649,7 +689,10 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG,
d_mog(d_frame, foreground, learningRate); d_mog(d_frame, foreground, learningRate);
for (int i = 0; i < 10; ++i) int i = 0;
// collect performance data
for (; i < numIters; ++i)
{ {
cap >> frame; cap >> frame;
ASSERT_FALSE(frame.empty()); ASSERT_FALSE(frame.empty());
@ -666,11 +709,36 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG,
d_frame.upload(frame); d_frame.upload(frame);
startTimer(); next(); startTimer();
if(!next())
break;
d_mog(d_frame, foreground, learningRate); d_mog(d_frame, foreground, learningRate);
stopTimer(); stopTimer();
} }
// process last frame in sequence to get data for sanity test
for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
d_mog(d_frame, foreground, learningRate);
}
GPU_SANITY_CHECK(foreground); GPU_SANITY_CHECK(foreground);
} }
else else
@ -680,7 +748,10 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG,
mog(frame, foreground, learningRate); mog(frame, foreground, learningRate);
for (int i = 0; i < 10; ++i) int i = 0;
// collect performance data
for (; i < numIters; ++i)
{ {
cap >> frame; cap >> frame;
ASSERT_FALSE(frame.empty()); ASSERT_FALSE(frame.empty());
@ -695,11 +766,34 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG,
cv::swap(temp, frame); cv::swap(temp, frame);
} }
startTimer(); next(); startTimer();
if(!next())
break;
mog(frame, foreground, learningRate); mog(frame, foreground, learningRate);
stopTimer(); stopTimer();
} }
// process last frame in sequence to get data for sanity test
for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
mog(frame, foreground, learningRate);
}
CPU_SANITY_CHECK(foreground); CPU_SANITY_CHECK(foreground);
} }
} }
@ -717,6 +811,8 @@ PERF_TEST_P(Video_Cn, Video_MOG2,
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
GPU_CHANNELS_1_3_4)) GPU_CHANNELS_1_3_4))
{ {
const int numIters = 10;
const string inputFile = perf::TestBase::getDataPath(GET_PARAM(0)); const string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
const int cn = GET_PARAM(1); const int cn = GET_PARAM(1);
@ -748,7 +844,10 @@ PERF_TEST_P(Video_Cn, Video_MOG2,
d_mog2(d_frame, foreground); d_mog2(d_frame, foreground);
for (int i = 0; i < 10; ++i) int i = 0;
// collect performance data
for (; i < numIters; ++i)
{ {
cap >> frame; cap >> frame;
ASSERT_FALSE(frame.empty()); ASSERT_FALSE(frame.empty());
@ -765,11 +864,36 @@ PERF_TEST_P(Video_Cn, Video_MOG2,
d_frame.upload(frame); d_frame.upload(frame);
startTimer(); next(); startTimer();
if(!next())
break;
d_mog2(d_frame, foreground); d_mog2(d_frame, foreground);
stopTimer(); stopTimer();
} }
// process last frame in sequence to get data for sanity test
for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
d_mog2(d_frame, foreground);
}
GPU_SANITY_CHECK(foreground); GPU_SANITY_CHECK(foreground);
} }
else else
@ -781,7 +905,10 @@ PERF_TEST_P(Video_Cn, Video_MOG2,
mog2(frame, foreground); mog2(frame, foreground);
for (int i = 0; i < 10; ++i) int i = 0;
// collect performance data
for (; i < numIters; ++i)
{ {
cap >> frame; cap >> frame;
ASSERT_FALSE(frame.empty()); ASSERT_FALSE(frame.empty());
@ -796,11 +923,34 @@ PERF_TEST_P(Video_Cn, Video_MOG2,
cv::swap(temp, frame); cv::swap(temp, frame);
} }
startTimer(); next(); startTimer();
if(!next())
break;
mog2(frame, foreground); mog2(frame, foreground);
stopTimer(); stopTimer();
} }
// process last frame in sequence to get data for sanity test
for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
mog2(frame, foreground);
}
CPU_SANITY_CHECK(foreground); CPU_SANITY_CHECK(foreground);
} }
} }
@ -901,6 +1051,8 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG,
GPU_CHANNELS_1_3_4, GPU_CHANNELS_1_3_4,
Values(20, 40, 60))) Values(20, 40, 60)))
{ {
const int numIters = 150;
const std::string inputFile = perf::TestBase::getDataPath(GET_PARAM(0)); const std::string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
const int cn = GET_PARAM(1); const int cn = GET_PARAM(1);
const int maxFeatures = GET_PARAM(2); const int maxFeatures = GET_PARAM(2);
@ -932,7 +1084,10 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG,
d_gmg(d_frame, foreground); d_gmg(d_frame, foreground);
for (int i = 0; i < 150; ++i) int i = 0;
// collect performance data
for (; i < numIters; ++i)
{ {
cap >> frame; cap >> frame;
if (frame.empty()) if (frame.empty())
@ -954,11 +1109,41 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG,
d_frame.upload(frame); d_frame.upload(frame);
startTimer(); next(); startTimer();
if(!next())
break;
d_gmg(d_frame, foreground); d_gmg(d_frame, foreground);
stopTimer(); stopTimer();
} }
// process last frame in sequence to get data for sanity test
for (; i < numIters; ++i)
{
cap >> frame;
if (frame.empty())
{
cap.release();
cap.open(inputFile);
cap >> frame;
}
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
d_gmg(d_frame, foreground);
}
GPU_SANITY_CHECK(foreground); GPU_SANITY_CHECK(foreground);
} }
else else
@ -972,7 +1157,10 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG,
gmg(frame, foreground); gmg(frame, foreground);
for (int i = 0; i < 150; ++i) int i = 0;
// collect performance data
for (; i < numIters; ++i)
{ {
cap >> frame; cap >> frame;
if (frame.empty()) if (frame.empty())
@ -992,11 +1180,39 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG,
cv::swap(temp, frame); cv::swap(temp, frame);
} }
startTimer(); next(); startTimer();
if(!next())
break;
gmg(frame, foreground); gmg(frame, foreground);
stopTimer(); stopTimer();
} }
// process last frame in sequence to get data for sanity test
for (; i < numIters; ++i)
{
cap >> frame;
if (frame.empty())
{
cap.release();
cap.open(inputFile);
cap >> frame;
}
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
gmg(frame, foreground);
}
CPU_SANITY_CHECK(foreground); CPU_SANITY_CHECK(foreground);
} }
} }

Loading…
Cancel
Save