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
b7696377
Commit
b7696377
authored
Jun 19, 2014
by
jaco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BING porting finalized
parent
0a162305
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
52 deletions
+17
-52
CMakeLists.txt
modules/saliency/CMakeLists.txt
+1
-1
saliencySpecializedClasses.hpp
...y/include/opencv2/saliency/saliencySpecializedClasses.hpp
+8
-10
computeSaliency.cpp
modules/saliency/samples/computeSaliency.cpp
+2
-2
objectnessBING.cpp
modules/saliency/src/objectnessBING.cpp
+6
-20
saliency.cpp
modules/saliency/src/saliency.cpp
+0
-19
No files found.
modules/saliency/CMakeLists.txt
View file @
b7696377
set
(
the_description
"Saliency API"
)
ocv_define_module
(
saliency opencv_imgproc
)
ocv_define_module
(
saliency opencv_imgproc
opencv_highgui
)
modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
View file @
b7696377
...
...
@@ -91,7 +91,7 @@ class CV_EXPORTS_W StaticSaliencySpectralResidual : public StaticSaliency
protected
:
bool
computeSaliencyImpl
(
const
InputArray
src
,
OutputArray
dst
);
AlgorithmInfo
*
info
()
const
;
//{ return 0; }
AlgorithmInfo
*
info
()
const
;
CV_PROP_RW
Ptr
<
Size
>
resizedImageSize
;
private
:
...
...
@@ -125,7 +125,7 @@ class CV_EXPORTS_W MotionSaliencyPBAS : public MotionSaliency
protected
:
bool
computeSaliencyImpl
(
const
InputArray
src
,
OutputArray
dst
);
AlgorithmInfo
*
info
()
const
;
// { return 0; }
AlgorithmInfo
*
info
()
const
;
private
:
//Params params;
...
...
@@ -158,8 +158,8 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
vector
<
float
>
getobjectnessValues
();
void
setColorSpace
(
int
clr
=
MAXBGR
);
void
set
ModelName
(
string
modelName
);
void
setBBResDir
(
string
d
ir
);
void
set
TrainingPath
(
string
trainingPath
);
void
setBBResDir
(
string
resultsD
ir
);
// Read matrix from binary file
static
bool
matRead
(
const
std
::
string
&
filename
,
Mat
&
M
);
...
...
@@ -171,7 +171,7 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
protected
:
bool
computeSaliencyImpl
(
const
InputArray
src
,
OutputArray
dst
);
AlgorithmInfo
*
info
()
const
;
//{ return 0; }
AlgorithmInfo
*
info
()
const
;
private
:
// Parameters
double
_base
,
_logBase
;
// base for window size quantization
...
...
@@ -182,9 +182,8 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
int
_Clr
;
//
static
const
char
*
_clrName
[
3
];
//TODO Probably remove this parameters
//DataSetVOC &_voc; // The dataset for training, testing
std
::
string
_modelName
,
_bbResDir
;
// Names and paths to read model and to store results
std
::
string
_modelName
,
_bbResDir
,
_trainingPath
,
_resultsDir
;
vecI
_svmSzIdxs
;
// Indexes of active size. It's equal to _svmFilters.size() and _svmReW1f.rows
Mat
_svmFilter
;
// Filters learned at stage I, each is a _H by _W CV_32F matrix
...
...
@@ -192,7 +191,7 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
Mat
_svmReW1f
;
// Re-weight parameters learned at stage II.
// List of the rectangles' objectness value, in the same order as
// vector<Vec4i> objectnessBoundingBox returned by the algorithm (in computeSaliencyImpl function)
//
the
vector<Vec4i> objectnessBoundingBox returned by the algorithm (in computeSaliencyImpl function)
vector
<
float
>
objectnessValues
;
//vector<Vec4i> objectnessBoundingBox;
...
...
@@ -212,7 +211,6 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
static
inline
int
bgrMaxDist
(
const
Vec3b
&
u
,
const
Vec3b
&
v
)
{
int
b
=
abs
(
u
[
0
]
-
v
[
0
]),
g
=
abs
(
u
[
1
]
-
v
[
1
]),
r
=
abs
(
u
[
2
]
-
v
[
2
]);
b
=
max
(
b
,
g
);
return
max
(
b
,
r
);}
static
inline
int
vecDist3b
(
const
Vec3b
&
u
,
const
Vec3b
&
v
)
{
return
abs
(
u
[
0
]
-
v
[
0
])
+
abs
(
u
[
1
]
-
v
[
1
])
+
abs
(
u
[
2
]
-
v
[
2
]);}
//inline string strVec4i(const Vec4i &vv) const {return std::format("%d, %d, %d, %d", vv[0], vv[1], vv[2], vv[3]);}
//Non-maximal suppress
static
void
nonMaxSup
(
CMat
&
matchCost1f
,
ValStructVec
<
float
,
Point
>
&
matchCost
,
int
NSS
=
1
,
int
maxPoint
=
50
,
bool
fast
=
true
);
...
...
modules/saliency/samples/computeSaliency.cpp
View file @
b7696377
...
...
@@ -62,7 +62,7 @@ int main( int argc, char** argv )
Mat
binaryMap
;
Mat
image
;
//OutputArray saliencyMap( image );
Mat
image2
=
imread
(
"/home/puja/src/BING_beta2_linux/VOC2007/oneVideoJpeg4Test/0011.jpg"
);
cap
>>
frame
;
...
...
@@ -101,7 +101,7 @@ int main( int argc, char** argv )
{
vector
<
Vec4i
>
saliencyMap
;
saliencyAlgorithm
.
dynamicCast
<
ObjectnessBING
>
()
->
set
ModelName
(
training_path
);
saliencyAlgorithm
.
dynamicCast
<
ObjectnessBING
>
()
->
set
TrainingPath
(
training_path
);
saliencyAlgorithm
.
dynamicCast
<
ObjectnessBING
>
()
->
setBBResDir
(
training_path
+
"/Results"
);
if
(
saliencyAlgorithm
->
computeSaliency
(
image2
,
saliencyMap
)
)
...
...
modules/saliency/src/objectnessBING.cpp
View file @
b7696377
...
...
@@ -75,21 +75,18 @@ ObjectnessBING::~ObjectnessBING()
void
ObjectnessBING
::
setColorSpace
(
int
clr
)
{
_Clr
=
clr
;
//_modelName = "/home/puja/src/opencv_contrib/modules/saliency/src/ObjectnessTrainedModel/"
// + string( format( "ObjNessB%gW%d%s", _base, _W, _clrName[_Clr] ).c_str() );
//_bbResDir = "/home/puja/src/opencv_contrib/modules/saliency/src/" + string( format( "BBoxesB%gW%d%s/", _base, _W, _clrName[_Clr] ).c_str() );
_modelName
=
_trainingPath
+
"/"
+
string
(
format
(
"ObjNessB%gW%d%s"
,
_base
,
_W
,
_clrName
[
_Clr
]
).
c_str
()
);
_bbResDir
=
_resultsDir
+
"/"
+
string
(
format
(
"BBoxesB%gW%d%s/"
,
_base
,
_W
,
_clrName
[
_Clr
]
).
c_str
()
);
}
void
ObjectnessBING
::
set
ModelName
(
string
modelName
)
void
ObjectnessBING
::
set
TrainingPath
(
string
trainingPath
)
{
_modelName
=
modelName
+
string
(
format
(
"/ObjNessB%gW%d%s"
,
_base
,
_W
,
_clrName
[
_Clr
]
).
c_str
()
);
_trainingPath
=
trainingPath
;
}
void
ObjectnessBING
::
setBBResDir
(
string
d
ir
)
void
ObjectnessBING
::
setBBResDir
(
string
resultsD
ir
)
{
_bbResDir
=
dir
+
string
(
format
(
"BBoxesB%gW%d%s/"
,
_base
,
_W
,
_clrName
[
_Clr
]
).
c_str
()
);
_resultsDir
=
resultsDir
;
}
int
ObjectnessBING
::
loadTrainedModel
(
string
modelName
)
// Return -1, 0, or 1 if partial, none, or all loaded
...
...
@@ -99,7 +96,6 @@ int ObjectnessBING::loadTrainedModel( string modelName ) // Return -1, 0, or 1
CStr
s1
=
modelName
+
".wS1"
,
s2
=
modelName
+
".wS2"
,
sI
=
modelName
+
".idx"
;
Mat
filters1f
,
reW1f
,
idx1i
,
show3u
;
cout
<<
"***TEST*****"
<<
s1
<<
endl
;
if
(
!
matRead
(
s1
,
filters1f
)
||
!
matRead
(
sI
,
idx1i
)
)
{
printf
(
"Can't load model: %s or %s
\n
"
,
_S
(
s1
),
_S
(
sI
)
);
...
...
@@ -144,7 +140,6 @@ void ObjectnessBING::predictBBoxSI( CMat &img3u, ValStructVec<float, Vec4i> &val
resize
(
img3u
,
im3u
,
Size
(
cvRound
(
_W
*
imgW
*
1.0
/
width
),
cvRound
(
_W
*
imgH
*
1.0
/
height
)
)
);
gradientMag
(
im3u
,
mag1u
);
//imwrite(_voc.localDir + format("%d.png", r), mag1u);
//Mat mag1f;
//mag1u.convertTo(mag1f, CV_32F);
//matchTemplate(mag1f, _svmFilter, matchCost1f, CV_TM_CCORR);
...
...
@@ -445,8 +440,6 @@ bool ObjectnessBING::matRead( const string& filename, Mat& _M )
String
filenamePlusExt
(
filename
.
c_str
()
);
filenamePlusExt
+=
".yml.gz"
;
FileStorage
fs2
(
filenamePlusExt
,
FileStorage
::
READ
);
//String fileNameString( filename.c_str() );
Mat
M
;
fs2
[
String
(
removeExtension
(
basename
(
filename
)
).
c_str
()
)]
>>
M
;
...
...
@@ -492,13 +485,6 @@ bool ObjectnessBING::computeSaliencyImpl( const InputArray image, OutputArray ob
// At the top there are the rectangles with lower values of objectness, ie more
// likely to have objects in them.
vector
<
Vec4i
>
sortedBB
=
finalBoxes
.
getSortedStructVal
();
//objBoundingBox.create( 1, sortedBB.size(), CV_MAKETYPE( CV_32S, CV_MAT_CN(objBoundingBox.type()) ) );
//Mat obj = objBoundingBox.getMat();
//for ( uint i = 0; i < sortedBB.size(); i++ )
// obj.at<Vec4i>( i ) = sortedBB[i];
Mat
(
sortedBB
).
copyTo
(
objBoundingBox
);
// List of the rectangles' objectness value
...
...
modules/saliency/src/saliency.cpp
View file @
b7696377
...
...
@@ -51,27 +51,8 @@ Saliency::~Saliency()
Ptr
<
Saliency
>
Saliency
::
create
(
const
String
&
saliencyType
)
{
/*if( saliencyType.find( "STATIC_SALIENCY.SPECTRAL_RESIDUAL" ) == 0 )
{
return Ptr < Saliency > ( new StaticSaliencySpectralResidual() );
}
else if( saliencyType.find( "STATIC_SALIENCY.ITTI_CIO" ) == 0 )
{
//return Ptr < Saliency > ( new SaliencyIttiCIO() );
}
else if( saliencyType.find( "MOTION_SALIENCY.PBAS" ) == 0 )
{
return Ptr < Saliency > ( new MotionSaliencyPBAS() );
}
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>();
}
bool
Saliency
::
computeSaliency
(
const
InputArray
image
,
OutputArray
saliencyMap
)
...
...
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