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
09127aa3
Commit
09127aa3
authored
Mar 21, 2013
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed warnings; added read/write methods; fixed docs
parent
07e0f7bf
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
24 deletions
+112
-24
motion_analysis_and_object_tracking.rst
modules/video/doc/motion_analysis_and_object_tracking.rst
+0
-0
background_segm.hpp
modules/video/include/opencv2/video/background_segm.hpp
+1
-1
bgfg_gaussmix.cpp
modules/video/src/bgfg_gaussmix.cpp
+20
-0
bgfg_gaussmix2.cpp
modules/video/src/bgfg_gaussmix2.cpp
+38
-1
bgfg_gmg.cpp
modules/video/src/bgfg_gmg.cpp
+53
-22
No files found.
modules/video/doc/motion_analysis_and_object_tracking.rst
View file @
09127aa3
This diff is collapsed.
Click to expand it.
modules/video/include/opencv2/video/background_segm.hpp
View file @
09127aa3
...
...
@@ -59,7 +59,7 @@ class BackgroundSubtractor : public Algorithm
{
public
:
//! the update operator that takes the next video frame and returns the current foreground mask as 8-bit binary image.
virtual
void
apply
(
InputArray
image
,
OutputArray
fgmask
,
double
learningRate
=
0
)
=
0
;
virtual
void
apply
(
InputArray
image
,
OutputArray
fgmask
,
double
learningRate
=
-
1
)
=
0
;
//! computes a background image
virtual
void
getBackgroundImage
(
OutputArray
backgroundImage
)
const
=
0
;
...
...
modules/video/src/bgfg_gaussmix.cpp
View file @
09127aa3
...
...
@@ -82,6 +82,7 @@ public:
varThreshold
=
defaultVarThreshold
;
backgroundRatio
=
defaultBackgroundRatio
;
noiseSigma
=
defaultNoiseSigma
;
name_
=
"BackgroundSubtractor.MOG"
;
}
// the full constructor that takes the length of the history,
// the number of gaussian mixtures, the background ratio parameter and the noise strength
...
...
@@ -138,6 +139,24 @@ public:
virtual
double
getNoiseSigma
()
const
{
return
noiseSigma
;
}
virtual
void
setNoiseSigma
(
double
_noiseSigma
)
{
noiseSigma
=
_noiseSigma
;
}
virtual
void
write
(
FileStorage
&
fs
)
const
{
fs
<<
"name"
<<
name_
<<
"history"
<<
history
<<
"nmixtures"
<<
nmixtures
<<
"backgroundRatio"
<<
backgroundRatio
<<
"noiseSigma"
<<
noiseSigma
;
}
virtual
void
read
(
const
FileNode
&
fn
)
{
CV_Assert
(
(
std
::
string
)
fn
[
"name"
]
==
name_
);
history
=
(
int
)
fn
[
"history"
];
nmixtures
=
(
int
)
fn
[
"nmixtures"
];
backgroundRatio
=
(
double
)
fn
[
"backgroundRatio"
];
noiseSigma
=
(
double
)
fn
[
"noiseSigma"
];
}
protected
:
Size
frameSize
;
int
frameType
;
...
...
@@ -148,6 +167,7 @@ protected:
double
varThreshold
;
double
backgroundRatio
;
double
noiseSigma
;
std
::
string
name_
;
};
...
...
modules/video/src/bgfg_gaussmix2.cpp
View file @
09127aa3
...
...
@@ -117,7 +117,7 @@ static const unsigned char defaultnShadowDetection2 = (unsigned char)127; // val
static
const
float
defaultfTau
=
0.5
f
;
// Tau - shadow threshold, see the paper for explanation
class
CV_EXPORTS
BackgroundSubtractorMOG2Impl
:
public
BackgroundSubtractorMOG2
class
BackgroundSubtractorMOG2Impl
:
public
BackgroundSubtractorMOG2
{
public
:
//! the default constructor
...
...
@@ -164,6 +164,7 @@ public:
fCT
=
defaultfCT2
;
nShadowDetection
=
defaultnShadowDetection2
;
fTau
=
defaultfTau
;
name_
=
"BackgroundSubtractor.MOG2"
;
}
//! the destructor
~
BackgroundSubtractorMOG2Impl
()
{}
...
...
@@ -231,6 +232,40 @@ public:
virtual
double
getShadowThreshold
()
const
{
return
fTau
;
}
virtual
void
setShadowThreshold
(
double
value
)
{
fTau
=
(
float
)
value
;
}
virtual
void
write
(
FileStorage
&
fs
)
const
{
fs
<<
"name"
<<
name_
<<
"history"
<<
history
<<
"nmixtures"
<<
nmixtures
<<
"backgroundRatio"
<<
backgroundRatio
<<
"varThreshold"
<<
varThreshold
<<
"varThresholdGen"
<<
varThresholdGen
<<
"varInit"
<<
fVarInit
<<
"varMin"
<<
fVarMin
<<
"varMax"
<<
fVarMax
<<
"complexityReductionThreshold"
<<
fCT
<<
"detectShadows"
<<
(
int
)
bShadowDetection
<<
"shadowValue"
<<
nShadowDetection
<<
"shadowThreshold"
<<
fTau
;
}
virtual
void
read
(
const
FileNode
&
fn
)
{
CV_Assert
(
(
std
::
string
)
fn
[
"name"
]
==
name_
);
history
=
(
int
)
fn
[
"history"
];
nmixtures
=
(
int
)
fn
[
"nmixtures"
];
backgroundRatio
=
(
float
)
fn
[
"backgroundRatio"
];
varThreshold
=
(
double
)
fn
[
"varThreshold"
];
varThresholdGen
=
(
float
)
fn
[
"varThresholdGen"
];
fVarInit
=
(
float
)
fn
[
"varInit"
];
fVarMin
=
(
float
)
fn
[
"varMin"
];
fVarMax
=
(
float
)
fn
[
"varMax"
];
fCT
=
(
float
)
fn
[
"complexityReductionThreshold"
];
bShadowDetection
=
(
int
)
fn
[
"detectShadows"
]
!=
0
;
nShadowDetection
=
(
int
)
fn
[
"shadowValue"
];
fTau
=
(
float
)
fn
[
"shadowThreshold"
];
}
protected
:
Size
frameSize
;
int
frameType
;
...
...
@@ -284,6 +319,8 @@ protected:
//version of the background. Tau is a threshold on how much darker the shadow can be.
//Tau= 0.5 means that if pixel is more than 2 times darker then it is not shadow
//See: Prati,Mikic,Trivedi,Cucchiarra,"Detecting Moving Shadows...",IEEE PAMI,2003.
std
::
string
name_
;
};
struct
GaussBGStatModel2Params
...
...
modules/video/src/bgfg_gmg.cpp
View file @
09127aa3
...
...
@@ -53,11 +53,30 @@
namespace
cv
{
class
CV_EXPORTS
BackgroundSubtractorGMGImpl
:
public
BackgroundSubtractorGMG
class
BackgroundSubtractorGMGImpl
:
public
BackgroundSubtractorGMG
{
public
:
BackgroundSubtractorGMGImpl
();
~
BackgroundSubtractorGMGImpl
();
BackgroundSubtractorGMGImpl
()
{
/*
* Default Parameter Values. Override with algorithm "set" method.
*/
maxFeatures
=
64
;
learningRate
=
0.025
;
numInitializationFrames
=
120
;
quantizationLevels
=
16
;
backgroundPrior
=
0.8
;
decisionThreshold
=
0.8
;
smoothingRadius
=
7
;
updateBackgroundModel
=
true
;
minVal_
=
maxVal_
=
0
;
name_
=
"BackgroundSubtractor.GMG"
;
}
~
BackgroundSubtractorGMGImpl
()
{
}
virtual
AlgorithmInfo
*
info
()
const
{
return
0
;
}
/**
...
...
@@ -117,6 +136,35 @@ public:
CV_Error
(
CV_StsNotImplemented
,
""
);
}
virtual
void
write
(
FileStorage
&
fs
)
const
{
fs
<<
"name"
<<
name_
<<
"maxFeatures"
<<
maxFeatures
<<
"defaultLearningRate"
<<
learningRate
<<
"numFrames"
<<
numInitializationFrames
<<
"quantizationLevels"
<<
quantizationLevels
<<
"backgroundPrior"
<<
backgroundPrior
<<
"decisionThreshold"
<<
decisionThreshold
<<
"smoothingRadius"
<<
smoothingRadius
<<
"updateBackgroundModel"
<<
(
int
)
updateBackgroundModel
;
// we do not save minVal_ & maxVal_, since they depend on the image type.
}
virtual
void
read
(
const
FileNode
&
fn
)
{
CV_Assert
(
(
std
::
string
)
fn
[
"name"
]
==
name_
);
maxFeatures
=
(
int
)
fn
[
"maxFeatures"
];
learningRate
=
(
double
)
fn
[
"defaultLearningRate"
];
numInitializationFrames
=
(
int
)
fn
[
"numFrames"
];
quantizationLevels
=
(
int
)
fn
[
"quantizationLevels"
];
backgroundPrior
=
(
double
)
fn
[
"backgroundPrior"
];
smoothingRadius
=
(
int
)
fn
[
"smoothingRadius"
];
decisionThreshold
=
(
double
)
fn
[
"decisionThreshold"
];
updateBackgroundModel
=
(
int
)
fn
[
"updateBackgroundModel"
]
!=
0
;
minVal_
=
maxVal_
=
0
;
frameSize_
=
Size
();
}
//! Total number of distinct colors to maintain in histogram.
int
maxFeatures
;
//! Set between 0.0 and 1.0, determines how quickly features are "forgotten" from histograms.
...
...
@@ -141,6 +189,8 @@ private:
Size
frameSize_
;
int
frameNum_
;
std
::
string
name_
;
Mat_
<
int
>
nfeatures_
;
Mat_
<
unsigned
int
>
colors_
;
Mat_
<
float
>
weights_
;
...
...
@@ -148,25 +198,6 @@ private:
Mat
buf_
;
};
BackgroundSubtractorGMGImpl
::
BackgroundSubtractorGMGImpl
()
{
/*
* Default Parameter Values. Override with algorithm "set" method.
*/
maxFeatures
=
64
;
learningRate
=
0.025
;
numInitializationFrames
=
120
;
quantizationLevels
=
16
;
backgroundPrior
=
0.8
;
decisionThreshold
=
0.8
;
smoothingRadius
=
7
;
updateBackgroundModel
=
true
;
minVal_
=
maxVal_
=
0
;
}
BackgroundSubtractorGMGImpl
::~
BackgroundSubtractorGMGImpl
()
{
}
void
BackgroundSubtractorGMGImpl
::
initialize
(
Size
frameSize
,
double
minVal
,
double
maxVal
)
{
...
...
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