Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cudabgsegm module compilation #3024

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/cudabgsegm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
57 changes: 0 additions & 57 deletions modules/cudabgsegm/perf/perf_bgsegm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
}
}

Expand Down
78 changes: 0 additions & 78 deletions modules/cudabgsegm/test/test_bgsegm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@

#include "test_precomp.hpp"

#ifdef HAVE_OPENCV_CUDALEGACY
# include "opencv2/cudalegacy.hpp"
#endif

#ifdef HAVE_CUDA

using namespace cvtest;
Expand All @@ -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

Expand Down