Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
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_contrib
Commits
fd7f7c37
Commit
fd7f7c37
authored
Aug 01, 2014
by
jaco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
templateReplacement function added (II part)
parent
c88e0fc4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
10 deletions
+41
-10
motionSaliencyBinWangApr2014.cpp
modules/saliency/src/motionSaliencyBinWangApr2014.cpp
+41
-10
No files found.
modules/saliency/src/motionSaliencyBinWangApr2014.cpp
View file @
fd7f7c37
...
...
@@ -300,27 +300,31 @@ bool MotionSaliencyBinWangApr2014::templateOrdering()
}
bool
MotionSaliencyBinWangApr2014
::
templateReplacement
(
Mat
finalBFMask
,
Mat
image
)
{
int
roiSize
=
3
;
int
countNonZeroElements
=
NAN
;
Mat
replicateCurrentBAMat
(
roiSize
,
roiSize
,
CV_8U
);
Mat
backgroundModelROI
(
roiSize
,
roiSize
,
CV_32F
);
Mat
diffResult
(
roiSize
,
roiSize
,
CV_32F
);
/////////////////// MAINTENANCE of potentialBackground model ///////////////////
// Scan all pixels of finalBFMask
// Scan all pixels of finalBFMask and all pixels of others models (the dimension are the same)
for
(
int
i
=
0
;
i
<
finalBFMask
.
rows
;
i
++
)
{
for
(
int
j
=
0
;
j
<
finalBFMask
.
cols
;
j
++
)
{
if
(
finalBFMask
.
at
<
int
>
(
i
,
j
)
==
1
)
// i.e. the corresponding frame pixel has been market as foreground
/////////////////// MAINTENANCE of potentialBackground model ///////////////////
if
(
finalBFMask
.
at
<
uchar
>
(
i
,
j
)
==
1
)
// i.e. the corresponding frame pixel has been market as foreground
{
/* For the pixels with CA= 0, if the current frame pixel has been classified as foreground, its value
* will be loaded into BA and CA will be set to 1*/
if
(
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
1
]
==
0
)
{
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
0
]
=
image
.
at
<
int
>
(
i
,
j
);
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
0
]
=
image
.
at
<
uchar
>
(
i
,
j
);
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
1
]
=
1
;
}
/*the distance between this pixel value and BA is calculated, and if this distance is smaller than
the decision threshold epslon, then CA is increased by 1, otherwise is decreased by 1*/
else
if
(
abs
(
image
.
at
<
int
>
(
i
,
j
)
-
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
0
]
)
<
epslonPixelsValue
.
at
<
float
>
(
i
,
j
)
)
else
if
(
abs
(
image
.
at
<
uchar
>
(
i
,
j
)
-
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
0
]
)
<
epslonPixelsValue
.
at
<
float
>
(
i
,
j
)
)
{
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
1
]
+=
1
;
}
...
...
@@ -328,12 +332,39 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( Mat finalBFMask, Mat ima
{
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
1
]
-=
1
;
}
}
}
// end of second for
}
// end of first for
}
/////////////////// END of potentialBackground model MAINTENANCE///////////////////
/////////////////// EVALUATION of potentialBackground values ///////////////////
if
(
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
1
]
>
thetaA
)
{
// replicate currentBA value
replicateCurrentBAMat
.
setTo
(
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
0
]
);
for
(
size_t
z
=
1
;
z
<
backgroundModel
.
size
();
z
++
)
{
// Neighborhood of current pixel in the current background model template.
// The ROI is centered in the pixel coordinates
// TODO border check
backgroundModelROI
=
(
backgroundModel
[
z
],
Rect
(
i
-
floor
(
roiSize
/
2
),
j
-
floor
(
roiSize
/
2
),
roiSize
,
roiSize
)
);
/* Check if the value of current pixel BA in potentialBackground model is already contained in at least one of its neighbors'
* background model
*/
absdiff
(
replicateCurrentBAMat
,
backgroundModelROI
,
diffResult
);
threshold
(
diffResult
,
diffResult
,
epslonPixelsValue
.
at
<
float
>
(
i
,
j
),
255
,
THRESH_BINARY_INV
);
countNonZeroElements
=
countNonZero
(
diffResult
);
if
(
countNonZeroElements
>
0
)
{
/////////////////// REPLACEMENT of backgroundModel template ///////////////////
//replace TA with current TK
break
;
/////////////////// EVALUATION of potentialBackground values ///////////////////
}
}
}
}
// end of second for
}
// end of first for
return
true
;
}
...
...
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