merged gpu_perf_cpu into gpu_perf
This commit is contained in:
@@ -3,6 +3,14 @@
|
||||
using namespace std;
|
||||
using namespace testing;
|
||||
|
||||
namespace cv
|
||||
{
|
||||
template<> void Ptr<CvBGStatModel>::delete_obj()
|
||||
{
|
||||
cvReleaseBGStatModel(&obj);
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
@@ -25,19 +33,26 @@ PERF_TEST_P(ImagePair, Video_BroxOpticalFlow, Values<pair_string>(make_pair("gpu
|
||||
frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
|
||||
frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
|
||||
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_u;
|
||||
cv::gpu::GpuMat d_v;
|
||||
|
||||
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
|
||||
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
|
||||
|
||||
d_flow(d_frame0, d_frame1, d_u, d_v);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_u;
|
||||
cv::gpu::GpuMat d_v;
|
||||
|
||||
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
|
||||
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
|
||||
|
||||
d_flow(d_frame0, d_frame1, d_u, d_v);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_flow(d_frame0, d_frame1, d_u, d_v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,25 +70,32 @@ PERF_TEST_P(ImagePair, Video_InterpolateFrames, Values<pair_string>(make_pair("g
|
||||
frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
|
||||
frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
|
||||
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_fu, d_fv;
|
||||
cv::gpu::GpuMat d_bu, d_bv;
|
||||
|
||||
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
|
||||
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
|
||||
|
||||
d_flow(d_frame0, d_frame1, d_fu, d_fv);
|
||||
d_flow(d_frame1, d_frame0, d_bu, d_bv);
|
||||
|
||||
cv::gpu::GpuMat d_newFrame;
|
||||
cv::gpu::GpuMat d_buf;
|
||||
|
||||
cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_fu, d_fv;
|
||||
cv::gpu::GpuMat d_bu, d_bv;
|
||||
|
||||
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
|
||||
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
|
||||
|
||||
d_flow(d_frame0, d_frame1, d_fu, d_fv);
|
||||
d_flow(d_frame1, d_frame0, d_bu, d_bv);
|
||||
|
||||
cv::gpu::GpuMat d_newFrame;
|
||||
cv::gpu::GpuMat d_buf;
|
||||
|
||||
cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,23 +113,30 @@ PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap, Values<pair_string>(mak
|
||||
frame0.convertTo(frame0, CV_32FC1, 1.0 / 255.0);
|
||||
frame1.convertTo(frame1, CV_32FC1, 1.0 / 255.0);
|
||||
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_u;
|
||||
cv::gpu::GpuMat d_v;
|
||||
|
||||
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
|
||||
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
|
||||
|
||||
d_flow(d_frame0, d_frame1, d_u, d_v);
|
||||
|
||||
cv::gpu::GpuMat d_vertex, d_colors;
|
||||
|
||||
cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_u;
|
||||
cv::gpu::GpuMat d_v;
|
||||
|
||||
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
|
||||
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
|
||||
|
||||
d_flow(d_frame0, d_frame1, d_u, d_v);
|
||||
|
||||
cv::gpu::GpuMat d_vertex, d_colors;
|
||||
|
||||
cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,16 +153,30 @@ PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack, Combine(Values<string>
|
||||
cv::Mat image = readImage(fileName, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance);
|
||||
|
||||
cv::gpu::GpuMat d_image(image);
|
||||
cv::gpu::GpuMat d_pts;
|
||||
|
||||
d_detector(d_image, d_pts);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance);
|
||||
|
||||
cv::gpu::GpuMat d_image(image);
|
||||
cv::gpu::GpuMat d_pts;
|
||||
|
||||
d_detector(d_image, d_pts);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_detector(d_image, d_pts);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat pts;
|
||||
|
||||
cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::goodFeaturesToTrack(image, pts, 8000, 0.01, minDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +193,8 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse
|
||||
Values(1, 2, 3),
|
||||
Values(1, 10, 30)))
|
||||
{
|
||||
declare.time(20.0);
|
||||
|
||||
pair_string imagePair = GET_PARAM(0);
|
||||
bool useGray = GET_PARAM(1);
|
||||
int points = GET_PARAM(2);
|
||||
@@ -169,26 +214,45 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse
|
||||
else
|
||||
cv::cvtColor(frame0, gray_frame, cv::COLOR_BGR2GRAY);
|
||||
|
||||
cv::gpu::GpuMat d_pts;
|
||||
cv::Mat pts;
|
||||
cv::goodFeaturesToTrack(gray_frame, pts, points, 0.01, 0.0);
|
||||
|
||||
cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(points, 0.01, 0.0);
|
||||
d_detector(cv::gpu::GpuMat(gray_frame), d_pts);
|
||||
|
||||
cv::gpu::PyrLKOpticalFlow d_pyrLK;
|
||||
d_pyrLK.winSize = cv::Size(winSize, winSize);
|
||||
d_pyrLK.maxLevel = levels - 1;
|
||||
d_pyrLK.iters = iters;
|
||||
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_nextPts;
|
||||
cv::gpu::GpuMat d_status;
|
||||
|
||||
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_pts(pts);
|
||||
|
||||
cv::gpu::PyrLKOpticalFlow d_pyrLK;
|
||||
d_pyrLK.winSize = cv::Size(winSize, winSize);
|
||||
d_pyrLK.maxLevel = levels - 1;
|
||||
d_pyrLK.iters = iters;
|
||||
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_nextPts;
|
||||
cv::gpu::GpuMat d_status;
|
||||
|
||||
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat nextPts;
|
||||
cv::Mat status;
|
||||
|
||||
cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(),
|
||||
cv::Size(winSize, winSize), levels - 1,
|
||||
cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(),
|
||||
cv::Size(winSize, winSize), levels - 1,
|
||||
cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,21 +280,28 @@ PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine(
|
||||
cv::Mat frame1 = readImage(imagePair.second, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(frame1.empty());
|
||||
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_u;
|
||||
cv::gpu::GpuMat d_v;
|
||||
|
||||
cv::gpu::PyrLKOpticalFlow d_pyrLK;
|
||||
d_pyrLK.winSize = cv::Size(winSize, winSize);
|
||||
d_pyrLK.maxLevel = levels - 1;
|
||||
d_pyrLK.iters = iters;
|
||||
|
||||
d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_u;
|
||||
cv::gpu::GpuMat d_v;
|
||||
|
||||
cv::gpu::PyrLKOpticalFlow d_pyrLK;
|
||||
d_pyrLK.winSize = cv::Size(winSize, winSize);
|
||||
d_pyrLK.maxLevel = levels - 1;
|
||||
d_pyrLK.iters = iters;
|
||||
|
||||
d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,18 +318,47 @@ PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow, Values<pair_string>(make_pair
|
||||
cv::Mat frame1 = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(frame1.empty());
|
||||
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_u;
|
||||
cv::gpu::GpuMat d_v;
|
||||
int numLevels = 5;
|
||||
double pyrScale = 0.5;
|
||||
int winSize = 13;
|
||||
int numIters = 10;
|
||||
int polyN = 5;
|
||||
double polySigma = 1.1;
|
||||
int flags = 0;
|
||||
|
||||
cv::gpu::FarnebackOpticalFlow d_farneback;
|
||||
|
||||
d_farneback(d_frame0, d_frame1, d_u, d_v);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_frame0(frame0);
|
||||
cv::gpu::GpuMat d_frame1(frame1);
|
||||
cv::gpu::GpuMat d_u;
|
||||
cv::gpu::GpuMat d_v;
|
||||
|
||||
cv::gpu::FarnebackOpticalFlow d_farneback;
|
||||
d_farneback.numLevels = numLevels;
|
||||
d_farneback.pyrScale = pyrScale;
|
||||
d_farneback.winSize = winSize;
|
||||
d_farneback.numIters = numIters;
|
||||
d_farneback.polyN = polyN;
|
||||
d_farneback.polySigma = polySigma;
|
||||
d_farneback.flags = flags;
|
||||
|
||||
d_farneback(d_frame0, d_frame1, d_u, d_v);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_farneback(d_frame0, d_frame1, d_u, d_v);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat flow;
|
||||
|
||||
cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +369,7 @@ DEF_PARAM_TEST_1(Video, string);
|
||||
|
||||
PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
|
||||
{
|
||||
declare.time(10);
|
||||
declare.time(60);
|
||||
|
||||
string inputFile = perf::TestBase::getDataPath(GetParam());
|
||||
|
||||
@@ -280,20 +380,41 @@ PERF_TEST_P(Video, Video_FGDStatModel, Values("gpu/video/768x576.avi", "gpu/vide
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
cv::gpu::GpuMat d_frame(frame);
|
||||
cv::gpu::FGDStatModel d_model(4);
|
||||
d_model.create(d_frame);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (runOnGpu)
|
||||
{
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
cv::gpu::GpuMat d_frame(frame);
|
||||
|
||||
d_frame.upload(frame);
|
||||
cv::gpu::FGDStatModel d_model(4);
|
||||
d_model.create(d_frame);
|
||||
|
||||
startTimer(); next();
|
||||
d_model.update(d_frame);
|
||||
stopTimer();
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
d_frame.upload(frame);
|
||||
|
||||
startTimer(); next();
|
||||
d_model.update(d_frame);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IplImage ipl_frame = frame;
|
||||
cv::Ptr<CvBGStatModel> model(cvCreateFGDStatModel(&ipl_frame));
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
ipl_frame = frame;
|
||||
|
||||
startTimer(); next();
|
||||
cvUpdateBGStatModel(&ipl_frame, model);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,10 +434,6 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576.
|
||||
|
||||
cv::Mat frame;
|
||||
|
||||
cv::gpu::GpuMat d_frame;
|
||||
cv::gpu::MOG_GPU d_mog;
|
||||
cv::gpu::GpuMat d_foreground;
|
||||
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
@@ -330,30 +447,62 @@ PERF_TEST_P(Video_Cn_LearningRate, Video_MOG, Combine(Values("gpu/video/768x576.
|
||||
cv::swap(temp, frame);
|
||||
}
|
||||
|
||||
d_frame.upload(frame);
|
||||
|
||||
d_mog(d_frame, d_foreground, learningRate);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (runOnGpu)
|
||||
{
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
cv::gpu::GpuMat d_frame(frame);
|
||||
cv::gpu::MOG_GPU d_mog;
|
||||
cv::gpu::GpuMat d_foreground;
|
||||
|
||||
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);
|
||||
|
||||
startTimer(); next();
|
||||
d_mog(d_frame, d_foreground, learningRate);
|
||||
stopTimer();
|
||||
|
||||
for (int i = 0; i < 10; ++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);
|
||||
|
||||
startTimer(); next();
|
||||
d_mog(d_frame, d_foreground, learningRate);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::BackgroundSubtractorMOG mog;
|
||||
cv::Mat foreground;
|
||||
|
||||
mog(frame, foreground, learningRate);
|
||||
|
||||
for (int i = 0; i < 10; ++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);
|
||||
}
|
||||
|
||||
startTimer(); next();
|
||||
mog(frame, foreground, learningRate);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -372,10 +521,6 @@ PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/v
|
||||
|
||||
cv::Mat frame;
|
||||
|
||||
cv::gpu::GpuMat d_frame;
|
||||
cv::gpu::MOG2_GPU d_mog2;
|
||||
cv::gpu::GpuMat d_foreground;
|
||||
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
@@ -389,30 +534,62 @@ PERF_TEST_P(Video_Cn, Video_MOG2, Combine(Values("gpu/video/768x576.avi", "gpu/v
|
||||
cv::swap(temp, frame);
|
||||
}
|
||||
|
||||
d_frame.upload(frame);
|
||||
|
||||
d_mog2(d_frame, d_foreground);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (runOnGpu)
|
||||
{
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
cv::gpu::GpuMat d_frame(frame);
|
||||
cv::gpu::MOG2_GPU d_mog2;
|
||||
cv::gpu::GpuMat d_foreground;
|
||||
|
||||
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);
|
||||
|
||||
startTimer(); next();
|
||||
d_mog2(d_frame, d_foreground);
|
||||
stopTimer();
|
||||
|
||||
for (int i = 0; i < 10; ++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);
|
||||
|
||||
startTimer(); next();
|
||||
d_mog2(d_frame, d_foreground);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::BackgroundSubtractorMOG2 mog2;
|
||||
cv::Mat foreground;
|
||||
|
||||
mog2(frame, foreground);
|
||||
|
||||
for (int i = 0; i < 10; ++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);
|
||||
}
|
||||
|
||||
startTimer(); next();
|
||||
mog2(frame, foreground);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -429,36 +606,70 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage, Combine(Values("gpu/video/76
|
||||
|
||||
cv::Mat frame;
|
||||
|
||||
cv::gpu::GpuMat d_frame;
|
||||
cv::gpu::MOG2_GPU d_mog2;
|
||||
cv::gpu::GpuMat d_foreground;
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (runOnGpu)
|
||||
{
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
cv::gpu::GpuMat d_frame;
|
||||
cv::gpu::MOG2_GPU d_mog2;
|
||||
cv::gpu::GpuMat d_foreground;
|
||||
|
||||
if (cn != 3)
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
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);
|
||||
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, d_foreground);
|
||||
}
|
||||
|
||||
d_frame.upload(frame);
|
||||
|
||||
d_mog2(d_frame, d_foreground);
|
||||
}
|
||||
|
||||
cv::gpu::GpuMat d_background;
|
||||
d_mog2.getBackgroundImage(d_background);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::gpu::GpuMat d_background;
|
||||
d_mog2.getBackgroundImage(d_background);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_mog2.getBackgroundImage(d_background);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::BackgroundSubtractorMOG2 mog2;
|
||||
cv::Mat foreground;
|
||||
|
||||
for (int i = 0; i < 10; ++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);
|
||||
}
|
||||
|
||||
cv::Mat background;
|
||||
mog2.getBackgroundImage(background);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
mog2.getBackgroundImage(background);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,32 +698,39 @@ PERF_TEST_P(Video_Cn, Video_VIBE, Combine(Values("gpu/video/768x576.avi", "gpu/v
|
||||
cv::swap(temp, frame);
|
||||
}
|
||||
|
||||
cv::gpu::GpuMat d_frame(frame);
|
||||
cv::gpu::VIBE_GPU d_vibe;
|
||||
cv::gpu::GpuMat d_foreground;
|
||||
|
||||
d_vibe(d_frame, d_foreground);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (runOnGpu)
|
||||
{
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
cv::gpu::GpuMat d_frame(frame);
|
||||
cv::gpu::VIBE_GPU d_vibe;
|
||||
cv::gpu::GpuMat d_foreground;
|
||||
|
||||
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);
|
||||
|
||||
startTimer(); next();
|
||||
d_vibe(d_frame, d_foreground);
|
||||
stopTimer();
|
||||
|
||||
for (int i = 0; i < 10; ++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);
|
||||
|
||||
startTimer(); next();
|
||||
d_vibe(d_frame, d_foreground);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAIL();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,38 +762,76 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.a
|
||||
cv::swap(temp, frame);
|
||||
}
|
||||
|
||||
cv::gpu::GpuMat d_frame(frame);
|
||||
cv::gpu::GpuMat d_fgmask;
|
||||
|
||||
cv::gpu::GMG_GPU d_gmg;
|
||||
d_gmg.maxFeatures = maxFeatures;
|
||||
|
||||
d_gmg(d_frame, d_fgmask);
|
||||
|
||||
for (int i = 0; i < 150; ++i)
|
||||
if (runOnGpu)
|
||||
{
|
||||
cap >> frame;
|
||||
if (frame.empty())
|
||||
{
|
||||
cap.open(inputFile);
|
||||
cap >> frame;
|
||||
}
|
||||
cv::gpu::GpuMat d_frame(frame);
|
||||
cv::gpu::GpuMat d_fgmask;
|
||||
|
||||
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);
|
||||
}
|
||||
cv::gpu::GMG_GPU d_gmg;
|
||||
d_gmg.maxFeatures = maxFeatures;
|
||||
|
||||
d_frame.upload(frame);
|
||||
|
||||
startTimer(); next();
|
||||
d_gmg(d_frame, d_fgmask);
|
||||
stopTimer();
|
||||
|
||||
for (int i = 0; i < 150; ++i)
|
||||
{
|
||||
cap >> frame;
|
||||
if (frame.empty())
|
||||
{
|
||||
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);
|
||||
|
||||
startTimer(); next();
|
||||
d_gmg(d_frame, d_fgmask);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat fgmask;
|
||||
cv::Mat zeros(frame.size(), CV_8UC1, cv::Scalar::all(0));
|
||||
|
||||
cv::BackgroundSubtractorGMG gmg;
|
||||
gmg.set("maxFeatures", maxFeatures);
|
||||
gmg.initialize(frame.size(), 0.0, 255.0);
|
||||
|
||||
gmg(frame, fgmask);
|
||||
|
||||
for (int i = 0; i < 150; ++i)
|
||||
{
|
||||
cap >> frame;
|
||||
if (frame.empty())
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
startTimer(); next();
|
||||
gmg(frame, fgmask);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,6 +840,8 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.a
|
||||
|
||||
PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"))
|
||||
{
|
||||
declare.time(30);
|
||||
|
||||
string inputFile = perf::TestBase::getDataPath(GetParam());
|
||||
string outputFile = cv::tempfile(".avi");
|
||||
|
||||
@@ -592,26 +850,45 @@ PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video
|
||||
cv::VideoCapture reader(inputFile);
|
||||
ASSERT_TRUE( reader.isOpened() );
|
||||
|
||||
cv::gpu::VideoWriter_GPU d_writer;
|
||||
|
||||
cv::Mat frame;
|
||||
cv::gpu::GpuMat d_frame;
|
||||
|
||||
declare.time(10);
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
if (runOnGpu)
|
||||
{
|
||||
reader >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
cv::gpu::VideoWriter_GPU d_writer;
|
||||
|
||||
d_frame.upload(frame);
|
||||
cv::gpu::GpuMat d_frame;
|
||||
|
||||
if (!d_writer.isOpened())
|
||||
d_writer.open(outputFile, frame.size(), FPS);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
reader >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
startTimer(); next();
|
||||
d_writer.write(d_frame);
|
||||
stopTimer();
|
||||
d_frame.upload(frame);
|
||||
|
||||
if (!d_writer.isOpened())
|
||||
d_writer.open(outputFile, frame.size(), FPS);
|
||||
|
||||
startTimer(); next();
|
||||
d_writer.write(d_frame);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::VideoWriter writer;
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
reader >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
|
||||
if (!writer.isOpened())
|
||||
writer.open(outputFile, CV_FOURCC('X', 'V', 'I', 'D'), FPS, frame.size());
|
||||
|
||||
startTimer(); next();
|
||||
writer.write(frame);
|
||||
stopTimer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -624,16 +901,33 @@ PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video
|
||||
|
||||
string inputFile = perf::TestBase::getDataPath(GetParam());
|
||||
|
||||
cv::gpu::VideoReader_GPU d_reader(inputFile);
|
||||
ASSERT_TRUE( d_reader.isOpened() );
|
||||
|
||||
cv::gpu::GpuMat d_frame;
|
||||
|
||||
d_reader.read(d_frame);
|
||||
|
||||
TEST_CYCLE_N(10)
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::VideoReader_GPU d_reader(inputFile);
|
||||
ASSERT_TRUE( d_reader.isOpened() );
|
||||
|
||||
cv::gpu::GpuMat d_frame;
|
||||
|
||||
d_reader.read(d_frame);
|
||||
|
||||
TEST_CYCLE_N(10)
|
||||
{
|
||||
d_reader.read(d_frame);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::VideoCapture reader(inputFile);
|
||||
ASSERT_TRUE( reader.isOpened() );
|
||||
|
||||
cv::Mat frame;
|
||||
|
||||
reader >> frame;
|
||||
|
||||
TEST_CYCLE_N(10)
|
||||
{
|
||||
reader >> frame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user