Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
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
Commits
a486aafe
Commit
a486aafe
authored
Mar 09, 2013
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add dlobbing under *nix
parent
6569a585
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
171 additions
and
0 deletions
+171
-0
core.hpp
modules/core/include/opencv2/core/core.hpp
+2
-0
glob.cpp
modules/core/src/glob.cpp
+152
-0
test_io.cpp
modules/core/test/test_io.cpp
+17
-0
No files found.
modules/core/include/opencv2/core/core.hpp
View file @
a486aafe
...
...
@@ -108,6 +108,8 @@ template<typename _Tp, size_t fixed_size = 1024/sizeof(_Tp)+8> class CV_EXPORTS
CV_EXPORTS
std
::
string
format
(
const
char
*
fmt
,
...
);
CV_EXPORTS
std
::
string
tempfile
(
const
char
*
suffix
CV_DEFAULT
(
0
));
CV_EXPORTS
void
glob
(
std
::
string
pattern
,
std
::
vector
<
std
::
string
>&
result
,
bool
recursive
=
false
);
// matrix decomposition types
enum
{
DECOMP_LU
=
0
,
DECOMP_SVD
=
1
,
DECOMP_EIG
=
2
,
DECOMP_CHOLESKY
=
3
,
DECOMP_QR
=
4
,
DECOMP_NORMAL
=
16
};
enum
{
NORM_INF
=
1
,
NORM_L1
=
2
,
NORM_L2
=
4
,
NORM_L2SQR
=
5
,
NORM_HAMMING
=
6
,
NORM_HAMMING2
=
7
,
NORM_TYPE_MASK
=
7
,
NORM_RELATIVE
=
8
,
NORM_MINMAX
=
32
};
...
...
modules/core/src/glob.cpp
0 → 100644
View file @
a486aafe
#include "precomp.hpp"
#if defined WIN32 || defined _WIN32 || defined WINCE
# include <windows.h>
const
char
dir_separators
[]
=
"/
\\
"
;
const
char
native_separator
=
'\\'
;
#else
# include <dirent.h>
const
char
dir_separators
[]
=
"/"
;
const
char
native_separator
=
'/'
;
#endif
#ifndef _WIN32_WCE
# include <sys/stat.h>
#endif
static
bool
isDir
(
std
::
string
path
)
{
#ifndef _WIN32_WCE
struct
stat
stat_buf
;
stat
(
path
.
c_str
(),
&
stat_buf
);
int
is_dir
=
S_ISDIR
(
stat_buf
.
st_mode
);
return
is_dir
!=
0
;
#else
/* unsupported */
return
false
;
#endif
}
static
bool
wildcmp
(
const
char
*
string
,
const
char
*
wild
)
{
// Based on wildcmp written by Jack Handy - <A href="mailto:jakkhandy@hotmail.com">jakkhandy@hotmail.com</A>
const
char
*
cp
=
0
,
*
mp
=
0
;
while
((
*
string
)
&&
(
*
wild
!=
'*'
))
{
if
((
*
wild
!=
*
string
)
&&
(
*
wild
!=
'?'
))
{
return
false
;
}
wild
++
;
string
++
;
}
while
(
*
string
)
{
if
(
*
wild
==
'*'
)
{
if
(
!*++
wild
)
{
return
true
;
}
mp
=
wild
;
cp
=
string
+
1
;
}
else
if
((
*
wild
==
*
string
)
||
(
*
wild
==
'?'
))
{
wild
++
;
string
++
;
}
else
{
wild
=
mp
;
string
=
cp
++
;
}
}
while
(
*
wild
==
'*'
)
{
wild
++
;
}
return
*
wild
==
0
;
}
static
void
glob_rec
(
const
std
::
string
&
directory
,
const
std
::
string
&
wildchart
,
std
::
vector
<
std
::
string
>&
result
,
bool
recursive
)
{
DIR
*
dir
;
struct
dirent
*
ent
;
if
((
dir
=
opendir
(
directory
.
c_str
()))
!=
0
)
{
/* find all the files and directories within directory */
try
{
while
((
ent
=
readdir
(
dir
))
!=
0
)
{
const
char
*
name
=
ent
->
d_name
;
if
((
name
[
0
]
==
0
)
||
(
name
[
0
]
==
'.'
&&
name
[
1
]
==
0
)
||
(
name
[
0
]
==
'.'
&&
name
[
1
]
==
'.'
&&
name
[
2
]
==
0
))
continue
;
std
::
string
path
=
directory
+
native_separator
+
name
;
if
(
isDir
(
path
))
{
if
(
recursive
)
glob_rec
(
path
,
wildchart
,
result
,
recursive
);
}
else
{
if
(
wildchart
.
empty
()
||
wildcmp
(
name
,
wildchart
.
c_str
()))
result
.
push_back
(
path
);
}
}
}
catch
(...)
{
closedir
(
dir
);
throw
;
}
closedir
(
dir
);
}
else
CV_Error
(
CV_StsObjectNotFound
,
"could not open directory"
);
}
void
cv
::
glob
(
std
::
string
pattern
,
std
::
vector
<
std
::
string
>&
result
,
bool
recursive
)
{
result
.
clear
();
std
::
string
path
,
wildchart
;
if
(
isDir
(
pattern
))
{
if
(
strchr
(
dir_separators
,
pattern
[
pattern
.
size
()
-
1
])
!=
0
)
{
path
=
pattern
.
substr
(
0
,
pattern
.
size
()
-
1
);
}
else
{
path
=
pattern
;
}
}
else
{
size_t
pos
=
pattern
.
find_last_of
(
dir_separators
);
if
(
pos
==
std
::
string
::
npos
)
{
wildchart
=
pattern
;
path
=
"."
;
}
else
{
path
=
pattern
.
substr
(
0
,
pos
);
wildchart
=
pattern
.
substr
(
pos
+
1
);
}
}
glob_rec
(
path
,
wildchart
,
result
,
recursive
);
}
\ No newline at end of file
modules/core/test/test_io.cpp
View file @
a486aafe
...
...
@@ -454,3 +454,19 @@ protected:
TEST(Core_InputOutput, huge) { CV_BigMatrixIOTest test; test.safe_run(); }
*/
TEST
(
Core_globbing
,
accurasy
)
{
std
::
string
patternLena
=
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"lena*.*"
;
std
::
string
patternLenaPng
=
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
"lena.png"
;
std
::
vector
<
std
::
string
>
lenas
,
pngLenas
;
cv
::
glob
(
patternLena
,
lenas
,
true
);
cv
::
glob
(
patternLenaPng
,
pngLenas
,
true
);
ASSERT_GT
(
lenas
.
size
(),
pngLenas
.
size
());
for
(
size_t
i
=
0
;
i
<
pngLenas
.
size
();
++
i
)
{
ASSERT_NE
(
std
::
find
(
lenas
.
begin
(),
lenas
.
end
(),
pngLenas
[
i
]),
lenas
.
end
());
}
}
\ No newline at end of file
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