Merge pull request #3024 from jet47:fix-cudabgsegm-compilation

pull/3022/merge
Vadim Pisarevsky 10 years ago
commit 345b69d5f7
  1. 2
      modules/cudabgsegm/CMakeLists.txt
  2. 57
      modules/cudabgsegm/perf/perf_bgsegm.cpp
  3. 78
      modules/cudabgsegm/test/test_bgsegm.cpp

@ -6,4 +6,4 @@ set(the_description "CUDA-accelerated Background Segmentation")
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations)
ocv_define_module(cudabgsegm opencv_video OPTIONAL opencv_legacy opencv_imgproc opencv_cudaarithm opencv_cudafilters opencv_cudaimgproc)
ocv_define_module(cudabgsegm opencv_video OPTIONAL opencv_imgproc opencv_cudaarithm opencv_cudafilters opencv_cudaimgproc)

@ -42,10 +42,6 @@
#include "perf_precomp.hpp"
#ifdef HAVE_OPENCV_CUDALEGACY
# include "opencv2/cudalegacy.hpp"
#endif
#ifdef HAVE_OPENCV_CUDAIMGPROC
# include "opencv2/cudaimgproc.hpp"
#endif
@ -72,18 +68,6 @@ using namespace perf;
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
#ifdef HAVE_OPENCV_CUDALEGACY
namespace cv
{
template<> void DefaultDeleter<CvBGStatModel>::operator ()(CvBGStatModel* obj) const
{
cvReleaseBGStatModel(&obj);
}
}
#endif
DEF_PARAM_TEST_1(Video, string);
PERF_TEST_P(Video, FGDStatModel,
@ -150,48 +134,7 @@ PERF_TEST_P(Video, FGDStatModel,
}
else
{
#ifdef HAVE_OPENCV_CUDALEGACY
IplImage ipl_frame = frame;
cv::Ptr<CvBGStatModel> model(cvCreateFGDStatModel(&ipl_frame));
int i = 0;
// collect performance data
for (; i < numIters; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
ipl_frame = frame;
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 = cv::cvarrToMat(model->background);
const cv::Mat foreground = cv::cvarrToMat(model->foreground);
CPU_SANITY_CHECK(background);
CPU_SANITY_CHECK(foreground);
#else
FAIL_NO_CPU();
#endif
}
}

@ -42,10 +42,6 @@
#include "test_precomp.hpp"
#ifdef HAVE_OPENCV_CUDALEGACY
# include "opencv2/cudalegacy.hpp"
#endif
#ifdef HAVE_CUDA
using namespace cvtest;
@ -63,80 +59,6 @@ using namespace cvtest;
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
//////////////////////////////////////////////////////
// FGDStatModel
#if BUILD_WITH_VIDEO_INPUT_SUPPORT && defined(HAVE_OPENCV_CUDALEGACY)
namespace cv
{
template<> void DefaultDeleter<CvBGStatModel>::operator ()(CvBGStatModel* obj) const
{
cvReleaseBGStatModel(&obj);
}
}
PARAM_TEST_CASE(FGDStatModel, cv::cuda::DeviceInfo, std::string)
{
cv::cuda::DeviceInfo devInfo;
std::string inputFile;
virtual void SetUp()
{
devInfo = GET_PARAM(0);
cv::cuda::setDevice(devInfo.deviceID());
inputFile = std::string(cvtest::TS::ptr()->get_data_path()) + "video/" + GET_PARAM(1);
}
};
CUDA_TEST_P(FGDStatModel, Update)
{
cv::VideoCapture cap(inputFile);
ASSERT_TRUE(cap.isOpened());
cv::Mat frame;
cap >> frame;
ASSERT_FALSE(frame.empty());
IplImage ipl_frame = frame;
cv::Ptr<CvBGStatModel> model(cvCreateFGDStatModel(&ipl_frame));
cv::cuda::GpuMat d_frame(frame);
cv::Ptr<cv::cuda::BackgroundSubtractorFGD> d_fgd = cv::cuda::createBackgroundSubtractorFGD();
cv::cuda::GpuMat d_foreground, d_background;
std::vector< std::vector<cv::Point> > foreground_regions;
d_fgd->apply(d_frame, d_foreground);
for (int i = 0; i < 5; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
ipl_frame = frame;
int gold_count = cvUpdateBGStatModel(&ipl_frame, model);
d_frame.upload(frame);
d_fgd->apply(d_frame, d_foreground);
d_fgd->getBackgroundImage(d_background);
d_fgd->getForegroundRegions(foreground_regions);
int count = (int) foreground_regions.size();
cv::Mat gold_background = cv::cvarrToMat(model->background);
cv::Mat gold_foreground = cv::cvarrToMat(model->foreground);
ASSERT_MAT_NEAR(gold_background, d_background, 1.0);
ASSERT_MAT_NEAR(gold_foreground, d_foreground, 0.0);
ASSERT_EQ(gold_count, count);
}
}
INSTANTIATE_TEST_CASE_P(CUDA_BgSegm, FGDStatModel, testing::Combine(
ALL_DEVICES,
testing::Values(std::string("768x576.avi"))));
#endif
//////////////////////////////////////////////////////
// MOG

Loading…
Cancel
Save