Open Source Computer Vision Library https://opencv.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.7 KiB

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
10 years ago
#include "../perf_precomp.hpp"
11 years ago
#include "opencv2/ts/ocl_perf.hpp"
#ifdef HAVE_OPENCL
#ifdef HAVE_VIDEO_INPUT
#include "../perf_bgfg_utils.hpp"
11 years ago
namespace opencv_test {
11 years ago
namespace ocl {
//////////////////////////// Mog2//////////////////////////
typedef tuple<string, int> VideoMOG2ParamType;
11 years ago
typedef TestBaseWithParam<VideoMOG2ParamType> MOG2_Apply;
11 years ago
typedef TestBaseWithParam<VideoMOG2ParamType> MOG2_GetBackgroundImage;
using namespace opencv_test;
11 years ago
11 years ago
OCL_PERF_TEST_P(MOG2_Apply, Mog2, Combine(Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"), Values(1,3)))
{
VideoMOG2ParamType params = GetParam();
const string inputFile = getDataPath(get<0>(params));
const int cn = get<1>(params);
int nFrame = 5;
vector<Mat> frame_buffer(nFrame);
cv::VideoCapture cap(inputFile);
ASSERT_TRUE(cap.isOpened());
prepareData(cap, cn, frame_buffer);
UMat u_foreground;
OCL_TEST_CYCLE()
{
Ptr<cv::BackgroundSubtractorMOG2> mog2 = createBackgroundSubtractorMOG2();
mog2->setDetectShadows(false);
u_foreground.release();
for (int i = 0; i < nFrame; i++)
{
mog2->apply(frame_buffer[i], u_foreground);
}
}
SANITY_CHECK_NOTHING();
11 years ago
}
OCL_PERF_TEST_P(MOG2_GetBackgroundImage, Mog2, Values(
std::make_pair<string, int>("gpu/video/768x576.avi", 5),
std::make_pair<string, int>("gpu/video/1920x1080.avi", 5)))
11 years ago
{
VideoMOG2ParamType params = GetParam();
const string inputFile = getDataPath(get<0>(params));
const int cn = 3;
const int skipFrames = get<1>(params);
int nFrame = 10;
11 years ago
vector<Mat> frame_buffer(nFrame);
cv::VideoCapture cap(inputFile);
ASSERT_TRUE(cap.isOpened());
prepareData(cap, cn, frame_buffer, skipFrames);
11 years ago
UMat u_foreground, u_background;
OCL_TEST_CYCLE()
{
Ptr<cv::BackgroundSubtractorMOG2> mog2 = createBackgroundSubtractorMOG2();
mog2->setDetectShadows(false);
u_foreground.release();
u_background.release();
for (int i = 0; i < nFrame; i++)
{
mog2->apply(frame_buffer[i], u_foreground);
}
mog2->getBackgroundImage(u_background);
}
#ifdef DEBUG_BGFG
imwrite(format("fg_%d_%d_mog2_ocl.png", frame_buffer[0].rows, cn), u_foreground.getMat(ACCESS_READ));
imwrite(format("bg_%d_%d_mog2_ocl.png", frame_buffer[0].rows, cn), u_background.getMat(ACCESS_READ));
#endif
SANITY_CHECK_NOTHING();
11 years ago
}
}}// namespace opencv_test::ocl
11 years ago
#endif
#endif