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
a76954ad
Commit
a76954ad
authored
Jun 18, 2014
by
jaco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BING update2
parent
f28bdc3d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
25 deletions
+56
-25
saliencySpecializedClasses.hpp
...y/include/opencv2/saliency/saliencySpecializedClasses.hpp
+5
-3
computeSaliency.cpp
modules/saliency/samples/computeSaliency.cpp
+13
-1
ValStructVec.h
modules/saliency/src/ValStructVec.h
+2
-2
objectnessBING.cpp
modules/saliency/src/objectnessBING.cpp
+36
-19
No files found.
modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp
View file @
a76954ad
...
...
@@ -144,8 +144,8 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
ObjectnessBING
();
~
ObjectnessBING
();
void
read
(
const
FileNode
&
fn
);
void
write
(
FileStorage
&
fs
)
const
;
void
read
();
void
write
()
const
;
// Load trained model.
int
loadTrainedModel
(
std
::
string
modelName
=
""
);
// Return -1, 0, or 1 if partial, none, or all loaded
...
...
@@ -158,6 +158,8 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
vector
<
float
>
getobjectnessValues
();
void
setColorSpace
(
int
clr
=
MAXBGR
);
void
set_modelName
(
string
name
);
void
set_bbResDir
(
string
dir
);
// Read matrix from binary file
static
bool
matRead
(
const
std
::
string
&
filename
,
Mat
&
M
);
...
...
@@ -182,7 +184,7 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
//TODO Probably remove this parameters
//DataSetVOC &_voc; // The dataset for training, testing
std
::
string
_modelName
,
_
trainDirSI
,
_
bbResDir
;
std
::
string
_modelName
,
_bbResDir
;
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
...
...
modules/saliency/samples/computeSaliency.cpp
View file @
a76954ad
...
...
@@ -70,6 +70,7 @@ int main( int argc, char** argv )
frame
.
copyTo
(
image
);
if
(
saliency_algorithm
.
find
(
"SPECTRAL_RESIDUAL"
)
==
0
)
{
Mat
saliencyMap
;
...
...
@@ -89,11 +90,22 @@ 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);
//bing->set_modelName("home/puja/src/opencv_contrib/modules/saliency/src/ObjectnessTrainedModel/");
//bing->set_bbResDir("/home/puja/src/opencv_contrib/modules/saliency/src/ObjectnessTrainedModel/");
if
(
saliencyAlgorithm
->
computeSaliency
(
image
,
saliencyMap
)
)
{
std
::
cout
<<
"-----------------OBJECTNESS-----------"
<<
std
::
endl
;
std
::
cout
<<
"OBJ
BB
VECTOR SIZE"
<<
saliencyMap
.
size
()
<<
std
::
endl
;
std
::
cout
<<
"OBJ
ECTNESS 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/ValStructVec.h
View file @
a76954ad
...
...
@@ -72,8 +72,8 @@ struct ValStructVec
template
<
typename
VT
,
typename
ST
>
void
ValStructVec
<
VT
,
ST
>::
append
(
const
ValStructVec
<
VT
,
ST
>
&
newVals
,
int
startV
)
{
int
sz
=
newVals
.
size
();
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
int
newValsSize
=
newVals
.
size
();
for
(
int
i
=
0
;
i
<
newValsSize
;
i
++
)
pushBack
(
(
float
)
(
(
i
+
300
)
*
startV
)
/*newVals(i)*/
,
newVals
[
i
]
);
}
...
...
modules/saliency/src/objectnessBING.cpp
View file @
a76954ad
...
...
@@ -77,8 +77,19 @@ 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
()
);
// _trainDirSI = _voc.localDir + string(format("TrainS1B%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
());
_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
name
)
{
_modelName
=
name
+
string
(
format
(
"ObjNessB%gW%d%s"
,
_base
,
_W
,
_clrName
[
_Clr
]
).
c_str
()
);
}
void
ObjectnessBING
::
set_bbResDir
(
string
dir
)
{
_modelName
=
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
...
...
@@ -388,17 +399,23 @@ void ObjectnessBING::getObjBndBoxesForSingleImage( Mat img, ValStructVec<float,
printf
(
"Average time for predicting an image (%s) is %gs
\n
"
,
_clrName
[
_Clr
],
tm
.
TimeInSeconds
()
);
}
/*CmFile::MkDir(_bbResDir);
//Write on file the total number and the list of rectangles returned by objectess, one for each row.
CmFile
::
MkDir
(
_bbResDir
);
CStr
fName
=
_bbResDir
+
"bb"
;
//vector<Vec4i> sortedBB = finalBoxes.getSortedStructVal();
FILE *f = fopen( _S( fName + ".txt" ), "w" );
fprintf( f, "%d\n", finalBoxes.size() );
for ( size_t k = 0; k < finalBoxes.size(); k++ ){
//fprintf(f, "%g, %s\n", finalBoxes(k), _S(strVec4i(finalBoxes[k])));
//fprintf(f, "%g, %s\n", finalBoxes(k), finalBoxes(k)[0],finalBoxes(k)[1],finalBoxes(k)[2],finalBoxes(k)[3]);
vector
<
Vec4i
>
sortedBB
=
finalBoxes
.
getSortedStructVal
();
std
::
ofstream
ofs
;
ofs
.
open
(
_S
(
fName
+
".txt"
),
std
::
ofstream
::
out
);
stringstream
dim
;
dim
<<
sortedBB
.
size
();
ofs
<<
dim
.
str
()
<<
"
\n
"
;
for
(
size_t
k
=
0
;
k
<
sortedBB
.
size
();
k
++
)
{
stringstream
str
;
str
<<
sortedBB
[
k
][
0
]
<<
" "
<<
sortedBB
[
k
][
1
]
<<
" "
<<
sortedBB
[
k
][
2
]
<<
" "
<<
sortedBB
[
k
][
3
]
<<
"
\n
"
;
ofs
<<
str
.
str
();
}
fclose( f ); */
ofs
.
close
();
}
struct
MatchPathSeparator
...
...
@@ -454,12 +471,12 @@ vector<float> ObjectnessBING::getobjectnessValues()
return
objectnessValues
;
}
void
ObjectnessBING
::
read
(
const
cv
::
FileNode
&
fn
)
void
ObjectnessBING
::
read
()
{
}
void
ObjectnessBING
::
write
(
cv
::
FileStorage
&
fs
)
const
void
ObjectnessBING
::
write
()
const
{
}
...
...
@@ -472,15 +489,15 @@ bool ObjectnessBING::computeSaliencyImpl( const InputArray image, OutputArray ob
// List of rectangles returned by objectess function in ascending order.
// At the top there are the rectangles with lower values of objectness, ie more
// likely to have objects in them.
//vector<Vec4i>
vector
<
Vec4i
>
sortedBB
=
finalBoxes
.
getSortedStructVal
();
objBoundingBox
.
create
(
1
,
sortedBB
.
size
(),
CV_MAKETYPE
(
CV_32S
,
CV_MAT_CN
(
objBoundingBox
.
type
())
)
);
Mat
obj
=
objBoundingBox
.
getMat
();
//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];
for
(
uint
i
=
0
;
i
<
sortedBB
.
size
();
i
++
)
obj
.
at
<
Vec4i
>
(
i
)
=
sortedBB
[
i
];
Mat
(
sortedBB
).
copyTo
(
objBoundingBox
);
// List of the rectangles' objectness value
unsigned
long
int
valIdxesSize
=
finalBoxes
.
getvalIdxes
().
size
();
...
...
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