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
a25c27ca
Commit
a25c27ca
authored
Jun 28, 2012
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed windows build problems of BackgroundSubtractorGMG but code still need more work.
parent
82cb2ab5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
12 deletions
+10
-12
background_segm.hpp
modules/video/include/opencv2/video/background_segm.hpp
+4
-6
bgfg_gmg.cpp
modules/video/src/bgfg_gmg.cpp
+6
-6
No files found.
modules/video/include/opencv2/video/background_segm.hpp
View file @
a25c27ca
...
...
@@ -272,7 +272,7 @@ private:
* Used internally to represent a single feature in a histogram.
* Feature is a color and an associated likelihood (weight in the histogram).
*/
struct
HistogramFeatureGMG
struct
CV_EXPORTS
HistogramFeatureGMG
{
/**
* Default constructor.
...
...
@@ -316,11 +316,11 @@ private:
* Representation of the statistical model of a single pixel for use in the background subtraction
* algorithm.
*/
class
PixelModelGMG
class
CV_EXPORTS
PixelModelGMG
{
public
:
PixelModelGMG
();
virtual
~
PixelModelGMG
();
~
PixelModelGMG
();
/**
* Incorporate the last observed feature into the statistical model.
...
...
@@ -359,7 +359,7 @@ private:
PixelModelGMG
&
operator
*=
(
const
float
&
rhs
);
//friend class BackgroundSubtractorGMG;
//friend class HistogramFeatureGMG;
protected
:
private
:
size_t
numFeatures
;
//!< number of features in histogram
size_t
maxFeatures
;
//!< max allowable features in histogram
std
::
list
<
HistogramFeatureGMG
>
histogram
;
//!< represents the histogram as a list of features
...
...
@@ -444,8 +444,6 @@ protected:
Mat
fgMaskImage
;
//!< Foreground mask image.
};
bool
initModule_BackgroundSubtractorGMG
(
void
);
}
#endif
modules/video/src/bgfg_gmg.cpp
View file @
a25c27ca
...
...
@@ -237,14 +237,14 @@ void BackgroundSubtractorGMG::operator()(InputArray _image, OutputArray _fgmask,
if
(
frameNum
>
numInitializationFrames
)
// typical operation
{
newFeature
.
likelihood
=
learningRate
;
newFeature
.
likelihood
=
float
(
learningRate
)
;
/*
* (1) Query histogram to find posterior probability of feature under model.
*/
float
likelihood
=
(
float
)
pixel
->
getLikelihood
(
newFeature
);
// see Godbehere, Matsukawa, Goldberg (2012) for reasoning behind this implementation of Bayes rule
float
posterior
=
(
likelihood
*
backgroundPrior
)
/
(
likelihood
*
backgroundPrior
+
(
1
-
likelihood
)
*
(
1
-
backgroundPrior
));
float
posterior
=
float
((
likelihood
*
backgroundPrior
)
/
(
likelihood
*
backgroundPrior
+
(
1
-
likelihood
)
*
(
1
-
backgroundPrior
)
));
/*
* (2) feed posterior probability into the posterior image
...
...
@@ -252,7 +252,7 @@ void BackgroundSubtractorGMG::operator()(InputArray _image, OutputArray _fgmask,
int
row
,
col
;
col
=
i
%
imWidth
;
row
=
(
i
-
col
)
/
imWidth
;
posteriorImage
.
at
<
float
>
(
row
,
col
)
=
(
1.0
-
posterior
);
posteriorImage
.
at
<
float
>
(
row
,
col
)
=
(
1.0
f
-
posterior
);
}
pixel
->
setLastObservedFeature
(
newFeature
);
}
...
...
@@ -393,8 +393,8 @@ void BackgroundSubtractorGMG::PixelModelGMG::insertFeature(double learningRate)
* (3) Check if feature already represented. If so, simply add.
* (4) If feature is not represented, remove old feature, distribute weight evenly among existing features, add in new feature.
*/
*
this
*=
(
1.0
-
learningRate
);
lastObservedFeature
.
likelihood
=
learningRate
;
*
this
*=
float
(
1.0
-
learningRate
);
lastObservedFeature
.
likelihood
=
float
(
learningRate
)
;
for
(
feature
=
histogram
.
begin
();
feature
!=
last_feature
;
++
feature
)
{
...
...
@@ -453,7 +453,7 @@ void BackgroundSubtractorGMG::PixelModelGMG::normalizeHistogram()
for
(
feature
=
histogram
.
begin
();
feature
!=
last_feature
;
++
feature
)
{
if
(
total
!=
0.0
)
feature
->
likelihood
/=
total
;
feature
->
likelihood
=
float
(
feature
->
likelihood
/
total
)
;
}
}
...
...
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