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
55f8310c
Commit
55f8310c
authored
Aug 09, 2012
by
Vladislav Vinogradov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed number of training mode operation
parent
9b16563f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
17 deletions
+15
-17
bgfg_gmg.cpp
modules/video/src/bgfg_gmg.cpp
+15
-17
No files found.
modules/video/src/bgfg_gmg.cpp
View file @
55f8310c
...
...
@@ -199,7 +199,7 @@ namespace
public
:
GMG_LoopBody
(
const
cv
::
Mat
&
frame
,
const
cv
::
Mat
&
fgmask
,
const
cv
::
Mat_
<
int
>&
nfeatures
,
const
cv
::
Mat_
<
int
>&
colors
,
const
cv
::
Mat_
<
float
>&
weights
,
int
maxFeatures
,
double
learningRate
,
int
numInitializationFrames
,
int
quantizationLevels
,
double
backgroundPrior
,
double
decisionThreshold
,
double
maxVal
,
double
minVal
,
size_
t
frameNum
)
:
double
maxVal
,
double
minVal
,
in
t
frameNum
)
:
frame_
(
frame
),
fgmask_
(
fgmask
),
nfeatures_
(
nfeatures
),
colors_
(
colors
),
weights_
(
weights
),
maxFeatures_
(
maxFeatures
),
learningRate_
(
learningRate
),
numInitializationFrames_
(
numInitializationFrames
),
quantizationLevels_
(
quantizationLevels
),
backgroundPrior_
(
backgroundPrior
),
decisionThreshold_
(
decisionThreshold
),
...
...
@@ -227,7 +227,7 @@ namespace
double
maxVal_
;
double
minVal_
;
size_
t
frameNum_
;
in
t
frameNum_
;
};
void
GMG_LoopBody
::
operator
()
(
const
cv
::
Range
&
range
)
const
...
...
@@ -262,7 +262,7 @@ namespace
bool
isForeground
=
false
;
if
(
frameNum_
>
numInitializationFrames_
)
if
(
frameNum_
>
=
numInitializationFrames_
)
{
// typical operation
...
...
@@ -272,33 +272,31 @@ namespace
const
double
posterior
=
(
weight
*
backgroundPrior_
)
/
(
weight
*
backgroundPrior_
+
(
1.0
-
weight
)
*
(
1.0
-
backgroundPrior_
));
isForeground
=
((
1.0
-
posterior
)
>
decisionThreshold_
);
}
fgmask_row
[
x
]
=
(
uchar
)(
-
isForeground
);
// update histogram.
if
(
frameNum_
<=
numInitializationFrames_
+
1
)
{
// training-mode update
for
(
int
i
=
0
;
i
<
nfeatures
;
++
i
)
weights
[
i
]
*=
1.0
f
-
learningRate_
;
insertFeature
(
newFeatureColor
,
1.0
f
,
colors
,
weights
,
nfeatures
,
maxFeatures_
);
bool
inserted
=
insertFeature
(
newFeatureColor
,
learningRate_
,
colors
,
weights
,
nfeatures
,
maxFeatures_
);
if
(
frameNum_
==
numInitializationFrames_
+
1
)
if
(
inserted
)
{
normalizeHistogram
(
weights
,
nfeatures
);
nfeatures_row
[
x
]
=
nfeatures
;
}
}
else
{
// update histogram.
for
(
int
i
=
0
;
i
<
nfeatures
;
++
i
)
weights
[
i
]
*=
1.0
f
-
learningRate_
;
// training-mode update
bool
inserted
=
insertFeature
(
newFeatureColor
,
learningRate_
,
colors
,
weights
,
nfeatures
,
maxFeatures_
);
insertFeature
(
newFeatureColor
,
1.0
f
,
colors
,
weights
,
nfeatures
,
maxFeatures_
);
if
(
inserted
)
if
(
frameNum_
==
numInitializationFrames_
-
1
)
normalizeHistogram
(
weights
,
nfeatures
);
}
nfeatures_row
[
x
]
=
nfeatures
;
fgmask_row
[
x
]
=
(
uchar
)(
-
isForeground
)
;
}
}
}
...
...
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