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
0a162305
Commit
0a162305
authored
Jun 18, 2014
by
jaco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BING modification after OpenCV master update
parent
a76954ad
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
49 additions
and
46 deletions
+49
-46
saliencySpecializedClasses.hpp
...y/include/opencv2/saliency/saliencySpecializedClasses.hpp
+2
-2
computeSaliency.cpp
modules/saliency/samples/computeSaliency.cpp
+24
-21
CmFile.cpp
modules/saliency/src/CmFile.cpp
+1
-1
CmShow.cpp
modules/saliency/src/CmShow.cpp
+1
-0
ValStructVec.h
modules/saliency/src/ValStructVec.h
+5
-5
kyheader.h
modules/saliency/src/kyheader.h
+3
-6
motionSaliencyPBAS.cpp
modules/saliency/src/motionSaliencyPBAS.cpp
+3
-3
objectnessBING.cpp
modules/saliency/src/objectnessBING.cpp
+9
-7
saliency.cpp
modules/saliency/src/saliency.cpp
+1
-1
No files found.
modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
View file @
0a162305
...
...
@@ -158,8 +158,8 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
vector
<
float
>
getobjectnessValues
();
void
setColorSpace
(
int
clr
=
MAXBGR
);
void
set
_modelName
(
string
n
ame
);
void
set
_bb
ResDir
(
string
dir
);
void
set
ModelName
(
string
modelN
ame
);
void
set
BB
ResDir
(
string
dir
);
// Read matrix from binary file
static
bool
matRead
(
const
std
::
string
&
filename
,
Mat
&
M
);
...
...
modules/saliency/samples/computeSaliency.cpp
View file @
0a162305
...
...
@@ -9,13 +9,14 @@ using namespace cv;
static
const
char
*
keys
=
{
"{@saliency_algorithm | | Saliency algorithm <saliencyAlgorithmType.[saliencyAlgorithmTypeSubType]> }"
"{@video_name | | video name }"
"{@start_frame |1| Start frame }"
};
"{@start_frame |1| Start frame }"
"{@training_path |1| Path of the folder containing the trained files}"
};
static
void
help
()
{
cout
<<
"
\n
This example shows the functionality of
\"
Saliency
\"
"
"Call:
\n
"
"./example_saliency_computeSaliency <
SALIENCY.[saliencyAlgorithmSubType]
> <video_name> <start_frame>
\n
"
"./example_saliency_computeSaliency <
saliencyAlgorithmSubType
> <video_name> <start_frame>
\n
"
<<
endl
;
}
...
...
@@ -26,6 +27,7 @@ int main( int argc, char** argv )
String
saliency_algorithm
=
parser
.
get
<
String
>
(
0
);
String
video_name
=
parser
.
get
<
String
>
(
1
);
int
start_frame
=
parser
.
get
<
int
>
(
2
);
String
training_path
=
parser
.
get
<
String
>
(
3
);
if
(
saliency_algorithm
.
empty
()
||
video_name
.
empty
()
)
{
...
...
@@ -61,6 +63,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
;
if
(
frame
.
empty
()
)
...
...
@@ -70,16 +73,14 @@ int main( int argc, char** argv )
frame
.
copyTo
(
image
);
if
(
saliency_algorithm
.
find
(
"SPECTRAL_RESIDUAL"
)
==
0
)
{
Mat
saliencyMap
;
if
(
saliencyAlgorithm
->
computeSaliency
(
image
,
saliencyMap
)
)
{
StaticSaliencySpectralResidual
spec
;
//Mat salMat=saliencyMap.getMat();
spec
.
computeBinaryMap
(
saliencyMap
,
binaryMap
);
//saliencyAlgorithm->computeBinaryMap( saliencyMap, binaryMap );
imshow
(
"Saliency Map"
,
saliencyMap
);
imshow
(
"Original Image"
,
image
);
imshow
(
"Binary Map"
,
binaryMap
);
...
...
@@ -89,26 +90,28 @@ int main( int argc, char** argv )
}
else
if
(
saliency_algorithm
.
find
(
"BING"
)
==
0
)
{
vector
<
Vec4i
>
saliencyMap
;
//Ptr<ObjectnessBING> bing = Saliency::create( "BING" );
//bing=static_cast<ObjectnessBING>(saliencyAlgorithm);
saliencyAlgorithm
.
staticCast
<
ObjectnessBING
>
()
->
set_modelName
(
"home/puja/src/opencv_contrib/modules/saliency/src/ObjectnessTrainedModel/"
);
saliencyAlgorithm
.
staticCast
<
ObjectnessBING
>
()
->
set_bbResDir
(
"/home/puja/src/opencv_contrib/modules/saliency/src/ObjectnessTrainedModel/"
);
//ObjectnessBING bing(saliencyAlgorithm);
if
(
training_path
.
empty
()
)
{
//bing->set_modelName("home/puja/src/opencv_contrib/modules/saliency/src/ObjectnessTrainedModel/");
//bing->set_bbResDir("/home/puja/src/opencv_contrib/modules/saliency/src/ObjectnessTrainedModel/");
cout
<<
"Path of trained files missing! "
<<
endl
;
return
-
1
;
}
if
(
saliencyAlgorithm
->
computeSaliency
(
image
,
saliencyMap
)
)
else
{
std
::
cout
<<
"-----------------OBJECTNESS-----------"
<<
std
::
endl
;
std
::
cout
<<
"OBJECTNESS BOUNDING BOX VECTOR SIZE"
<<
saliencyMap
.
size
()
<<
std
::
endl
;
std
::
cout
<<
" "
<<
saliencyMap
[
0
]
<<
std
::
endl
;
std
::
cout
<<
" "
<<
saliencyMap
[
1
]
<<
std
::
endl
;
std
::
cout
<<
" "
<<
saliencyMap
[
2
]
<<
std
::
endl
;
vector
<
Vec4i
>
saliencyMap
;
saliencyAlgorithm
.
dynamicCast
<
ObjectnessBING
>
()
->
setModelName
(
training_path
);
saliencyAlgorithm
.
dynamicCast
<
ObjectnessBING
>
()
->
setBBResDir
(
training_path
+
"/Results"
);
if
(
saliencyAlgorithm
->
computeSaliency
(
image2
,
saliencyMap
)
)
{
std
::
cout
<<
"-----------------OBJECTNESS-----------"
<<
std
::
endl
;
std
::
cout
<<
"OBJECTNESS BOUNDING BOX VECTOR SIZE"
<<
saliencyMap
.
size
()
<<
std
::
endl
;
std
::
cout
<<
" "
<<
saliencyMap
[
0
]
<<
std
::
endl
;
std
::
cout
<<
" "
<<
saliencyMap
[
1
]
<<
std
::
endl
;
std
::
cout
<<
" "
<<
saliencyMap
[
2
]
<<
std
::
endl
;
}
}
}
...
...
modules/saliency/src/CmFile.cpp
View file @
0a162305
...
...
@@ -105,7 +105,7 @@ bool CmFile::MkDir(CStr &_path)
}
void
CmFile
::
loadStrList
(
CStr
&
fName
,
vecS
&
strs
,
bool
flag
)
{
ifstream
fIn
(
fName
);
ifstream
fIn
(
fName
.
c_str
()
);
string
line
;
//vecS strs;
while
(
getline
(
fIn
,
line
)){
...
...
modules/saliency/src/CmShow.cpp
View file @
0a162305
#include "kyheader.h"
#include "CmShow.h"
#include "opencv2/core.hpp"
#include <opencv2/highgui.hpp>
...
...
modules/saliency/src/ValStructVec.h
View file @
0a162305
...
...
@@ -53,14 +53,14 @@ struct ValStructVec
void
sort
(
bool
descendOrder
=
true
);
const
vector
<
ST
>
&
getSortedStructVal
();
vector
<
pair
<
VT
,
int
>>
getvalIdxes
();
vector
<
pair
<
VT
,
int
>
>
getvalIdxes
();
void
append
(
const
ValStructVec
<
VT
,
ST
>
&
newVals
,
int
startV
=
0
);
vector
<
ST
>
structVals
;
// struct values
private
:
int
sz
;
// size of the value struct vector
vector
<
pair
<
VT
,
int
>>
valIdxes
;
// Indexes after sort
vector
<
pair
<
VT
,
int
>
>
valIdxes
;
// Indexes after sort
bool
smaller
()
{
return
true
;
...
...
@@ -81,9 +81,9 @@ template<typename VT, typename ST>
void
ValStructVec
<
VT
,
ST
>::
sort
(
bool
descendOrder
/* = true */
)
{
if
(
descendOrder
)
std
::
sort
(
valIdxes
.
begin
(),
valIdxes
.
end
(),
std
::
greater
<
pair
<
VT
,
int
>>
()
);
std
::
sort
(
valIdxes
.
begin
(),
valIdxes
.
end
(),
std
::
greater
<
pair
<
VT
,
int
>
>
()
);
else
std
::
sort
(
valIdxes
.
begin
(),
valIdxes
.
end
(),
std
::
less
<
pair
<
VT
,
int
>>
()
);
std
::
sort
(
valIdxes
.
begin
(),
valIdxes
.
end
(),
std
::
less
<
pair
<
VT
,
int
>
>
()
);
}
template
<
typename
VT
,
typename
ST
>
...
...
@@ -96,7 +96,7 @@ const vector<ST>& ValStructVec<VT, ST>::getSortedStructVal()
}
template
<
typename
VT
,
typename
ST
>
vector
<
pair
<
VT
,
int
>>
ValStructVec
<
VT
,
ST
>::
getvalIdxes
()
vector
<
pair
<
VT
,
int
>
>
ValStructVec
<
VT
,
ST
>::
getvalIdxes
()
{
return
valIdxes
;
}
...
...
modules/saliency/src/kyheader.h
View file @
0a162305
...
...
@@ -11,11 +11,8 @@
#include <cmath>
#include <time.h>
#include <fstream>
#include <random>
//#include <atlstr.h>
//#include <atltypes.h>
#include <omp.h>
#include <strstream>
// TODO: reference additional headers your program requires here
...
...
@@ -77,13 +74,13 @@ static inline int findFromList(const T &word, const vector<T> &strList) {
//cout << "Size w " << word.size() << " Size L "<< strList[i].size() << endl;
}
auto
it
=
std
::
find
(
strList
.
begin
(),
strList
.
end
(),
word
);
vector
<
String
>::
iterator
it
=
std
::
find
(
strList
.
begin
(),
strList
.
end
(),
word
);
if
(
it
==
strList
.
end
())
{
return
-
1
;
}
else
{
auto
index
=
std
::
distance
(
strList
.
begin
(),
it
);
vector
<
String
>::
iterator
index
=
std
::
distance
(
strList
.
begin
(),
it
);
//cout << "index" <<" "<< index << endl;
return
index
;
}
...
...
modules/saliency/src/motionSaliencyPBAS.cpp
View file @
0a162305
...
...
@@ -77,17 +77,17 @@ MotionSaliencyPBAS::~MotionSaliencyPBAS()
}
void
MotionSaliencyPBAS
::
read
(
const
cv
::
FileNode
&
fn
)
void
MotionSaliencyPBAS
::
read
(
const
cv
::
FileNode
&
/*fn*/
)
{
//params.read( fn );
}
void
MotionSaliencyPBAS
::
write
(
cv
::
FileStorage
&
fs
)
const
void
MotionSaliencyPBAS
::
write
(
cv
::
FileStorage
&
/*fs*/
)
const
{
//params.write( fs );
}
bool
MotionSaliencyPBAS
::
computeSaliencyImpl
(
const
InputArray
src
,
OutputArray
dst
)
bool
MotionSaliencyPBAS
::
computeSaliencyImpl
(
const
InputArray
/*src*/
,
OutputArray
/*dst*/
)
{
return
true
;
...
...
modules/saliency/src/objectnessBING.cpp
View file @
0a162305
...
...
@@ -75,21 +75,21 @@ 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 = "/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() );
}
void
ObjectnessBING
::
set
_modelName
(
string
n
ame
)
void
ObjectnessBING
::
set
ModelName
(
string
modelN
ame
)
{
_modelName
=
name
+
string
(
format
(
"
ObjNessB%gW%d%s"
,
_base
,
_W
,
_clrName
[
_Clr
]
).
c_str
()
);
_modelName
=
modelName
+
string
(
format
(
"/
ObjNessB%gW%d%s"
,
_base
,
_W
,
_clrName
[
_Clr
]
).
c_str
()
);
}
void
ObjectnessBING
::
set
_bb
ResDir
(
string
dir
)
void
ObjectnessBING
::
set
BB
ResDir
(
string
dir
)
{
_
modelName
=
dir
+
string
(
format
(
"BBoxesB%gW%d%s/"
,
_base
,
_W
,
_clrName
[
_Clr
]
).
c_str
()
);
_
bbResDir
=
dir
+
string
(
format
(
"BBoxesB%gW%d%s/"
,
_base
,
_W
,
_clrName
[
_Clr
]
).
c_str
()
);
}
int
ObjectnessBING
::
loadTrainedModel
(
string
modelName
)
// Return -1, 0, or 1 if partial, none, or all loaded
...
...
@@ -98,6 +98,8 @@ int ObjectnessBING::loadTrainedModel( string modelName ) // Return -1, 0, or 1
modelName
=
_modelName
;
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
)
);
...
...
modules/saliency/src/saliency.cpp
View file @
0a162305
...
...
@@ -74,7 +74,7 @@ Ptr<Saliency> Saliency::create( const String& saliencyType )
//return Ptr<Saliency>();
}
bool
Saliency
::
computeSaliency
(
const
InputArray
&
image
,
OutputArray
&
saliencyMap
)
bool
Saliency
::
computeSaliency
(
const
InputArray
image
,
OutputArray
saliencyMap
)
{
if
(
image
.
empty
()
)
return
false
;
...
...
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