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
d9cc4703
Commit
d9cc4703
authored
Jul 21, 2014
by
jaco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
7f28c23e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
20 deletions
+70
-20
saliencySpecializedClasses.hpp
...y/include/opencv2/saliency/saliencySpecializedClasses.hpp
+1
-1
computeSaliency.cpp
modules/saliency/samples/computeSaliency.cpp
+9
-1
motionSaliencyBinWangApr2014.cpp
modules/saliency/src/motionSaliencyBinWangApr2014.cpp
+60
-18
No files found.
modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
View file @
d9cc4703
...
@@ -114,7 +114,7 @@ class CV_EXPORTS_W MotionSaliencyBinWangApr2014 : public MotionSaliency
...
@@ -114,7 +114,7 @@ class CV_EXPORTS_W MotionSaliencyBinWangApr2014 : public MotionSaliency
private
:
private
:
// classification (and adaptation) functions
// classification (and adaptation) functions
bool
fullResolutionDetection
(
Mat
image
,
Mat
highResBFMask
);
bool
fullResolutionDetection
(
Mat
&
image
,
Mat
&
highResBFMask
);
bool
lowResolutionDetection
(
Mat
image
,
Mat
lowResBFMask
);
bool
lowResolutionDetection
(
Mat
image
,
Mat
lowResBFMask
);
//bool templateUpdate( Mat highResBFMask );
//bool templateUpdate( Mat highResBFMask );
...
...
modules/saliency/samples/computeSaliency.cpp
View file @
d9cc4703
...
@@ -141,7 +141,7 @@ int main( int argc, char** argv )
...
@@ -141,7 +141,7 @@ int main( int argc, char** argv )
vector
<
Vec4i
>
saliencyMap
;
vector
<
Vec4i
>
saliencyMap
;
saliencyAlgorithm
.
dynamicCast
<
ObjectnessBING
>
()
->
setTrainingPath
(
training_path
);
saliencyAlgorithm
.
dynamicCast
<
ObjectnessBING
>
()
->
setTrainingPath
(
training_path
);
saliencyAlgorithm
.
dynamicCast
<
ObjectnessBING
>
()
->
setBBResDir
(
training_path
+
"/Results"
);
saliencyAlgorithm
.
dynamicCast
<
ObjectnessBING
>
()
->
setBBResDir
(
training_path
+
"/Results"
);
if
(
saliencyAlgorithm
->
computeSaliency
(
image
,
saliencyMap
)
)
if
(
saliencyAlgorithm
->
computeSaliency
(
image
,
saliencyMap
)
)
{
{
...
@@ -154,6 +154,14 @@ int main( int argc, char** argv )
...
@@ -154,6 +154,14 @@ int main( int argc, char** argv )
}
}
}
}
else
if
(
saliency_algorithm
.
find
(
"BinWangApr2014"
)
==
0
)
{
Mat
saliencyMap
;
if
(
saliencyAlgorithm
->
computeSaliency
(
image
,
saliencyMap
)
)
{
std
::
cout
<<
"OKKKK"
<<
std
::
endl
;
}
}
return
0
;
return
0
;
}
}
modules/saliency/src/motionSaliencyBinWangApr2014.cpp
View file @
d9cc4703
...
@@ -97,47 +97,45 @@ MotionSaliencyBinWangApr2014::~MotionSaliencyBinWangApr2014()
...
@@ -97,47 +97,45 @@ MotionSaliencyBinWangApr2014::~MotionSaliencyBinWangApr2014()
}
}
// classification (and adaptation) functions
// classification (and adaptation) functions
bool
MotionSaliencyBinWangApr2014
::
fullResolutionDetection
(
Mat
image
,
Mat
highResBFMask
)
bool
MotionSaliencyBinWangApr2014
::
fullResolutionDetection
(
Mat
&
image
,
Mat
&
highResBFMask
)
{
{
Mat
currentTemplateMat
;
float
*
currentB
;
float
*
currentB
;
float
*
currentC
;
float
*
currentC
;
Vec2f
elem
;
float
currentPixelValue
;
float
currentPixelValue
;
float
currentEpslonValue
;
float
currentEpslonValue
;
bool
backgFlag
=
false
;
bool
backgFlag
=
false
;
// Initially, all pixels are considered as foreground and then we evaluate with the background model
// Initially, all pixels are considered as foreground and then we evaluate with the background model
highResBFMask
.
create
(
image
.
rows
,
image
.
cols
,
CV_8UC1
);
highResBFMask
.
setTo
(
1
);
highResBFMask
.
setTo
(
1
);
// Scan all pixels of image
// Scan all pixels of image
for
(
size_t
i
=
0
;
i
<
image
.
size
().
width
;
i
++
)
for
(
size_t
i
=
0
;
i
<
image
.
rows
;
i
++
)
{
{
for
(
size_t
j
=
0
;
j
<
image
.
size
().
height
;
j
++
)
for
(
size_t
j
=
0
;
j
<
image
.
cols
;
j
++
)
{
{
backgFlag
=
false
;
// TODO replace "at" with more efficient matrix access
// TODO replace "at" with more efficient matrix access
currentPixelValue
=
image
.
at
<
float
>
(
i
,
j
);
currentPixelValue
=
image
.
at
<
uchar
>
(
i
,
j
);
currentEpslonValue
=
epslonPixelsValue
.
at
<
float
>
(
i
,
j
);
currentEpslonValue
=
epslonPixelsValue
.
at
<
float
>
(
i
,
j
);
// scan background model vector
// scan background model vector
for
(
size_t
z
=
0
;
z
<
backgroundModel
.
size
();
z
++
)
for
(
size_t
z
=
0
;
z
<
backgroundModel
.
size
();
z
++
)
{
{
currentTemplateMat
=
backgroundModel
[
z
];
// Current Background Model matrix
// TODO replace "at" with more efficient matrix access
// TODO replace "at" with more efficient matrix access
elem
=
currentTemplateMat
.
at
<
Vec2f
>
(
i
,
j
);
currentB
=
&
backgroundModel
[
z
].
at
<
Vec2f
>
(
i
,
j
)[
0
];
currentB
=
&
elem
[
0
];
currentC
=
&
backgroundModel
[
z
].
at
<
Vec2f
>
(
i
,
j
)[
1
];
currentC
=
&
elem
[
1
];
if
(
currentC
>
0
)
//The current template is active
if
(
*
currentC
>
0
)
//The current template is active
{
{
// If there is a match with a current background template
// If there is a match with a current background template
if
(
abs
(
currentPixelValue
-
*
(
currentB
)
)
<
currentEpslonValue
&&
!
backgFlag
)
if
(
abs
(
currentPixelValue
-
*
(
currentB
)
)
<
currentEpslonValue
&&
!
backgFlag
)
{
{
// The correspondence pixel in the BF mask is set as background ( 0 value)
// The correspondence pixel in the BF mask is set as background ( 0 value)
// TODO replace "at" with more efficient matrix access
// TODO replace "at" with more efficient matrix access
highResBFMask
.
at
<
int
>
(
i
,
j
)
=
0
;
highResBFMask
.
at
<
uchar
>
(
i
,
j
)
=
0
;
*
currentC
+=
1
;
// increment the efficacy of this template
*
currentC
+=
1
;
// increment the efficacy of this template
*
currentB
=
(
(
1
-
alpha
)
*
*
currentB
)
+
(
alpha
*
currentPixelValue
);
// Update the template value
*
currentB
=
(
(
1
-
alpha
)
*
*
(
currentB
)
)
+
(
alpha
*
currentPixelValue
);
// Update the template value
backgFlag
=
true
;
backgFlag
=
true
;
//break;
//break;
}
}
...
@@ -148,10 +146,10 @@ bool MotionSaliencyBinWangApr2014::fullResolutionDetection( Mat image, Mat highR
...
@@ -148,10 +146,10 @@ bool MotionSaliencyBinWangApr2014::fullResolutionDetection( Mat image, Mat highR
}
}
}
// end "for" cicle of template vector
}
// end "for" cicle of template vector
}
}
}
// end "for" cicle of all image's pixels
}
// end "for" cicle of all image's pixels
return
true
;
return
true
;
}
}
bool
MotionSaliencyBinWangApr2014
::
lowResolutionDetection
(
Mat
image
,
Mat
lowResBFMask
)
bool
MotionSaliencyBinWangApr2014
::
lowResolutionDetection
(
Mat
image
,
Mat
lowResBFMask
)
...
@@ -160,10 +158,10 @@ bool MotionSaliencyBinWangApr2014::lowResolutionDetection( Mat image, Mat lowRes
...
@@ -160,10 +158,10 @@ bool MotionSaliencyBinWangApr2014::lowResolutionDetection( Mat image, Mat lowRes
return
true
;
return
true
;
}
}
/*bool MotionSaliencyBinWangApr2014::templateUpdate( Mat highResBFMask )
/*bool MotionSaliencyBinWangApr2014::templateUpdate( Mat highResBFMask )
{
{
return true;
return true;
}*/
}*/
// Background model maintenance functions
// Background model maintenance functions
bool
MotionSaliencyBinWangApr2014
::
templateOrdering
()
bool
MotionSaliencyBinWangApr2014
::
templateOrdering
()
...
@@ -180,6 +178,50 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( Mat finalBFMask )
...
@@ -180,6 +178,50 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( Mat finalBFMask )
bool
MotionSaliencyBinWangApr2014
::
computeSaliencyImpl
(
const
InputArray
image
,
OutputArray
saliencyMap
)
bool
MotionSaliencyBinWangApr2014
::
computeSaliencyImpl
(
const
InputArray
image
,
OutputArray
saliencyMap
)
{
{
Mat
Test
(
36
,
36
,
CV_32F
);
Mat
Results
;
std
::
ofstream
ofs
;
ofs
.
open
(
"TEST.txt"
,
std
::
ofstream
::
out
);
for
(
int
i
=
0
;
i
<
Test
.
size
().
height
;
i
++
)
{
for
(
int
j
=
0
;
j
<
Test
.
size
().
width
;
j
++
)
{
Test
.
at
<
float
>
(
i
,
j
)
=
i
+
j
;
stringstream
str
;
str
<<
i
+
j
<<
" "
;
ofs
<<
str
.
str
();
}
stringstream
str2
;
str2
<<
"
\n
"
;
ofs
<<
str2
.
str
();
}
ofs
.
close
();
//blur( Test, Results, Size( 4, 4 ) );
medianBlur
(
Test
,
Results
,
3
);
//pyrDown(Results,Results, Size(Test.size().height/9, Test.size().width/9));
std
::
ofstream
ofs2
;
ofs2
.
open
(
"RESULTS.txt"
,
std
::
ofstream
::
out
);
for
(
int
i
=
0
;
i
<
Results
.
size
().
height
;
i
++
)
{
for
(
int
j
=
0
;
j
<
Results
.
size
().
width
;
j
++
)
{
stringstream
str
;
str
<<
Results
.
at
<
float
>
(
i
,
j
)
<<
" "
;
ofs2
<<
str
.
str
();
}
stringstream
str2
;
str2
<<
"
\n
"
;
ofs2
<<
str2
.
str
();
}
ofs2
.
close
();
std
::
cout
<<
"TEST SIZE: "
<<
Test
.
size
().
height
<<
" "
<<
Test
.
size
().
width
<<
" RESULTS SIZE: "
<<
Results
.
size
().
height
<<
" "
<<
Results
.
size
().
width
<<
std
::
endl
;
return
true
;
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