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
c88e0fc4
Commit
c88e0fc4
authored
Aug 01, 2014
by
jaco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
templateReplacement function added (I part)
parent
5dfc2ff4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
18 deletions
+53
-18
saliencySpecializedClasses.hpp
...y/include/opencv2/saliency/saliencySpecializedClasses.hpp
+1
-1
motionSaliencyBinWangApr2014.cpp
modules/saliency/src/motionSaliencyBinWangApr2014.cpp
+52
-17
No files found.
modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
View file @
c88e0fc4
...
...
@@ -120,7 +120,7 @@ class CV_EXPORTS_W MotionSaliencyBinWangApr2014 : public MotionSaliency
// Background model maintenance functions
bool
templateOrdering
();
bool
templateReplacement
(
Mat
finalBFMask
);
bool
templateReplacement
(
Mat
finalBFMask
,
Mat
image
);
// Decision threshold adaptation and Activity control function
//bool activityControl(vector<Mat> noisePixelMask);
...
...
modules/saliency/src/motionSaliencyBinWangApr2014.cpp
View file @
c88e0fc4
...
...
@@ -298,37 +298,72 @@ bool MotionSaliencyBinWangApr2014::templateOrdering()
return
true
;
}
bool
MotionSaliencyBinWangApr2014
::
templateReplacement
(
Mat
finalBFMask
)
bool
MotionSaliencyBinWangApr2014
::
templateReplacement
(
Mat
finalBFMask
,
Mat
image
)
{
/////////////////// MAINTENANCE of potentialBackground model ///////////////////
// Scan all pixels of finalBFMask
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
{
/* 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
)[
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
)
)
{
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
1
]
+=
1
;
}
else
{
potentialBackground
.
at
<
Vec2f
>
(
i
,
j
)[
1
]
-=
1
;
}
}
}
// end of second for
}
// end of first for
/////////////////// EVALUATION of potentialBackground values ///////////////////
return
true
;
}
bool
MotionSaliencyBinWangApr2014
::
computeSaliencyImpl
(
const
InputArray
image
,
OutputArray
saliencyMap
)
{
Mat
highResBFMask
;
Mat
lowResBFMask
;
Mat
not_lowResBFMask
;
Mat
finalBFMask
;
Mat
noisePixelsMask
;
/*Mat t( image.getMat().rows, image.getMat().cols, CV_32FC2 );
Mat
highResBFMask
;
Mat
lowResBFMask
;
Mat
not_lowResBFMask
;
Mat
finalBFMask
;
Mat
noisePixelsMask
;
/*Mat t( image.getMat().rows, image.getMat().cols, CV_32FC2 );
t.setTo( 50 );
backgroundModel.at( 0 ) = t; */
fullResolutionDetection
(
image
.
getMat
(),
highResBFMask
);
lowResolutionDetection
(
image
.
getMat
(),
lowResBFMask
);
// Compute the final background-foreground mask. One pixel is marked as foreground if and only if it is
// foreground in both masks (full and low)
bitwise_and
(
highResBFMask
,
lowResBFMask
,
finalBFMask
);
fullResolutionDetection
(
image
.
getMat
(),
highResBFMask
);
lowResolutionDetection
(
image
.
getMat
(),
lowResBFMask
);
// Detect the noise pixels (i.e. for a given pixel, fullRes(pixel) = foreground and lowRes(pixel)= background)
bitwise_not
(
lowResBFMask
,
not_lowResBFMask
);
bitwise_and
(
highResBFMask
,
not_lowResBFMask
,
noisePixels
Mask
);
// Compute the final background-foreground mask. One pixel is marked as foreground if and only if it is
// foreground in both masks (full and low)
bitwise_and
(
highResBFMask
,
lowResBFMask
,
finalBF
Mask
);
// Detect the noise pixels (i.e. for a given pixel, fullRes(pixel) = foreground and lowRes(pixel)= background)
bitwise_not
(
lowResBFMask
,
not_lowResBFMask
);
bitwise_and
(
highResBFMask
,
not_lowResBFMask
,
noisePixelsMask
);
templateOrdering
();
templateOrdering
();
templateReplacement
(
finalBFMask
,
image
.
getMat
()
);
templateOrdering
();
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