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
da38a95d
Commit
da38a95d
authored
Aug 09, 2012
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed number of update operation
parent
9ec96597
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
17 deletions
+20
-17
bgfg_gmg.cpp
modules/gpu/src/bgfg_gmg.cpp
+8
-0
bgfg_gmg.cu
modules/gpu/src/cuda/bgfg_gmg.cu
+12
-17
No files found.
modules/gpu/src/bgfg_gmg.cpp
View file @
da38a95d
...
...
@@ -96,6 +96,7 @@ void cv::gpu::GMG_GPU::initialize(cv::Size frameSize, float min, float max)
nfeatures_
.
setTo
(
cv
::
Scalar
::
all
(
0
));
if
(
smoothingRadius
>
0
)
boxFilter_
=
cv
::
gpu
::
createBoxFilter_GPU
(
CV_8UC1
,
CV_8UC1
,
cv
::
Size
(
smoothingRadius
,
smoothingRadius
));
loadConstants
(
frameSize_
.
width
,
frameSize_
.
height
,
minVal_
,
maxVal_
,
quantizationLevels
,
backgroundPrior
,
decisionThreshold
,
maxFeatures
,
numInitializationFrames
);
...
...
@@ -130,14 +131,21 @@ void cv::gpu::GMG_GPU::operator ()(const cv::gpu::GpuMat& frame, cv::gpu::GpuMat
initialize
(
frame
.
size
(),
0.0
f
,
frame
.
depth
()
==
CV_8U
?
255.0
f
:
frame
.
depth
()
==
CV_16U
?
std
::
numeric_limits
<
ushort
>::
max
()
:
1.0
f
);
fgmask
.
create
(
frameSize_
,
CV_8UC1
);
if
(
stream
)
stream
.
enqueueMemSet
(
fgmask
,
cv
::
Scalar
::
all
(
0
));
else
fgmask
.
setTo
(
cv
::
Scalar
::
all
(
0
));
funcs
[
frame
.
depth
()][
frame
.
channels
()
-
1
](
frame
,
fgmask
,
colors_
,
weights_
,
nfeatures_
,
frameNum_
,
learningRate
,
cv
::
gpu
::
StreamAccessor
::
getStream
(
stream
));
// medianBlur
if
(
smoothingRadius
>
0
)
{
boxFilter_
->
apply
(
fgmask
,
buf_
,
cv
::
Rect
(
0
,
0
,
-
1
,
-
1
),
stream
);
int
minCount
=
(
smoothingRadius
*
smoothingRadius
+
1
)
/
2
;
double
thresh
=
255.0
*
minCount
/
(
smoothingRadius
*
smoothingRadius
);
cv
::
gpu
::
threshold
(
buf_
,
fgmask
,
thresh
,
255.0
,
cv
::
THRESH_BINARY
,
stream
);
}
// keep track of how many frames we have processed
++
frameNum_
;
...
...
modules/gpu/src/cuda/bgfg_gmg.cu
View file @
da38a95d
...
...
@@ -181,32 +181,18 @@ namespace cv { namespace gpu { namespace device {
int nfeatures = nfeatures_(y, x);
bool isForeground = false;
if (frameNum > c_numInitializationFrames)
if (frameNum >= c_numInitializationFrames)
{
// typical operation
const float weight = findFeature(newFeatureColor, colors_, weights_, x, y, nfeatures);
// see Godbehere, Matsukawa, Goldberg (2012) for reasoning behind this implementation of Bayes rule
const float posterior = (weight * c_backgroundPrior) / (weight * c_backgroundPrior + (1.0f - weight) * (1.0f - c_backgroundPrior));
isForeground = ((1.0f - posterior) > c_decisionThreshold);
}
const bool isForeground = ((1.0f - posterior) > c_decisionThreshold);
fgmask(y, x) = (uchar)(-isForeground);
if (frameNum <= c_numInitializationFrames + 1)
{
// training-mode update
insertFeature(newFeatureColor, 1.0f, colors_, weights_, x, y, nfeatures);
if (frameNum == c_numInitializationFrames + 1)
normalizeHistogram(weights_, x, y, nfeatures);
}
else
{
// update histogram.
for (int i = 0, fy = y; i < nfeatures; ++i, fy += c_height)
...
...
@@ -220,6 +206,15 @@ namespace cv { namespace gpu { namespace device {
nfeatures_(y, x) = nfeatures;
}
}
else
{
// training-mode update
insertFeature(newFeatureColor, 1.0f, colors_, weights_, x, y, nfeatures);
if (frameNum == c_numInitializationFrames - 1)
normalizeHistogram(weights_, x, y, nfeatures);
}
}
template <typename SrcT>
...
...
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