Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
af2a7006
Commit
af2a7006
authored
May 07, 2013
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
made module dependency optional
parent
62edeeed
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
17 deletions
+66
-17
CMakeLists.txt
modules/gpubgsegm/CMakeLists.txt
+1
-1
perf_bgsegm.cpp
modules/gpubgsegm/perf/perf_bgsegm.cpp
+26
-9
perf_precomp.hpp
modules/gpubgsegm/perf/perf_precomp.hpp
+2
-0
fgd.cpp
modules/gpubgsegm/src/fgd.cpp
+11
-1
gmg.cpp
modules/gpubgsegm/src/gmg.cpp
+7
-1
precomp.hpp
modules/gpubgsegm/src/precomp.hpp
+12
-3
test_bgsegm.cpp
modules/gpubgsegm/test/test_bgsegm.cpp
+5
-2
test_precomp.hpp
modules/gpubgsegm/test/test_precomp.hpp
+2
-0
No files found.
modules/gpubgsegm/CMakeLists.txt
View file @
af2a7006
...
@@ -6,4 +6,4 @@ set(the_description "GPU-accelerated Background Segmentation")
...
@@ -6,4 +6,4 @@ set(the_description "GPU-accelerated Background Segmentation")
ocv_warnings_disable
(
CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations
)
ocv_warnings_disable
(
CMAKE_CXX_FLAGS /wd4127 /wd4324 /wd4512 -Wundef -Wmissing-declarations
)
ocv_define_module
(
gpubgsegm opencv_video
opencv_imgproc opencv_legacy
opencv_gpuarithm opencv_gpufilters opencv_gpuimgproc
)
ocv_define_module
(
gpubgsegm opencv_video
OPTIONAL opencv_legacy opencv_imgproc
opencv_gpuarithm opencv_gpufilters opencv_gpuimgproc
)
modules/gpubgsegm/perf/perf_bgsegm.cpp
View file @
af2a7006
...
@@ -41,8 +41,14 @@
...
@@ -41,8 +41,14 @@
//M*/
//M*/
#include "perf_precomp.hpp"
#include "perf_precomp.hpp"
#include "opencv2/legacy.hpp"
#include "opencv2/gpuimgproc.hpp"
#ifdef HAVE_OPENCV_LEGACY
# include "opencv2/legacy.hpp"
#endif
#ifdef HAVE_OPENCV_GPUIMGPROC
# include "opencv2/gpuimgproc.hpp"
#endif
using
namespace
std
;
using
namespace
std
;
using
namespace
testing
;
using
namespace
testing
;
...
@@ -60,6 +66,13 @@ using namespace perf;
...
@@ -60,6 +66,13 @@ using namespace perf;
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
# define BUILD_WITH_VIDEO_INPUT_SUPPORT 0
#endif
#endif
//////////////////////////////////////////////////////
// FGDStatModel
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
#ifdef HAVE_OPENCV_LEGACY
namespace
cv
namespace
cv
{
{
template
<>
void
Ptr
<
CvBGStatModel
>::
delete_obj
()
template
<>
void
Ptr
<
CvBGStatModel
>::
delete_obj
()
...
@@ -68,10 +81,7 @@ namespace cv
...
@@ -68,10 +81,7 @@ namespace cv
}
}
}
}
//////////////////////////////////////////////////////
#endif
// FGDStatModel
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
DEF_PARAM_TEST_1
(
Video
,
string
);
DEF_PARAM_TEST_1
(
Video
,
string
);
...
@@ -91,7 +101,7 @@ PERF_TEST_P(Video, FGDStatModel,
...
@@ -91,7 +101,7 @@ PERF_TEST_P(Video, FGDStatModel,
if
(
PERF_RUN_GPU
())
if
(
PERF_RUN_GPU
())
{
{
cv
::
gpu
::
GpuMat
d_frame
(
frame
),
foreground
,
background3
,
background
;
cv
::
gpu
::
GpuMat
d_frame
(
frame
),
foreground
;
cv
::
Ptr
<
cv
::
gpu
::
BackgroundSubtractorFGD
>
d_fgd
=
cv
::
gpu
::
createBackgroundSubtractorFGD
();
cv
::
Ptr
<
cv
::
gpu
::
BackgroundSubtractorFGD
>
d_fgd
=
cv
::
gpu
::
createBackgroundSubtractorFGD
();
d_fgd
->
apply
(
d_frame
,
foreground
);
d_fgd
->
apply
(
d_frame
,
foreground
);
...
@@ -108,14 +118,18 @@ PERF_TEST_P(Video, FGDStatModel,
...
@@ -108,14 +118,18 @@ PERF_TEST_P(Video, FGDStatModel,
stopTimer
();
stopTimer
();
}
}
GPU_SANITY_CHECK
(
foreground
,
1e-2
,
ERROR_RELATIVE
);
#ifdef HAVE_OPENCV_GPUIMGPROC
cv
::
gpu
::
GpuMat
background3
,
background
;
d_fgd
->
getBackgroundImage
(
background3
);
d_fgd
->
getBackgroundImage
(
background3
);
cv
::
gpu
::
cvtColor
(
background3
,
background
,
cv
::
COLOR_BGR2BGRA
);
cv
::
gpu
::
cvtColor
(
background3
,
background
,
cv
::
COLOR_BGR2BGRA
);
GPU_SANITY_CHECK
(
background
,
1e-2
,
ERROR_RELATIVE
);
GPU_SANITY_CHECK
(
background
,
1e-2
,
ERROR_RELATIVE
);
GPU_SANITY_CHECK
(
foreground
,
1e-2
,
ERROR_RELATIVE
);
#endif
}
}
else
else
{
{
#ifdef HAVE_OPENCV_LEGACY
IplImage
ipl_frame
=
frame
;
IplImage
ipl_frame
=
frame
;
cv
::
Ptr
<
CvBGStatModel
>
model
(
cvCreateFGDStatModel
(
&
ipl_frame
));
cv
::
Ptr
<
CvBGStatModel
>
model
(
cvCreateFGDStatModel
(
&
ipl_frame
));
...
@@ -136,6 +150,9 @@ PERF_TEST_P(Video, FGDStatModel,
...
@@ -136,6 +150,9 @@ PERF_TEST_P(Video, FGDStatModel,
CPU_SANITY_CHECK
(
background
);
CPU_SANITY_CHECK
(
background
);
CPU_SANITY_CHECK
(
foreground
);
CPU_SANITY_CHECK
(
foreground
);
#else
FAIL_NO_CPU
();
#endif
}
}
}
}
...
...
modules/gpubgsegm/perf/perf_precomp.hpp
View file @
af2a7006
...
@@ -57,6 +57,8 @@
...
@@ -57,6 +57,8 @@
#include "opencv2/gpubgsegm.hpp"
#include "opencv2/gpubgsegm.hpp"
#include "opencv2/video.hpp"
#include "opencv2/video.hpp"
#include "opencv2/opencv_modules.hpp"
#ifdef GTEST_CREATE_SHARED_LIBRARY
#ifdef GTEST_CREATE_SHARED_LIBRARY
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#endif
#endif
...
...
modules/gpubgsegm/src/fgd.cpp
View file @
af2a7006
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
using
namespace
cv
;
using
namespace
cv
;
using
namespace
cv
::
gpu
;
using
namespace
cv
::
gpu
;
#if !defined
HAVE_CUDA || defined(CUDA_DISABLER
)
#if !defined
(HAVE_CUDA) || defined(CUDA_DISABLER) || !defined(HAVE_OPENCV_IMGPROC) || !defined(HAVE_OPENCV_GPUARITHM) || !defined(HAVE_OPENCV_GPUIMGPROC
)
cv
::
gpu
::
FGDParams
::
FGDParams
()
{
throw_no_cuda
();
}
cv
::
gpu
::
FGDParams
::
FGDParams
()
{
throw_no_cuda
();
}
...
@@ -309,6 +309,8 @@ namespace
...
@@ -309,6 +309,8 @@ namespace
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// smoothForeground
// smoothForeground
#ifdef HAVE_OPENCV_GPUFILTERS
namespace
namespace
{
{
void
morphology
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
GpuMat
&
filterBrd
,
int
brd
,
Ptr
<
gpu
::
Filter
>&
filter
,
Scalar
brdVal
)
void
morphology
(
const
GpuMat
&
src
,
GpuMat
&
dst
,
GpuMat
&
filterBrd
,
int
brd
,
Ptr
<
gpu
::
Filter
>&
filter
,
Scalar
brdVal
)
...
@@ -336,6 +338,8 @@ namespace
...
@@ -336,6 +338,8 @@ namespace
}
}
}
}
#endif
/////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
// findForegroundRegions
// findForegroundRegions
...
@@ -606,8 +610,10 @@ namespace
...
@@ -606,8 +610,10 @@ namespace
GpuMat
buf_
;
GpuMat
buf_
;
GpuMat
filterBrd_
;
GpuMat
filterBrd_
;
#ifdef HAVE_OPENCV_GPUFILTERS
Ptr
<
gpu
::
Filter
>
dilateFilter_
;
Ptr
<
gpu
::
Filter
>
dilateFilter_
;
Ptr
<
gpu
::
Filter
>
erodeFilter_
;
Ptr
<
gpu
::
Filter
>
erodeFilter_
;
#endif
CvMemStorage
*
storage_
;
CvMemStorage
*
storage_
;
};
};
...
@@ -645,8 +651,10 @@ namespace
...
@@ -645,8 +651,10 @@ namespace
int
FG_pixels_count
=
bgfgClassification
(
prevFrame_
,
curFrame
,
Ftd_
,
Fbd_
,
foreground_
,
countBuf_
,
params_
,
4
);
int
FG_pixels_count
=
bgfgClassification
(
prevFrame_
,
curFrame
,
Ftd_
,
Fbd_
,
foreground_
,
countBuf_
,
params_
,
4
);
#ifdef HAVE_OPENCV_GPUFILTERS
if
(
params_
.
perform_morphing
>
0
)
if
(
params_
.
perform_morphing
>
0
)
smoothForeground
(
foreground_
,
filterBrd_
,
buf_
,
erodeFilter_
,
dilateFilter_
,
params_
);
smoothForeground
(
foreground_
,
filterBrd_
,
buf_
,
erodeFilter_
,
dilateFilter_
,
params_
);
#endif
if
(
params_
.
minArea
>
0
||
params_
.
is_obj_without_holes
)
if
(
params_
.
minArea
>
0
||
params_
.
is_obj_without_holes
)
findForegroundRegions
(
foreground_
,
h_foreground_
,
foreground_regions_
,
storage_
,
params_
);
findForegroundRegions
(
foreground_
,
h_foreground_
,
foreground_regions_
,
storage_
,
params_
);
...
@@ -702,6 +710,7 @@ namespace
...
@@ -702,6 +710,7 @@ namespace
stat_
.
create
(
firstFrame
.
size
(),
params_
);
stat_
.
create
(
firstFrame
.
size
(),
params_
);
fgd
::
setBGPixelStat
(
stat_
);
fgd
::
setBGPixelStat
(
stat_
);
#ifdef HAVE_OPENCV_GPUFILTERS
if
(
params_
.
perform_morphing
>
0
)
if
(
params_
.
perform_morphing
>
0
)
{
{
Mat
kernel
=
getStructuringElement
(
MORPH_RECT
,
Size
(
1
+
params_
.
perform_morphing
*
2
,
1
+
params_
.
perform_morphing
*
2
));
Mat
kernel
=
getStructuringElement
(
MORPH_RECT
,
Size
(
1
+
params_
.
perform_morphing
*
2
,
1
+
params_
.
perform_morphing
*
2
));
...
@@ -710,6 +719,7 @@ namespace
...
@@ -710,6 +719,7 @@ namespace
dilateFilter_
=
gpu
::
createMorphologyFilter
(
MORPH_DILATE
,
CV_8UC1
,
kernel
,
anchor
);
dilateFilter_
=
gpu
::
createMorphologyFilter
(
MORPH_DILATE
,
CV_8UC1
,
kernel
,
anchor
);
erodeFilter_
=
gpu
::
createMorphologyFilter
(
MORPH_ERODE
,
CV_8UC1
,
kernel
,
anchor
);
erodeFilter_
=
gpu
::
createMorphologyFilter
(
MORPH_ERODE
,
CV_8UC1
,
kernel
,
anchor
);
}
}
#endif
}
}
}
}
...
...
modules/gpubgsegm/src/gmg.cpp
View file @
af2a7006
...
@@ -45,7 +45,7 @@
...
@@ -45,7 +45,7 @@
using
namespace
cv
;
using
namespace
cv
;
using
namespace
cv
::
gpu
;
using
namespace
cv
::
gpu
;
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
|| !defined(HAVE_OPENCV_GPUFILTERS)
#if !defined HAVE_CUDA || defined(CUDA_DISABLER)
Ptr
<
gpu
::
BackgroundSubtractorGMG
>
cv
::
gpu
::
createBackgroundSubtractorGMG
(
int
,
double
)
{
throw_no_cuda
();
return
Ptr
<
gpu
::
BackgroundSubtractorGMG
>
();
}
Ptr
<
gpu
::
BackgroundSubtractorGMG
>
cv
::
gpu
::
createBackgroundSubtractorGMG
(
int
,
double
)
{
throw_no_cuda
();
return
Ptr
<
gpu
::
BackgroundSubtractorGMG
>
();
}
...
@@ -141,8 +141,10 @@ namespace
...
@@ -141,8 +141,10 @@ namespace
GpuMat
colors_
;
GpuMat
colors_
;
GpuMat
weights_
;
GpuMat
weights_
;
#if defined(HAVE_OPENCV_GPUFILTERS) && defined(HAVE_OPENCV_GPUARITHM)
Ptr
<
gpu
::
Filter
>
boxFilter_
;
Ptr
<
gpu
::
Filter
>
boxFilter_
;
GpuMat
buf_
;
GpuMat
buf_
;
#endif
};
};
GMGImpl
::
GMGImpl
(
int
initializationFrames
,
double
decisionThreshold
)
GMGImpl
::
GMGImpl
(
int
initializationFrames
,
double
decisionThreshold
)
...
@@ -212,6 +214,7 @@ namespace
...
@@ -212,6 +214,7 @@ namespace
funcs
[
frame
.
depth
()][
frame
.
channels
()
-
1
](
frame
,
fgmask
,
colors_
,
weights_
,
nfeatures_
,
frameNum_
,
funcs
[
frame
.
depth
()][
frame
.
channels
()
-
1
](
frame
,
fgmask
,
colors_
,
weights_
,
nfeatures_
,
frameNum_
,
learningRate_
,
updateBackgroundModel_
,
StreamAccessor
::
getStream
(
stream
));
learningRate_
,
updateBackgroundModel_
,
StreamAccessor
::
getStream
(
stream
));
#if defined(HAVE_OPENCV_GPUFILTERS) && defined(HAVE_OPENCV_GPUARITHM)
// medianBlur
// medianBlur
if
(
smoothingRadius_
>
0
)
if
(
smoothingRadius_
>
0
)
{
{
...
@@ -220,6 +223,7 @@ namespace
...
@@ -220,6 +223,7 @@ namespace
const
double
thresh
=
255.0
*
minCount
/
(
smoothingRadius_
*
smoothingRadius_
);
const
double
thresh
=
255.0
*
minCount
/
(
smoothingRadius_
*
smoothingRadius_
);
gpu
::
threshold
(
buf_
,
fgmask
,
thresh
,
255.0
,
THRESH_BINARY
,
stream
);
gpu
::
threshold
(
buf_
,
fgmask
,
thresh
,
255.0
,
THRESH_BINARY
,
stream
);
}
}
#endif
// keep track of how many frames we have processed
// keep track of how many frames we have processed
++
frameNum_
;
++
frameNum_
;
...
@@ -255,8 +259,10 @@ namespace
...
@@ -255,8 +259,10 @@ namespace
nfeatures_
.
setTo
(
Scalar
::
all
(
0
));
nfeatures_
.
setTo
(
Scalar
::
all
(
0
));
#if defined(HAVE_OPENCV_GPUFILTERS) && defined(HAVE_OPENCV_GPUARITHM)
if
(
smoothingRadius_
>
0
)
if
(
smoothingRadius_
>
0
)
boxFilter_
=
gpu
::
createBoxFilter
(
CV_8UC1
,
-
1
,
Size
(
smoothingRadius_
,
smoothingRadius_
));
boxFilter_
=
gpu
::
createBoxFilter
(
CV_8UC1
,
-
1
,
Size
(
smoothingRadius_
,
smoothingRadius_
));
#endif
loadConstants
(
frameSize_
.
width
,
frameSize_
.
height
,
minVal_
,
maxVal_
,
loadConstants
(
frameSize_
.
width
,
frameSize_
.
height
,
minVal_
,
maxVal_
,
quantizationLevels_
,
backgroundPrior_
,
decisionThreshold_
,
maxFeatures_
,
numInitializationFrames_
);
quantizationLevels_
,
backgroundPrior_
,
decisionThreshold_
,
maxFeatures_
,
numInitializationFrames_
);
...
...
modules/gpubgsegm/src/precomp.hpp
View file @
af2a7006
...
@@ -46,12 +46,21 @@
...
@@ -46,12 +46,21 @@
#include <limits>
#include <limits>
#include "opencv2/gpubgsegm.hpp"
#include "opencv2/gpubgsegm.hpp"
#include "opencv2/gpuarithm.hpp"
#include "opencv2/gpufilters.hpp"
#include "opencv2/gpuimgproc.hpp"
#include "opencv2/core/private.gpu.hpp"
#include "opencv2/core/private.gpu.hpp"
#include "opencv2/opencv_modules.hpp"
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_GPUARITHM
# include "opencv2/gpuarithm.hpp"
#endif
#ifdef HAVE_OPENCV_GPUFILTERS
# include "opencv2/gpufilters.hpp"
#endif
#ifdef HAVE_OPENCV_GPUIMGPROC
# include "opencv2/gpuimgproc.hpp"
#endif
#endif
/* __OPENCV_PRECOMP_H__ */
#endif
/* __OPENCV_PRECOMP_H__ */
modules/gpubgsegm/test/test_bgsegm.cpp
View file @
af2a7006
...
@@ -41,7 +41,10 @@
...
@@ -41,7 +41,10 @@
//M*/
//M*/
#include "test_precomp.hpp"
#include "test_precomp.hpp"
#include "opencv2/legacy.hpp"
#ifdef HAVE_OPENCV_LEGACY
# include "opencv2/legacy.hpp"
#endif
#ifdef HAVE_CUDA
#ifdef HAVE_CUDA
...
@@ -62,7 +65,7 @@ using namespace cvtest;
...
@@ -62,7 +65,7 @@ using namespace cvtest;
//////////////////////////////////////////////////////
//////////////////////////////////////////////////////
// FGDStatModel
// FGDStatModel
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
#if BUILD_WITH_VIDEO_INPUT_SUPPORT
&& defined(HAVE_OPENCV_LEGACY)
namespace
cv
namespace
cv
{
{
...
...
modules/gpubgsegm/test/test_precomp.hpp
View file @
af2a7006
...
@@ -59,4 +59,6 @@
...
@@ -59,4 +59,6 @@
#include "opencv2/gpubgsegm.hpp"
#include "opencv2/gpubgsegm.hpp"
#include "opencv2/video.hpp"
#include "opencv2/video.hpp"
#include "opencv2/opencv_modules.hpp"
#endif
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment