Merge remote-tracking branch 'origin/2.4' into merge-2.4
Conflicts: .gitignore doc/tutorials/objdetect/cascade_classifier/cascade_classifier.rst modules/gpu/src/match_template.cpp modules/imgproc/include/opencv2/imgproc/imgproc.hpp modules/ocl/include/opencv2/ocl/ocl.hpp modules/ocl/perf/perf_precomp.hpp
This commit is contained in:
282
modules/ocl/perf/perf_bgfg.cpp
Normal file
282
modules/ocl/perf/perf_bgfg.cpp
Normal file
@@ -0,0 +1,282 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
|
||||
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// @Authors
|
||||
// Fangfang Bai, fangfang@multicorewareinc.com
|
||||
// Jin Ma, jin@multicorewareinc.com
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other oclMaterials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors as is and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
#include "perf_precomp.hpp"
|
||||
using namespace perf;
|
||||
using namespace std;
|
||||
using namespace cv::ocl;
|
||||
using namespace cv;
|
||||
using std::tr1::tuple;
|
||||
using std::tr1::get;
|
||||
#if defined(HAVE_XINE) || \
|
||||
defined(HAVE_GSTREAMER) || \
|
||||
defined(HAVE_QUICKTIME) || \
|
||||
defined(HAVE_AVFOUNDATION) || \
|
||||
defined(HAVE_FFMPEG) || \
|
||||
defined(WIN32)
|
||||
|
||||
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 1
|
||||
#else
|
||||
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
|
||||
#endif
|
||||
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
static void cvtFrameFmt(vector<Mat>& input, vector<Mat>& output)
|
||||
{
|
||||
for(int i = 0; i< (int)(input.size()); i++)
|
||||
{
|
||||
cvtColor(input[i], output[i], COLOR_RGB2GRAY);
|
||||
}
|
||||
}
|
||||
//prepare data for CPU
|
||||
static void prepareData(VideoCapture& cap, int cn, vector<Mat>& frame_buffer)
|
||||
{
|
||||
cv::Mat frame;
|
||||
std::vector<Mat> frame_buffer_init;
|
||||
int nFrame = (int)frame_buffer.size();
|
||||
for(int i = 0; i < nFrame; i++)
|
||||
{
|
||||
cap >> frame;
|
||||
ASSERT_FALSE(frame.empty());
|
||||
frame_buffer_init.push_back(frame);
|
||||
}
|
||||
|
||||
if(cn == 1)
|
||||
cvtFrameFmt(frame_buffer_init, frame_buffer);
|
||||
else
|
||||
frame_buffer = frame_buffer_init;
|
||||
}
|
||||
//copy CPU data to GPU
|
||||
static void prepareData(vector<Mat>& frame_buffer, vector<oclMat>& frame_buffer_ocl)
|
||||
{
|
||||
for(int i = 0; i < (int)frame_buffer.size(); i++)
|
||||
frame_buffer_ocl.push_back(cv::ocl::oclMat(frame_buffer[i]));
|
||||
}
|
||||
#endif
|
||||
///////////// MOG ////////////////////////
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
|
||||
typedef tuple<string, int, double> VideoMOGParamType;
|
||||
typedef TestBaseWithParam<VideoMOGParamType> VideoMOGFixture;
|
||||
|
||||
PERF_TEST_P(VideoMOGFixture, MOG,
|
||||
::testing::Combine(::testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
|
||||
::testing::Values(1, 3),
|
||||
::testing::Values(0.0, 0.01)))
|
||||
{
|
||||
VideoMOGParamType params = GetParam();
|
||||
|
||||
const string inputFile = perf::TestBase::getDataPath(get<0>(params));
|
||||
const int cn = get<1>(params);
|
||||
const float learningRate = static_cast<float>(get<2>(params));
|
||||
|
||||
const int nFrame = 5;
|
||||
|
||||
Mat foreground_cpu;
|
||||
std::vector<Mat> frame_buffer(nFrame);
|
||||
std::vector<oclMat> frame_buffer_ocl;
|
||||
|
||||
cv::VideoCapture cap(inputFile);
|
||||
ASSERT_TRUE(cap.isOpened());
|
||||
|
||||
prepareData(cap, cn, frame_buffer);
|
||||
|
||||
cv::Mat foreground;
|
||||
cv::ocl::oclMat foreground_d;
|
||||
if(RUN_PLAIN_IMPL)
|
||||
{
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::Ptr<cv::BackgroundSubtractorMOG> mog = createBackgroundSubtractorMOG();
|
||||
foreground.release();
|
||||
for (int i = 0; i < nFrame; i++)
|
||||
{
|
||||
mog->apply(frame_buffer[i], foreground, learningRate);
|
||||
}
|
||||
}
|
||||
SANITY_CHECK(foreground);
|
||||
}else if(RUN_OCL_IMPL)
|
||||
{
|
||||
prepareData(frame_buffer, frame_buffer_ocl);
|
||||
CV_Assert((int)(frame_buffer_ocl.size()) == nFrame);
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
cv::ocl::MOG d_mog;
|
||||
foreground_d.release();
|
||||
for (int i = 0; i < nFrame; ++i)
|
||||
{
|
||||
d_mog(frame_buffer_ocl[i], foreground_d, learningRate);
|
||||
}
|
||||
}
|
||||
foreground_d.download(foreground);
|
||||
SANITY_CHECK(foreground);
|
||||
}else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////// MOG2 ////////////////////////
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
|
||||
typedef tuple<string, int> VideoMOG2ParamType;
|
||||
typedef TestBaseWithParam<VideoMOG2ParamType> VideoMOG2Fixture;
|
||||
|
||||
PERF_TEST_P(VideoMOG2Fixture, MOG2,
|
||||
::testing::Combine(::testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
|
||||
::testing::Values(1, 3)))
|
||||
{
|
||||
VideoMOG2ParamType params = GetParam();
|
||||
|
||||
const string inputFile = perf::TestBase::getDataPath(get<0>(params));
|
||||
const int cn = get<1>(params);
|
||||
int nFrame = 5;
|
||||
|
||||
std::vector<cv::Mat> frame_buffer(nFrame);
|
||||
std::vector<cv::ocl::oclMat> frame_buffer_ocl;
|
||||
|
||||
cv::VideoCapture cap(inputFile);
|
||||
ASSERT_TRUE(cap.isOpened());
|
||||
prepareData(cap, cn, frame_buffer);
|
||||
cv::Mat foreground;
|
||||
cv::ocl::oclMat foreground_d;
|
||||
|
||||
if(RUN_PLAIN_IMPL)
|
||||
{
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::Ptr<cv::BackgroundSubtractorMOG2> mog2 = createBackgroundSubtractorMOG2();
|
||||
mog2->set("detectShadows", false);
|
||||
foreground.release();
|
||||
|
||||
for (int i = 0; i < nFrame; i++)
|
||||
{
|
||||
mog2->apply(frame_buffer[i], foreground);
|
||||
}
|
||||
}
|
||||
SANITY_CHECK(foreground);
|
||||
}else if(RUN_OCL_IMPL)
|
||||
{
|
||||
prepareData(frame_buffer, frame_buffer_ocl);
|
||||
CV_Assert((int)(frame_buffer_ocl.size()) == nFrame);
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
cv::ocl::MOG2 d_mog2;
|
||||
foreground_d.release();
|
||||
for (int i = 0; i < nFrame; i++)
|
||||
{
|
||||
d_mog2(frame_buffer_ocl[i], foreground_d);
|
||||
}
|
||||
}
|
||||
foreground_d.download(foreground);
|
||||
SANITY_CHECK(foreground);
|
||||
}else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
#endif
|
||||
|
||||
///////////// MOG2_GetBackgroundImage //////////////////
|
||||
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
|
||||
|
||||
typedef TestBaseWithParam<VideoMOG2ParamType> Video_MOG2GetBackgroundImage;
|
||||
|
||||
PERF_TEST_P(Video_MOG2GetBackgroundImage, MOG2,
|
||||
::testing::Combine(::testing::Values("gpu/video/768x576.avi", "gpu/video/1920x1080.avi"),
|
||||
::testing::Values(3)))
|
||||
{
|
||||
VideoMOG2ParamType params = GetParam();
|
||||
|
||||
const string inputFile = perf::TestBase::getDataPath(get<0>(params));
|
||||
const int cn = get<1>(params);
|
||||
int nFrame = 5;
|
||||
|
||||
std::vector<cv::Mat> frame_buffer(nFrame);
|
||||
std::vector<cv::ocl::oclMat> frame_buffer_ocl;
|
||||
|
||||
cv::VideoCapture cap(inputFile);
|
||||
ASSERT_TRUE(cap.isOpened());
|
||||
|
||||
prepareData(cap, cn, frame_buffer);
|
||||
|
||||
cv::Mat foreground;
|
||||
cv::Mat background;
|
||||
cv::ocl::oclMat foreground_d;
|
||||
cv::ocl::oclMat background_d;
|
||||
|
||||
if(RUN_PLAIN_IMPL)
|
||||
{
|
||||
TEST_CYCLE()
|
||||
{
|
||||
cv::Ptr<cv::BackgroundSubtractorMOG2> mog2 = createBackgroundSubtractorMOG2();
|
||||
mog2->set("detectShadows", false);
|
||||
foreground.release();
|
||||
background.release();
|
||||
for (int i = 0; i < nFrame; i++)
|
||||
{
|
||||
mog2->apply(frame_buffer[i], foreground);
|
||||
}
|
||||
mog2->getBackgroundImage(background);
|
||||
}
|
||||
SANITY_CHECK(background);
|
||||
}else if(RUN_OCL_IMPL)
|
||||
{
|
||||
prepareData(frame_buffer, frame_buffer_ocl);
|
||||
CV_Assert((int)(frame_buffer_ocl.size()) == nFrame);
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
cv::ocl::MOG2 d_mog2;
|
||||
foreground_d.release();
|
||||
background_d.release();
|
||||
for (int i = 0; i < nFrame; i++)
|
||||
{
|
||||
d_mog2(frame_buffer_ocl[i], foreground_d);
|
||||
}
|
||||
d_mog2.getBackgroundImage(background_d);
|
||||
}
|
||||
background_d.download(background);
|
||||
SANITY_CHECK(background);
|
||||
}else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
#endif
|
@@ -43,6 +43,7 @@
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace perf;
|
||||
@@ -51,7 +52,9 @@ using namespace perf;
|
||||
|
||||
typedef TestBaseWithParam<Size> dftFixture;
|
||||
|
||||
PERF_TEST_P(dftFixture, DISABLED_dft, OCL_TYPICAL_MAT_SIZES) // TODO not implemented
|
||||
#ifdef HAVE_CLAMDFFT
|
||||
|
||||
PERF_TEST_P(dftFixture, dft, OCL_TYPICAL_MAT_SIZES)
|
||||
{
|
||||
const Size srcSize = GetParam();
|
||||
|
||||
@@ -70,7 +73,7 @@ PERF_TEST_P(dftFixture, DISABLED_dft, OCL_TYPICAL_MAT_SIZES) // TODO not impleme
|
||||
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
SANITY_CHECK(dst, 1.5);
|
||||
}
|
||||
else if (RUN_PLAIN_IMPL)
|
||||
{
|
||||
@@ -81,3 +84,5 @@ PERF_TEST_P(dftFixture, DISABLED_dft, OCL_TYPICAL_MAT_SIZES) // TODO not impleme
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -321,3 +321,82 @@ PERF_TEST_P(filter2DFixture, filter2D,
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
|
||||
///////////// Bilateral////////////////////////
|
||||
|
||||
typedef Size_MatType BilateralFixture;
|
||||
|
||||
PERF_TEST_P(BilateralFixture, Bilateral,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
OCL_PERF_ENUM(CV_8UC1, CV_8UC3)))
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params), d = 7;
|
||||
double sigmacolor = 50.0, sigmaspace = 50.0;
|
||||
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
if (srcSize == OCL_SIZE_4000 && type == CV_8UC3)
|
||||
declare.time(8);
|
||||
|
||||
if (RUN_OCL_IMPL)
|
||||
{
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
||||
|
||||
OCL_TEST_CYCLE() cv::ocl::bilateralFilter(oclSrc, oclDst, d, sigmacolor, sigmaspace);
|
||||
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else if (RUN_PLAIN_IMPL)
|
||||
{
|
||||
TEST_CYCLE() cv::bilateralFilter(src, dst, d, sigmacolor, sigmaspace);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
|
||||
///////////// adaptiveBilateral////////////////////////
|
||||
|
||||
typedef Size_MatType adaptiveBilateralFixture;
|
||||
|
||||
PERF_TEST_P(adaptiveBilateralFixture, adaptiveBilateral,
|
||||
::testing::Combine(OCL_TYPICAL_MAT_SIZES,
|
||||
OCL_PERF_ENUM(CV_8UC1, CV_8UC3)))
|
||||
{
|
||||
const Size_MatType_t params = GetParam();
|
||||
const Size srcSize = get<0>(params);
|
||||
const int type = get<1>(params);
|
||||
double sigmaspace = 10.0;
|
||||
Size ksize(9,9);
|
||||
|
||||
Mat src(srcSize, type), dst(srcSize, type);
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
|
||||
if (srcSize == OCL_SIZE_4000)
|
||||
declare.time(15);
|
||||
|
||||
if (RUN_OCL_IMPL)
|
||||
{
|
||||
ocl::oclMat oclSrc(src), oclDst(srcSize, type);
|
||||
|
||||
OCL_TEST_CYCLE() cv::ocl::adaptiveBilateralFilter(oclSrc, oclDst, ksize, sigmaspace);
|
||||
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst, 1.);
|
||||
}
|
||||
else if (RUN_PLAIN_IMPL)
|
||||
{
|
||||
TEST_CYCLE() cv::adaptiveBilateralFilter(src, dst, ksize, sigmaspace);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
|
@@ -51,8 +51,9 @@ using namespace perf;
|
||||
|
||||
typedef TestBaseWithParam<Size> gemmFixture;
|
||||
|
||||
PERF_TEST_P(gemmFixture, DISABLED_gemm,
|
||||
::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000)) // TODO not implemented
|
||||
#ifdef HAVE_CLAMDBLAS
|
||||
|
||||
PERF_TEST_P(gemmFixture, gemm, ::testing::Values(OCL_SIZE_1000, OCL_SIZE_2000))
|
||||
{
|
||||
const Size srcSize = GetParam();
|
||||
|
||||
@@ -72,14 +73,16 @@ PERF_TEST_P(gemmFixture, DISABLED_gemm,
|
||||
|
||||
oclDst.download(dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
SANITY_CHECK(dst, 0.01);
|
||||
}
|
||||
else if (RUN_PLAIN_IMPL)
|
||||
{
|
||||
TEST_CYCLE() cv::gemm(src1, src2, 1.0, src3, 1.0, dst);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
SANITY_CHECK(dst, 0.01);
|
||||
}
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -67,6 +67,7 @@
|
||||
#include <vector>
|
||||
#include <numeric>
|
||||
|
||||
#include "cvconfig.h"
|
||||
#include "opencv2/core.hpp"
|
||||
#include "opencv2/core/utility.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
@@ -102,7 +103,7 @@ using namespace cv;
|
||||
|
||||
#ifdef HAVE_OPENCV_GPU
|
||||
#define OCL_PERF_ELSE \
|
||||
if (RUN_GPU_IMPL) \
|
||||
if (RUN_GPU_IMPL) \
|
||||
CV_TEST_FAIL_NO_IMPL(); \
|
||||
else \
|
||||
CV_TEST_FAIL_NO_IMPL();
|
||||
|
Reference in New Issue
Block a user