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
071b7ae1
Commit
071b7ae1
authored
Jun 05, 2014
by
jaco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Algorithm Params stuff and InputArray/OutputArray added
parent
b9e4b3e9
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
96 additions
and
88 deletions
+96
-88
saliencyBaseClasses.hpp
...saliency/include/opencv2/saliency/saliencyBaseClasses.hpp
+10
-25
saliencySpecializedClasses.hpp
...y/include/opencv2/saliency/saliencySpecializedClasses.hpp
+33
-21
motionSaliencyPBAS.cpp
modules/saliency/src/motionSaliencyPBAS.cpp
+6
-7
objectnessBING.cpp
modules/saliency/src/objectnessBING.cpp
+6
-7
saliency.cpp
modules/saliency/src/saliency.cpp
+7
-5
saliency_init.cpp
modules/saliency/src/saliency_init.cpp
+9
-5
staticSaliency.cpp
modules/saliency/src/staticSaliency.cpp
+2
-2
staticSaliencySpectralResidual.cpp
modules/saliency/src/staticSaliencySpectralResidual.cpp
+23
-16
No files found.
modules/saliency/include/opencv2/saliency/saliencyBaseClasses.hpp
View file @
071b7ae1
...
...
@@ -73,7 +73,8 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm
* \param saliencyMap The computed saliency map.
* \return true if the saliency map is computed, false otherwise
*/
bool
computeSaliency
(
const
Mat
&
image
,
Mat
&
saliencyMap
);
//bool computeSaliency( const Mat& image, Mat& saliencyMap );
bool
computeSaliency
(
const
InputArray
&
image
,
OutputArray
&
saliencyMap
);
/**
* \brief Get the name of the specific saliency type
...
...
@@ -82,7 +83,8 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm
String
getClassName
()
const
;
protected
:
virtual
bool
computeSaliencyImpl
(
const
Mat
&
image
,
Mat
&
saliencyMap
)
=
0
;
//virtual bool computeSaliencyImpl( const Mat& image, Mat& saliencyMap ) = 0;
virtual
bool
computeSaliencyImpl
(
const
InputArray
&
image
,
OutputArray
&
saliencyMap
)
=
0
;
String
className
;
};
...
...
@@ -90,49 +92,32 @@ class CV_EXPORTS_W Saliency : public virtual Algorithm
class
CV_EXPORTS_W
StaticSaliency
:
public
virtual
Saliency
{
public
:
struct
CV_EXPORTS
Params
{
Params
();
};
bool
computeBinaryMap
(
const
Mat
&
saliencyMap
,
Mat
&
binaryMap
);
protected
:
virtual
bool
computeSaliencyImpl
(
const
Mat
&
image
,
Mat
&
saliencyMap
)
=
0
;
virtual
bool
computeSaliencyImpl
(
const
InputArray
&
image
,
OutputArray
&
saliencyMap
)
=
0
;
private
:
Params
params
;
};
/************************************ Motion Saliency Base Class ************************************/
class
CV_EXPORTS_W
MotionSaliency
:
public
virtual
Saliency
{
public
:
// struct CV_EXPORTS Params
// {
// Params();
// };
protected
:
virtual
bool
computeSaliencyImpl
(
const
Mat
&
image
,
Mat
&
saliencyMap
)
=
0
;
virtual
bool
computeSaliencyImpl
(
const
InputArray
&
image
,
OutputArray
&
saliencyMap
)
=
0
;
private
:
//Params params;
};
/************************************ Objectness Base Class ************************************/
class
CV_EXPORTS_W
Objectness
:
public
virtual
Saliency
{
public
:
// struct CV_EXPORTS Params
// {
// Params();
// };
protected
:
virtual
bool
computeSaliencyImpl
(
const
Mat
&
image
,
Mat
&
saliencyMap
)
=
0
;
virtual
bool
computeSaliencyImpl
(
const
InputArray
&
image
,
OutputArray
&
saliencyMap
)
=
0
;
private
:
//Params params;
};
}
/* namespace cv */
...
...
modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
View file @
071b7ae1
...
...
@@ -57,30 +57,40 @@ namespace cv
/**
* \brief Saliency based on algorithms based on [1]
* [1]
Yan, Jia, Xi Chen, and QiuPing Zhu. "Robust online tracking via adaptive samples selection with saliency detection." (2013)
* [1]
Hou, Xiaodi, and Liqing Zhang. "Saliency detection: A spectral residual approach." Computer Vision and Pattern Recognition, 2007. CVPR'07. IEEE Conference on. IEEE, 2007.
*/
class
CV_EXPORTS_W
StaticSaliencySpectralResidual
:
public
StaticSaliency
{
public
:
struct
CV_EXPORTS
Params
/*
struct CV_EXPORTS Params
{
Params();
Size resizedImageSize;
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
};
StaticSaliencySpectralResidual
(
const
StaticSaliencySpectralResidual
::
Params
&
parameters
=
StaticSaliencySpectralResidual
::
Params
()
);
}; */
//StaticSaliencySpectralResidual( const StaticSaliencySpectralResidual::Params ¶meters = StaticSaliencySpectralResidual::Params() );
StaticSaliencySpectralResidual
();
~
StaticSaliencySpectralResidual
();
typedef
cv
::
Ptr
<
Size
>
(
cv
::
Algorithm
::*
SizeGetter
)();
typedef
void
(
cv
::
Algorithm
::*
SizeSetter
)(
const
cv
::
Ptr
<
Size
>
&
);
cv
::
Ptr
<
Size
>
getWsize
();
void
setWsize
(
const
cv
::
Ptr
<
Size
>
&
arrPtr
);
void
read
(
const
FileNode
&
fn
);
void
write
(
FileStorage
&
fs
)
const
;
protected
:
bool
computeSaliencyImpl
(
const
Mat
&
src
,
Mat
&
dst
);
AlgorithmInfo
*
info
()
const
{
return
0
;
}
bool
computeSaliencyImpl
(
const
InputArray
&
src
,
OutputArray
&
dst
);
AlgorithmInfo
*
info
()
const
;
//{ return 0; }
CV_PROP_RW
Ptr
<
Size
>
resizedImageSize
;
private
:
Params
params
;
//Params params;
};
/************************************ Specific Motion Saliency Specialized Classes ************************************/
...
...
@@ -93,25 +103,26 @@ class CV_EXPORTS_W StaticSaliencySpectralResidual : public StaticSaliency
class
CV_EXPORTS_W
MotionSaliencyPBAS
:
public
MotionSaliency
{
public
:
struct
CV_EXPORTS
Params
/*
struct CV_EXPORTS Params
{
Params();
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
};
MotionSaliencyPBAS
(
const
MotionSaliencyPBAS
::
Params
&
parameters
=
MotionSaliencyPBAS
::
Params
()
);
//MotionSaliencyPBAS();
}; */
//MotionSaliencyPBAS( const MotionSaliencyPBAS::Params ¶meters = MotionSaliencyPBAS::Params() );
MotionSaliencyPBAS
();
~
MotionSaliencyPBAS
();
void
read
(
const
FileNode
&
fn
);
void
write
(
FileStorage
&
fs
)
const
;
protected
:
bool
computeSaliencyImpl
(
const
Mat
&
src
,
Mat
&
dst
);
AlgorithmInfo
*
info
()
const
{
return
0
;
}
bool
computeSaliencyImpl
(
const
InputArray
&
src
,
OutputArray
&
dst
);
AlgorithmInfo
*
info
()
const
;
//
{ return 0; }
private
:
Params
params
;
//
Params params;
};
/************************************ Specific Objectness Specialized Classes ************************************/
...
...
@@ -123,25 +134,26 @@ class CV_EXPORTS_W MotionSaliencyPBAS : public MotionSaliency
class
CV_EXPORTS_W
ObjectnessBING
:
public
Objectness
{
public
:
struct
CV_EXPORTS
Params
/*
struct CV_EXPORTS Params
{
Params();
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
};
ObjectnessBING
(
const
ObjectnessBING
::
Params
&
parameters
=
ObjectnessBING
::
Params
()
);
//
ObjectnessBING();
}; */
//
ObjectnessBING( const ObjectnessBING::Params ¶meters = ObjectnessBING::Params() );
ObjectnessBING
();
~
ObjectnessBING
();
void
read
(
const
FileNode
&
fn
);
void
write
(
FileStorage
&
fs
)
const
;
protected
:
bool
computeSaliencyImpl
(
const
Mat
&
src
,
Mat
&
dst
);
AlgorithmInfo
*
info
()
const
{
return
0
;
}
bool
computeSaliencyImpl
(
const
InputArray
&
src
,
OutputArray
&
dst
);
AlgorithmInfo
*
info
()
const
;
//
{ return 0; }
private
:
Params
params
;
//Params params;
};
}
/* namespace cv */
...
...
modules/saliency/src/motionSaliencyPBAS.cpp
View file @
071b7ae1
...
...
@@ -50,7 +50,7 @@ namespace cv
/**
* Parameters
*/
MotionSaliencyPBAS::Params::Params()
{
...
...
@@ -65,10 +65,9 @@ void MotionSaliencyPBAS::Params::read( const cv::FileNode& fn )
void MotionSaliencyPBAS::Params::write( cv::FileStorage& fs ) const
{
//fs << "resizedImageSize" << resizedImageSize;
}
}
*/
MotionSaliencyPBAS
::
MotionSaliencyPBAS
(
const
MotionSaliencyPBAS
::
Params
&
parameters
)
:
params
(
parameters
)
MotionSaliencyPBAS
::
MotionSaliencyPBAS
()
{
className
=
"PBAS"
;
}
...
...
@@ -80,15 +79,15 @@ MotionSaliencyPBAS::~MotionSaliencyPBAS()
void
MotionSaliencyPBAS
::
read
(
const
cv
::
FileNode
&
fn
)
{
params
.
read
(
fn
);
//
params.read( fn );
}
void
MotionSaliencyPBAS
::
write
(
cv
::
FileStorage
&
fs
)
const
{
params
.
write
(
fs
);
//
params.write( fs );
}
bool
MotionSaliencyPBAS
::
computeSaliencyImpl
(
const
Mat
&
image
,
Mat
&
saliencyMap
)
bool
MotionSaliencyPBAS
::
computeSaliencyImpl
(
const
InputArray
&
src
,
OutputArray
&
dst
)
{
return
true
;
...
...
modules/saliency/src/objectnessBING.cpp
View file @
071b7ae1
...
...
@@ -50,7 +50,7 @@ namespace cv
/**
* Parameters
*/
ObjectnessBING::Params::Params()
{
...
...
@@ -65,10 +65,9 @@ void ObjectnessBING::Params::read( const cv::FileNode& fn )
void ObjectnessBING::Params::write( cv::FileStorage& fs ) const
{
//fs << "resizedImageSize" << resizedImageSize;
}
}
*/
ObjectnessBING
::
ObjectnessBING
(
const
ObjectnessBING
::
Params
&
parameters
)
:
params
(
parameters
)
ObjectnessBING
::
ObjectnessBING
()
{
className
=
"BING"
;
}
...
...
@@ -80,15 +79,15 @@ ObjectnessBING::~ObjectnessBING()
void
ObjectnessBING
::
read
(
const
cv
::
FileNode
&
fn
)
{
params
.
read
(
fn
);
//
params.read( fn );
}
void
ObjectnessBING
::
write
(
cv
::
FileStorage
&
fs
)
const
{
params
.
write
(
fs
);
//
params.write( fs );
}
bool
ObjectnessBING
::
computeSaliencyImpl
(
const
Mat
&
image
,
Mat
&
saliencyMap
)
bool
ObjectnessBING
::
computeSaliencyImpl
(
const
InputArray
&
src
,
OutputArray
&
dst
)
{
return
true
;
...
...
modules/saliency/src/saliency.cpp
View file @
071b7ae1
...
...
@@ -51,7 +51,7 @@ Saliency::~Saliency()
Ptr
<
Saliency
>
Saliency
::
create
(
const
String
&
saliencyType
)
{
if
(
saliencyType
.
find
(
"STATIC_SALIENCY.SPECTRAL_RESIDUAL"
)
==
0
)
/*
if( saliencyType.find( "STATIC_SALIENCY.SPECTRAL_RESIDUAL" ) == 0 )
{
return Ptr < Saliency > ( new StaticSaliencySpectralResidual() );
}
...
...
@@ -66,13 +66,15 @@ Ptr<Saliency> Saliency::create( const String& saliencyType )
else if( saliencyType.find( "OBJECTNESS.BING" ) == 0 )
{
return Ptr < Saliency > ( new ObjectnessBING() );
}
} */
return
Algorithm
::
create
<
Saliency
>
(
"SALIENCY."
+
saliencyType
);
CV_Error
(
-
1
,
"Saliency algorithm type "
+
saliencyType
+
" not supported"
);
return
Ptr
<
Saliency
>
();
//
CV_Error( -1, "Saliency algorithm type " + saliencyType + " not supported" );
//
return Ptr<Saliency>();
}
bool
Saliency
::
computeSaliency
(
const
Mat
&
image
,
Mat
&
saliencyMap
)
bool
Saliency
::
computeSaliency
(
const
InputArray
&
image
,
OutputArray
&
saliencyMap
)
{
if
(
image
.
empty
()
)
return
false
;
...
...
modules/saliency/src/saliency_init.cpp
View file @
071b7ae1
...
...
@@ -45,15 +45,19 @@
namespace
cv
{
//CV_INIT_ALGORITHM(TrackerMIL, "TRACKER.MIL",);
CV_INIT_ALGORITHM
(
StaticSaliencySpectralResidual
,
"SALIENCY.SPECTRAL_RESIDUAL"
,
obj
.
info
()
->
addParam
(
obj
,
"resizedImageSize"
,
obj
.
resizedImageSize
,
false
,
reinterpret_cast
<
SizeGetter
>
(
&
StaticSaliencySpectralResidual
::
getWsize
),
reinterpret_cast
<
SizeSetter
>
(
&
StaticSaliencySpectralResidual
::
setWsize
)));
//CV_INIT_ALGORITHM(TrackerBoosting, "TRACKER.BOOSTING
",);
CV_INIT_ALGORITHM
(
MotionSaliencyPBAS
,
"SALIENCY.PBAS
"
,);
bool
initModule_saliency
(
void
)
CV_INIT_ALGORITHM
(
ObjectnessBING
,
"SALIENCY.BING"
,
);
bool
initModule_saliency
(
void
)
{
bool
all
=
true
;
//all &= !TrackerMIL_info_auto.name().empty();
//all &= !TrackerBoosting_info_auto.name().empty();
all
&=
!
StaticSaliencySpectralResidual_info_auto
.
name
().
empty
();
all
&=
!
MotionSaliencyPBAS_info_auto
.
name
().
empty
();
all
&=
!
ObjectnessBING_info_auto
.
name
().
empty
();
return
all
;
}
...
...
modules/saliency/src/staticSaliency.cpp
View file @
071b7ae1
...
...
@@ -50,12 +50,12 @@ namespace cv
/**
* Parameters
*/
StaticSaliency::Params::Params()
{
}
}
*/
bool
StaticSaliency
::
computeBinaryMap
(
const
Mat
&
saliencyMap
,
Mat
&
BinaryMap
)
{
...
...
modules/saliency/src/staticSaliencySpectralResidual.cpp
View file @
071b7ae1
...
...
@@ -50,7 +50,7 @@ namespace cv
/**
* Parameters
*/
StaticSaliencySpectralResidual::Params::Params()
{
...
...
@@ -66,12 +66,20 @@ void StaticSaliencySpectralResidual::Params::read( const cv::FileNode& fn )
void StaticSaliencySpectralResidual::Params::write( cv::FileStorage& fs ) const
{
//fs << "resizedImageSize" << resizedImageSize;
} */
cv
::
Ptr
<
Size
>
StaticSaliencySpectralResidual
::
getWsize
(){
return
resizedImageSize
;
}
void
StaticSaliencySpectralResidual
::
setWsize
(
const
cv
::
Ptr
<
Size
>&
newSize
){
resizedImageSize
=
newSize
;
}
StaticSaliencySpectralResidual
::
StaticSaliencySpectralResidual
(
const
StaticSaliencySpectralResidual
::
Params
&
parameters
)
:
params
(
parameters
)
StaticSaliencySpectralResidual
::
StaticSaliencySpectralResidual
()
{
className
=
"SPECTRAL_RESIDUAL"
;
resizedImageSize
=
Ptr
<
Size
>
(
new
Size
(
64
,
64
));
}
StaticSaliencySpectralResidual
::~
StaticSaliencySpectralResidual
()
...
...
@@ -81,37 +89,36 @@ StaticSaliencySpectralResidual::~StaticSaliencySpectralResidual()
void
StaticSaliencySpectralResidual
::
read
(
const
cv
::
FileNode
&
fn
)
{
params
.
read
(
fn
);
//
params.read( fn );
}
void
StaticSaliencySpectralResidual
::
write
(
cv
::
FileStorage
&
fs
)
const
{
params
.
write
(
fs
);
//
params.write( fs );
}
bool
StaticSaliencySpectralResidual
::
computeSaliencyImpl
(
const
Mat
&
image
,
Mat
&
saliencyMap
)
bool
StaticSaliencySpectralResidual
::
computeSaliencyImpl
(
const
InputArray
&
image
,
OutputArray
&
saliencyMap
)
{
Mat
grayTemp
,
grayDown
;
std
::
vector
<
Mat
>
mv
;
Mat
realImage
(
params
.
resizedImageSize
,
CV_64F
);
Mat
imaginaryImage
(
params
.
resizedImageSize
,
CV_64F
);
Mat
realImage
(
*
resizedImageSize
,
CV_64F
);
Mat
imaginaryImage
(
*
resizedImageSize
,
CV_64F
);
imaginaryImage
.
setTo
(
0
);
Mat
combinedImage
(
params
.
resizedImageSize
,
CV_64FC2
);
Mat
combinedImage
(
*
resizedImageSize
,
CV_64FC2
);
Mat
imageDFT
;
Mat
logAmplitude
;
Mat
angle
(
params
.
resizedImageSize
,
CV_64F
);
Mat
magnitude
(
params
.
resizedImageSize
,
CV_64F
);
Mat
angle
(
*
resizedImageSize
,
CV_64F
);
Mat
magnitude
(
*
resizedImageSize
,
CV_64F
);
Mat
logAmplitude_blur
,
imageGR
;
if
(
image
.
channels
()
==
3
)
{
cvtColor
(
image
,
imageGR
,
COLOR_BGR2GRAY
);
resize
(
imageGR
,
grayDown
,
params
.
resizedImageSize
,
0
,
0
,
INTER_LINEAR
);
resize
(
imageGR
,
grayDown
,
*
resizedImageSize
,
0
,
0
,
INTER_LINEAR
);
}
else
{
resize
(
image
,
grayDown
,
params
.
resizedImageSize
,
0
,
0
,
INTER_LINEAR
);
resize
(
image
,
grayDown
,
*
resizedImageSize
,
0
,
0
,
INTER_LINEAR
);
}
grayDown
.
convertTo
(
realImage
,
CV_64F
);
...
...
@@ -148,8 +155,8 @@ bool StaticSaliencySpectralResidual::computeSaliencyImpl( const Mat& image, Mat&
resize
(
magnitude
,
saliencyMap
,
image
.
size
(),
0
,
0
,
INTER_LINEAR
);
#ifdef SALIENCY_DEBUG
// visualize saliency map
before and after K-means
imshow
(
"Saliency Map"
,
saliencyMap
);
// visualize saliency map
imshow
(
"Saliency Map
Interna
"
,
saliencyMap
);
#endif
...
...
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