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
861d7bcf
Commit
861d7bcf
authored
Jul 30, 2014
by
jaco
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip windows byte compile error fixing
parent
5fc5b4f8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
190 deletions
+18
-190
kyheader.h
modules/saliency/include/opencv2/saliency/kyheader.h
+1
-1
CmFile.cpp
modules/saliency/src/BING/CmFile.cpp
+0
-109
CmFile.h
modules/saliency/src/BING/CmFile.h
+0
-63
FilterTIG.cpp
modules/saliency/src/BING/FilterTIG.cpp
+8
-8
objectnessBING.cpp
modules/saliency/src/BING/objectnessBING.cpp
+9
-9
No files found.
modules/saliency/include/opencv2/saliency/kyheader.h
View file @
861d7bcf
...
...
@@ -79,7 +79,7 @@ typedef unsigned short WORD;
typedef
unsigned
int
UNINT32
;
typedef
bool
BOOL
;
typedef
void
*
HANDLE
;
typedef
unsigned
char
byte
;
typedef
unsigned
char
byte
_
;
#endif
typedef
std
::
vector
<
int
>
vecI
;
...
...
modules/saliency/src/BING/CmFile.cpp
View file @
861d7bcf
...
...
@@ -41,91 +41,7 @@
#include "CmFile.h"
// Get image names from a wildcard. Eg: GetNames("D:\\*.jpg", imgNames);
int
CmFile
::
GetNames
(
CStr
&
_nameW
,
vecS
&
_names
,
std
::
string
_dir
)
{
_dir
=
GetFolder
(
_nameW
);
_names
.
clear
();
DIR
*
dir
;
struct
dirent
*
ent
;
if
(
(
dir
=
opendir
(
_dir
.
c_str
()
)
)
!=
NULL
)
{
//print all the files and directories within directory
while
(
(
ent
=
readdir
(
dir
)
)
!=
NULL
)
{
if
(
ent
->
d_name
[
0
]
==
'.'
)
continue
;
if
(
ent
->
d_type
==
4
)
continue
;
_names
.
push_back
(
ent
->
d_name
);
}
closedir
(
dir
);
}
else
{
perror
(
""
);
return
EXIT_FAILURE
;
}
return
(
int
)
_names
.
size
();
}
int
CmFile
::
GetSubFolders
(
CStr
&
folder
,
vecS
&
subFolders
)
{
subFolders
.
clear
();
std
::
string
nameWC
=
GetFolder
(
folder
);
//folder + "/*";
DIR
*
dir
;
struct
dirent
*
ent
;
if
(
(
dir
=
opendir
(
nameWC
.
c_str
()
)
)
!=
NULL
)
{
while
(
(
ent
=
readdir
(
dir
)
)
!=
NULL
)
{
if
(
ent
->
d_name
[
0
]
==
'.'
)
continue
;
if
(
ent
->
d_type
==
4
)
{
subFolders
.
push_back
(
ent
->
d_name
);
}
}
closedir
(
dir
);
}
else
{
perror
(
""
);
return
EXIT_FAILURE
;
}
return
(
int
)
subFolders
.
size
();
}
int
CmFile
::
GetNames
(
CStr
&
rootFolder
,
CStr
&
fileW
,
vecS
&
names
)
{
GetNames
(
rootFolder
+
fileW
,
names
);
vecS
subFolders
,
tmpNames
;
int
subNum
=
CmFile
::
GetSubFolders
(
rootFolder
,
subFolders
);
//
for
(
int
i
=
0
;
i
<
subNum
;
i
++
)
{
subFolders
[
i
]
+=
"/"
;
int
subNum_
=
GetNames
(
rootFolder
+
subFolders
[
i
],
fileW
,
tmpNames
);
for
(
int
j
=
0
;
j
<
subNum_
;
j
++
)
names
.
push_back
(
subFolders
[
i
]
+
tmpNames
[
j
]
);
}
return
(
int
)
names
.
size
();
}
int
CmFile
::
GetNamesNE
(
CStr
&
nameWC
,
vecS
&
names
,
std
::
string
dir
,
std
::
string
ext
)
{
int
fNum
=
GetNames
(
nameWC
,
names
,
dir
);
ext
=
GetExtention
(
nameWC
);
for
(
int
i
=
0
;
i
<
fNum
;
i
++
)
names
[
i
]
=
GetNameNE
(
names
[
i
]
);
return
fNum
;
}
int
CmFile
::
GetNamesNE
(
CStr
&
rootFolder
,
CStr
&
fileW
,
vecS
&
names
)
{
int
fNum
=
GetNames
(
rootFolder
,
fileW
,
names
);
int
extS
=
GetExtention
(
fileW
).
size
();
for
(
int
i
=
0
;
i
<
fNum
;
i
++
)
names
[
i
].
resize
(
names
[
i
].
size
()
-
extS
);
return
fNum
;
}
bool
CmFile
::
MkDir
(
CStr
&
_path
)
{
if
(
_path
.
size
()
==
0
)
...
...
@@ -156,28 +72,3 @@ bool CmFile::MkDir( CStr &_path )
return
mkdir
(
_S
(
_path
),
0
);
#endif
}
void
CmFile
::
loadStrList
(
CStr
&
fName
,
vecS
&
strs
,
bool
flag
)
{
std
::
ifstream
fIn
(
fName
.
c_str
()
);
std
::
string
line
;
//vecS strs;
while
(
getline
(
fIn
,
line
)
)
{
unsigned
sz
=
line
.
size
();
if
(
flag
)
line
.
resize
(
sz
-
1
);
printf
(
"%s
\n
"
,
_S
(
line
)
);
strs
.
push_back
(
line
);
}
//return strs;
}
bool
CmFile
::
writeStrList
(
CStr
&
fName
,
const
vecS
&
strs
)
{
FILE
*
f
=
fopen
(
_S
(
fName
),
"w"
);
if
(
f
==
NULL
)
return
false
;
for
(
size_t
i
=
0
;
i
<
strs
.
size
();
i
++
)
fprintf
(
f
,
"%s
\n
"
,
_S
(
strs
[
i
]
)
);
fclose
(
f
);
return
true
;
}
modules/saliency/src/BING/CmFile.h
View file @
861d7bcf
...
...
@@ -53,68 +53,5 @@
struct
CmFile
{
static
inline
std
::
string
GetFolder
(
CStr
&
path
);
static
inline
std
::
string
GetName
(
CStr
&
path
);
static
inline
std
::
string
GetNameNE
(
CStr
&
path
);
static
inline
std
::
string
GetPathNE
(
CStr
&
path
);
// Get file names from a wildcard. Eg: GetNames("D:\\*.jpg", imgNames);
static
int
GetNames
(
CStr
&
nameW
,
vecS
&
names
,
std
::
string
_dir
=
std
::
string
());
static
int
GetNames
(
CStr
&
rootFolder
,
CStr
&
fileW
,
vecS
&
names
);
static
int
GetNamesNE
(
CStr
&
nameWC
,
vecS
&
names
,
std
::
string
dir
=
std
::
string
(),
std
::
string
ext
=
std
::
string
());
static
int
GetNamesNE
(
CStr
&
rootFolder
,
CStr
&
fileW
,
vecS
&
names
);
static
inline
std
::
string
GetExtention
(
CStr
name
);
static
int
GetSubFolders
(
CStr
&
folder
,
vecS
&
subFolders
);
static
inline
std
::
string
GetWkDir
();
static
bool
MkDir
(
CStr
&
path
);
static
void
loadStrList
(
CStr
&
fName
,
vecS
&
strs
,
bool
flag
=
false
);
static
bool
writeStrList
(
CStr
&
fName
,
const
vecS
&
strs
);
};
/************************************************************************/
/* Implementation of inline functions */
/************************************************************************/
std
::
string
CmFile
::
GetFolder
(
CStr
&
path
)
{
return
path
.
substr
(
0
,
path
.
find_last_of
(
"
\\
/"
)
+
1
);
}
std
::
string
CmFile
::
GetName
(
CStr
&
path
)
{
int
start
=
path
.
find_last_of
(
"
\\
/"
)
+
1
;
int
end
=
path
.
find_last_not_of
(
' '
)
+
1
;
return
path
.
substr
(
start
,
end
-
start
);
}
std
::
string
CmFile
::
GetNameNE
(
CStr
&
path
)
{
int
start
=
path
.
find_last_of
(
"
\\
/"
)
+
1
;
int
end
=
path
.
find_last_of
(
'.'
);
if
(
end
>=
0
)
return
path
.
substr
(
start
,
end
-
start
);
else
return
path
.
substr
(
start
,
path
.
find_last_not_of
(
' '
)
+
1
-
start
);
}
std
::
string
CmFile
::
GetPathNE
(
CStr
&
path
)
{
int
end
=
path
.
find_last_of
(
'.'
);
if
(
end
>=
0
)
return
path
.
substr
(
0
,
end
);
else
return
path
.
substr
(
0
,
path
.
find_last_not_of
(
' '
)
+
1
);
}
std
::
string
CmFile
::
GetExtention
(
CStr
name
)
{
return
name
.
substr
(
name
.
find_last_of
(
'.'
));
}
/************************************************************************/
/* Implementations */
/************************************************************************/
modules/saliency/src/BING/FilterTIG.cpp
View file @
861d7bcf
...
...
@@ -88,12 +88,12 @@ Mat FilterTIG::matchTemplate( const Mat &mag1u )
const
Size
sz
(
W
+
1
,
H
+
1
);
// Expand original size to avoid dealing with boundary conditions
Mat_
<
INT64
>
Tig1
=
Mat_
<
INT64
>::
zeros
(
sz
),
Tig2
=
Mat_
<
INT64
>::
zeros
(
sz
);
Mat_
<
INT64
>
Tig4
=
Mat_
<
INT64
>::
zeros
(
sz
),
Tig8
=
Mat_
<
INT64
>::
zeros
(
sz
);
Mat_
<
byte
>
Row1
=
Mat_
<
byte
>::
zeros
(
sz
),
Row2
=
Mat_
<
byte
>::
zeros
(
sz
);
Mat_
<
byte
>
Row4
=
Mat_
<
byte
>::
zeros
(
sz
),
Row8
=
Mat_
<
byte
>::
zeros
(
sz
);
Mat_
<
byte
_
>
Row1
=
Mat_
<
byte_
>::
zeros
(
sz
),
Row2
=
Mat_
<
byte_
>::
zeros
(
sz
);
Mat_
<
byte
_
>
Row4
=
Mat_
<
byte_
>::
zeros
(
sz
),
Row8
=
Mat_
<
byte_
>::
zeros
(
sz
);
Mat_
<
float
>
scores
(
sz
);
for
(
int
y
=
1
;
y
<=
H
;
y
++
)
{
const
byte
*
G
=
mag1u
.
ptr
<
byte
>
(
y
-
1
);
const
byte
_
*
G
=
mag1u
.
ptr
<
byte_
>
(
y
-
1
);
INT64
*
T1
=
Tig1
.
ptr
<
INT64
>
(
y
);
// Binary TIG of current row
INT64
*
T2
=
Tig2
.
ptr
<
INT64
>
(
y
);
INT64
*
T4
=
Tig4
.
ptr
<
INT64
>
(
y
);
...
...
@@ -102,14 +102,14 @@ Mat FilterTIG::matchTemplate( const Mat &mag1u )
INT64
*
Tu2
=
Tig2
.
ptr
<
INT64
>
(
y
-
1
);
INT64
*
Tu4
=
Tig4
.
ptr
<
INT64
>
(
y
-
1
);
INT64
*
Tu8
=
Tig8
.
ptr
<
INT64
>
(
y
-
1
);
byte
*
R1
=
Row1
.
ptr
<
byte
>
(
y
);
byte
*
R2
=
Row2
.
ptr
<
byte
>
(
y
);
byte
*
R4
=
Row4
.
ptr
<
byte
>
(
y
);
byte
*
R8
=
Row8
.
ptr
<
byte
>
(
y
);
byte
_
*
R1
=
Row1
.
ptr
<
byte_
>
(
y
);
byte
_
*
R2
=
Row2
.
ptr
<
byte_
>
(
y
);
byte
_
*
R4
=
Row4
.
ptr
<
byte_
>
(
y
);
byte
_
*
R8
=
Row8
.
ptr
<
byte_
>
(
y
);
float
*
s
=
scores
.
ptr
<
float
>
(
y
);
for
(
int
x
=
1
;
x
<=
W
;
x
++
)
{
byte
g
=
G
[
x
-
1
];
byte
_
g
=
G
[
x
-
1
];
R1
[
x
]
=
(
R1
[
x
-
1
]
<<
1
)
|
(
(
g
>>
4
)
&
1
);
R2
[
x
]
=
(
R2
[
x
-
1
]
<<
1
)
|
(
(
g
>>
5
)
&
1
);
R4
[
x
]
=
(
R4
[
x
-
1
]
<<
1
)
|
(
(
g
>>
6
)
&
1
);
...
...
modules/saliency/src/BING/objectnessBING.cpp
View file @
861d7bcf
...
...
@@ -230,7 +230,7 @@ void ObjectnessBING::nonMaxSup( CMat &matchCost1f, ValStructVec<float, Point> &m
for
(
int
i
=
0
;
i
<
valPnt
.
size
();
i
++
)
{
Point
&
pnt
=
valPnt
[
i
];
if
(
isMax1u
.
at
<
byte
>
(
pnt
)
)
if
(
isMax1u
.
at
<
byte
_
>
(
pnt
)
)
{
matchCost
.
pushBack
(
valPnt
(
i
),
pnt
);
for
(
int
dy
=
-
NSS
;
dy
<=
NSS
;
dy
++
)
...
...
@@ -239,7 +239,7 @@ void ObjectnessBING::nonMaxSup( CMat &matchCost1f, ValStructVec<float, Point> &m
Point
neighbor
=
pnt
+
Point
(
dx
,
dy
);
if
(
!
CHK_IND
(
neighbor
)
)
continue
;
isMax1u
.
at
<
byte
>
(
neighbor
)
=
false
;
isMax1u
.
at
<
byte
_
>
(
neighbor
)
=
false
;
}
}
if
(
matchCost
.
size
()
>=
maxPoint
)
...
...
@@ -311,24 +311,24 @@ void ObjectnessBING::gradientGray( CMat &bgr3u, Mat &mag1u )
// Left/right most column Ix
for
(
int
y
=
0
;
y
<
H
;
y
++
)
{
Ix
.
at
<
int
>
(
y
,
0
)
=
abs
(
g1u
.
at
<
byte
>
(
y
,
1
)
-
g1u
.
at
<
byte
>
(
y
,
0
)
)
*
2
;
Ix
.
at
<
int
>
(
y
,
W
-
1
)
=
abs
(
g1u
.
at
<
byte
>
(
y
,
W
-
1
)
-
g1u
.
at
<
byte
>
(
y
,
W
-
2
)
)
*
2
;
Ix
.
at
<
int
>
(
y
,
0
)
=
abs
(
g1u
.
at
<
byte
_
>
(
y
,
1
)
-
g1u
.
at
<
byte_
>
(
y
,
0
)
)
*
2
;
Ix
.
at
<
int
>
(
y
,
W
-
1
)
=
abs
(
g1u
.
at
<
byte
_
>
(
y
,
W
-
1
)
-
g1u
.
at
<
byte_
>
(
y
,
W
-
2
)
)
*
2
;
}
// Top/bottom most column Iy
for
(
int
x
=
0
;
x
<
W
;
x
++
)
{
Iy
.
at
<
int
>
(
0
,
x
)
=
abs
(
g1u
.
at
<
byte
>
(
1
,
x
)
-
g1u
.
at
<
byte
>
(
0
,
x
)
)
*
2
;
Iy
.
at
<
int
>
(
H
-
1
,
x
)
=
abs
(
g1u
.
at
<
byte
>
(
H
-
1
,
x
)
-
g1u
.
at
<
byte
>
(
H
-
2
,
x
)
)
*
2
;
Iy
.
at
<
int
>
(
0
,
x
)
=
abs
(
g1u
.
at
<
byte
_
>
(
1
,
x
)
-
g1u
.
at
<
byte_
>
(
0
,
x
)
)
*
2
;
Iy
.
at
<
int
>
(
H
-
1
,
x
)
=
abs
(
g1u
.
at
<
byte
_
>
(
H
-
1
,
x
)
-
g1u
.
at
<
byte_
>
(
H
-
2
,
x
)
)
*
2
;
}
// Find the gradient for inner regions
for
(
int
y
=
0
;
y
<
H
;
y
++
)
for
(
int
x
=
1
;
x
<
W
-
1
;
x
++
)
Ix
.
at
<
int
>
(
y
,
x
)
=
abs
(
g1u
.
at
<
byte
>
(
y
,
x
+
1
)
-
g1u
.
at
<
byte
>
(
y
,
x
-
1
)
);
Ix
.
at
<
int
>
(
y
,
x
)
=
abs
(
g1u
.
at
<
byte
_
>
(
y
,
x
+
1
)
-
g1u
.
at
<
byte_
>
(
y
,
x
-
1
)
);
for
(
int
y
=
1
;
y
<
H
-
1
;
y
++
)
for
(
int
x
=
0
;
x
<
W
;
x
++
)
Iy
.
at
<
int
>
(
y
,
x
)
=
abs
(
g1u
.
at
<
byte
>
(
y
+
1
,
x
)
-
g1u
.
at
<
byte
>
(
y
-
1
,
x
)
);
Iy
.
at
<
int
>
(
y
,
x
)
=
abs
(
g1u
.
at
<
byte
_
>
(
y
+
1
,
x
)
-
g1u
.
at
<
byte_
>
(
y
-
1
,
x
)
);
gradientXY
(
Ix
,
Iy
,
mag1u
);
}
...
...
@@ -372,7 +372,7 @@ void ObjectnessBING::gradientXY( CMat &x1i, CMat &y1i, Mat &mag1u )
for
(
int
r
=
0
;
r
<
H
;
r
++
)
{
const
int
*
x
=
x1i
.
ptr
<
int
>
(
r
),
*
y
=
y1i
.
ptr
<
int
>
(
r
);
byte
*
m
=
mag1u
.
ptr
<
byte
>
(
r
);
byte
_
*
m
=
mag1u
.
ptr
<
byte_
>
(
r
);
for
(
int
c
=
0
;
c
<
W
;
c
++
)
m
[
c
]
=
min
(
x
[
c
]
+
y
[
c
],
255
);
//((int)sqrt(sqr(x[c]) + sqr(y[c])), 255);
}
...
...
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