PERF_TEST_P(Video, Video_FGDStatModel,
Values(string("gpu/video/768x576.avi")))
{
+ const int numIters = 10;
+
declare.time(60);
const string inputFile = perf::TestBase::getDataPath(GetParam());
cv::gpu::FGDStatModel d_model(4);
d_model.create(d_frame);
- for (int i = 0; i < 10; ++i)
+ int i = 0;
+
+ // collect performance data
+ for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
d_frame.upload(frame);
- startTimer(); next();
+ startTimer();
+ if(!next())
+ break;
+
d_model.update(d_frame);
+
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 foreground = d_model.foreground;
IplImage ipl_frame = 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;
ASSERT_FALSE(frame.empty());
ipl_frame = frame;
- startTimer(); next();
+ startTimer();
+ if(!next())
+ break;
+
cvUpdateBGStatModel(&ipl_frame, model);
+
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 foreground = model->foreground;
GPU_CHANNELS_1_3_4,
Values(0.0, 0.01)))
{
+ const int numIters = 10;
+
const string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
const int cn = GET_PARAM(1);
const float learningRate = static_cast<float>(GET_PARAM(2));
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;
ASSERT_FALSE(frame.empty());
d_frame.upload(frame);
- startTimer(); next();
+ startTimer();
+ if(!next())
+ break;
+
d_mog(d_frame, foreground, learningRate);
+
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);
}
else
mog(frame, foreground, learningRate);
- for (int i = 0; i < 10; ++i)
+ int i = 0;
+
+ // collect performance data
+ for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
cv::swap(temp, frame);
}
- startTimer(); next();
+ startTimer();
+ if(!next())
+ break;
+
mog(frame, foreground, learningRate);
+
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);
}
}
Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
GPU_CHANNELS_1_3_4))
{
+ const int numIters = 10;
+
const string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
const int cn = GET_PARAM(1);
d_mog2(d_frame, foreground);
- for (int i = 0; i < 10; ++i)
+ int i = 0;
+
+ // collect performance data
+ for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
d_frame.upload(frame);
- startTimer(); next();
+ startTimer();
+ if(!next())
+ break;
+
d_mog2(d_frame, foreground);
+
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);
}
else
mog2(frame, foreground);
- for (int i = 0; i < 10; ++i)
+ int i = 0;
+
+ // collect performance data
+ for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
cv::swap(temp, frame);
}
- startTimer(); next();
+ startTimer();
+ if(!next())
+ break;
+
mog2(frame, foreground);
+
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);
}
}
GPU_CHANNELS_1_3_4,
Values(20, 40, 60)))
{
+ const int numIters = 150;
+
const std::string inputFile = perf::TestBase::getDataPath(GET_PARAM(0));
const int cn = GET_PARAM(1);
const int maxFeatures = GET_PARAM(2);
d_gmg(d_frame, foreground);
- for (int i = 0; i < 150; ++i)
+ int i = 0;
+
+ // collect performance data
+ for (; i < numIters; ++i)
{
cap >> frame;
if (frame.empty())
d_frame.upload(frame);
- startTimer(); next();
+ startTimer();
+ if(!next())
+ break;
+
d_gmg(d_frame, foreground);
+
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);
}
else
gmg(frame, foreground);
- for (int i = 0; i < 150; ++i)
+ int i = 0;
+
+ // collect performance data
+ for (; i < numIters; ++i)
{
cap >> frame;
if (frame.empty())
cv::swap(temp, frame);
}
- startTimer(); next();
+ startTimer();
+ if(!next())
+ break;
+
gmg(frame, foreground);
+
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);
}
}