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
6bf41074
Commit
6bf41074
authored
Jul 18, 2014
by
jaco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init and fullResolutionDetection function completed
parent
4b1d0c21
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
4 deletions
+78
-4
saliencySpecializedClasses.hpp
...y/include/opencv2/saliency/saliencySpecializedClasses.hpp
+2
-0
motionSaliencyBinWangApr2014.cpp
modules/saliency/src/motionSaliencyBinWangApr2014.cpp
+76
-4
No files found.
modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
View file @
6bf41074
...
...
@@ -105,6 +105,8 @@ class CV_EXPORTS_W MotionSaliencyBinWangApr2014 : public MotionSaliency
Ptr
<
Size
>
getWsize
();
void
setWsize
(
const
Ptr
<
Size
>
&
newSize
);
bool
init
();
protected
:
bool
computeSaliencyImpl
(
const
InputArray
image
,
OutputArray
saliencyMap
);
AlgorithmInfo
*
info
()
const
;
...
...
modules/saliency/src/motionSaliencyBinWangApr2014.cpp
View file @
6bf41074
...
...
@@ -56,10 +56,6 @@ void MotionSaliencyBinWangApr2014::setWsize( const cv::Ptr<Size>& newSize )
MotionSaliencyBinWangApr2014
::
MotionSaliencyBinWangApr2014
()
{
epslonPixelsValue
=
Mat
::
zeros
(
imgSize
->
height
,
imgSize
->
width
,
CV_8U
);
potentialBackground
=
Mat
::
zeros
(
imgSize
->
height
,
imgSize
->
width
,
CV_32FC2
);
backgroundModel
=
std
::
vector
<
Mat
>
(
4
,
Mat
::
zeros
(
imgSize
->
height
,
imgSize
->
width
,
CV_32FC2
)
);
K
=
3
;
// Number of background model template
alpha
=
0.01
;
// Learning rate
L0
=
6000
;
// Upper-bound values for C0 (efficacy of the first template (matrices) of backgroundModel
...
...
@@ -71,6 +67,30 @@ MotionSaliencyBinWangApr2014::MotionSaliencyBinWangApr2014()
className
=
"BinWangApr2014"
;
}
bool
MotionSaliencyBinWangApr2014
::
init
()
{
epslonPixelsValue
=
Mat
(
imgSize
->
height
,
imgSize
->
width
,
CV_32F
);
potentialBackground
=
Mat
(
imgSize
->
height
,
imgSize
->
width
,
CV_32FC2
);
backgroundModel
=
std
::
vector
<
Mat
>
(
K
+
1
,
Mat
::
zeros
(
imgSize
->
height
,
imgSize
->
width
,
CV_32FC2
)
);
potentialBackground
.
setTo
(
NAN
);
for
(
size_t
i
=
0
;
i
<
backgroundModel
.
size
();
i
++
)
backgroundModel
[
i
].
setTo
(
NAN
);
epslonPixelsValue
.
setTo
(
48.5
);
// Median of range [18, 80] advised in reference paper.
// Since data is even, the median is estimated using two values that occupy
// the position (n / 2) and ((n / 2) +1) (choose their arithmetic mean).
/* epslonPixelsValue = Mat::zeros( imgSize->height, imgSize->width, CV_8U );
potentialBackground = Mat::NAN( imgSize->height, imgSize->width, CV_32FC2 );
backgroundModel = std::vector<Mat>( 4, Mat::zeros( imgSize->height, imgSize->width, CV_32FC2 ) );*/
return
true
;
}
MotionSaliencyBinWangApr2014
::~
MotionSaliencyBinWangApr2014
()
{
...
...
@@ -79,6 +99,58 @@ MotionSaliencyBinWangApr2014::~MotionSaliencyBinWangApr2014()
// classification (and adaptation) functions
bool
MotionSaliencyBinWangApr2014
::
fullResolutionDetection
(
Mat
image
,
Mat
highResBFMask
)
{
Mat
currentTemplateMat
;
float
currentB
;
float
currentC
;
Vec2f
elem
;
float
currentPixelValue
;
float
currentEpslonValue
;
//bool backgFlag=false;
// Initially, all pixels are considered as foreground and then we evaluate with the background model
highResBFMask
.
setTo
(
1
);
// Scan all pixels of image
for
(
size_t
i
=
0
;
i
<
image
.
size
().
width
;
i
++
)
{
for
(
size_t
j
=
0
;
j
<
image
.
size
().
height
;
j
++
)
{
// TODO replace "at" with more efficient matrix access
currentPixelValue
=
image
.
at
<
float
>
(
i
,
j
);
currentEpslonValue
=
epslonPixelsValue
.
at
<
float
>
(
i
,
j
);
// scan background model vector
for
(
size_t
z
=
0
;
z
<
backgroundModel
.
size
();
z
++
)
{
currentTemplateMat
=
backgroundModel
[
z
];
// Current Background Model matrix
// TODO replace "at" with more efficient matrix access
elem
=
currentTemplateMat
.
at
<
Vec2f
>
(
i
,
j
);
currentB
=
elem
[
0
];
currentC
=
elem
[
1
];
if
(
currentC
>
0
)
//The current template is active
{
// If there is a match with a current background template
if
(
abs
(
currentPixelValue
-
currentB
)
<
currentEpslonValue
)
{
// The correspondence pixel in the BF mask is set as background ( 0 value)
// TODO replace "at" with more efficient matrix access
highResBFMask
.
at
<
int
>
(
i
,
j
)
=
0
;
// backgFlag=true;
break
;
}
}
}
// end "for" cicle of template vector
// if the pixel has not matched with none of the active background models, is set as the foreground
// in the high resolution mask
//if(!backgFlag)
// highResBFMask.at<int>( i, j ) = 1;
}
}
// end "for" cicle of all image's pixels
//////// THERE WE CALL THE templateUpdate FUNCTION (to be implemented) ////////
templateUpdate
(
highResBFMask
);
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