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
af730e4b
Commit
af730e4b
authored
Oct 04, 2011
by
Andrey Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added class Directory
parent
36967575
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
0 deletions
+141
-0
contrib.hpp
modules/contrib/include/opencv2/contrib/contrib.hpp
+8
-0
inputoutput.cpp
modules/contrib/src/inputoutput.cpp
+133
-0
No files found.
modules/contrib/include/opencv2/contrib/contrib.hpp
View file @
af730e4b
...
...
@@ -605,6 +605,14 @@ namespace cv
};
CV_EXPORTS
void
polyfit
(
const
Mat
&
srcx
,
const
Mat
&
srcy
,
Mat
&
dst
,
int
order
);
class
CV_EXPORTS
Directory
{
public
:
static
std
::
vector
<
std
::
string
>
GetListFiles
(
const
string
&
directoryName
,
bool
addPath
=
true
);
static
std
::
vector
<
std
::
string
>
GetListFilesR
(
const
string
&
directoryName
,
bool
addPath
=
true
);
static
std
::
vector
<
std
::
string
>
GetListFolders
(
const
string
&
directoryName
,
bool
addPath
=
true
);
};
}
#include "opencv2/contrib/retina.hpp"
...
...
modules/contrib/src/inputoutput.cpp
0 → 100644
View file @
af730e4b
#include "opencv2/contrib/contrib.hpp"
#ifdef WIN32
#include <windows.h>
#include <tchar.h>
#else
#include <direct.h>
#endif
namespace
cv
{
std
::
vector
<
std
::
string
>
Directory
::
GetListFiles
(
const
string
&
directoryName
,
bool
addPath
)
{
std
::
vector
<
std
::
string
>
list
;
list
.
clear
();
std
::
string
path
=
directoryName
+
"/*"
;
#ifdef WIN32
WIN32_FIND_DATA
FindFileData
;
HANDLE
hFind
;
hFind
=
FindFirstFile
((
LPCSTR
)
path
.
c_str
(),
&
FindFileData
);
if
(
hFind
==
INVALID_HANDLE_VALUE
)
{
return
list
;
}
else
{
do
{
if
(
FindFileData
.
dwFileAttributes
==
FILE_ATTRIBUTE_NORMAL
||
FindFileData
.
dwFileAttributes
==
FILE_ATTRIBUTE_ARCHIVE
||
FindFileData
.
dwFileAttributes
==
FILE_ATTRIBUTE_HIDDEN
||
FindFileData
.
dwFileAttributes
==
FILE_ATTRIBUTE_SYSTEM
||
FindFileData
.
dwFileAttributes
==
FILE_ATTRIBUTE_READONLY
)
{
if
(
addPath
)
list
.
push_back
(
directoryName
+
"/"
+
FindFileData
.
cFileName
);
else
list
.
push_back
(
FindFileData
.
cFileName
);
}
}
while
(
FindNextFile
(
hFind
,
&
FindFileData
));
FindClose
(
hFind
);
}
#else
DIR
*
dp
;
struct
dirent
*
dirp
;
if
((
dp
=
opendir
(
directoryName
.
c_str
()))
==
NULL
)
{
return
list
;
}
while
((
dirp
=
readdir
(
dp
))
!=
NULL
)
{
if
(
dirp
->
d_type
==
DT_REG
)
list
.
push_back
(
static_cast
<
string
>
(
dirp
->
d_name
));
}
closedir
(
dp
);
#endif
return
list
;
}
std
::
vector
<
std
::
string
>
Directory
::
GetListFolders
(
const
string
&
directoryName
,
bool
addPath
)
{
std
::
vector
<
std
::
string
>
list
;
std
::
string
path
=
directoryName
+
"/*"
;
list
.
clear
();
#ifdef WIN32
WIN32_FIND_DATA
FindFileData
;
HANDLE
hFind
;
hFind
=
FindFirstFile
((
LPCSTR
)
path
.
c_str
(),
&
FindFileData
);
if
(
hFind
==
INVALID_HANDLE_VALUE
)
{
return
list
;
}
else
{
do
{
if
(
FindFileData
.
dwFileAttributes
==
FILE_ATTRIBUTE_DIRECTORY
&&
strcmp
(
FindFileData
.
cFileName
,
"."
)
!=
0
&&
strcmp
(
FindFileData
.
cFileName
,
".."
)
!=
0
)
{
if
(
addPath
)
list
.
push_back
(
directoryName
+
"/"
+
FindFileData
.
cFileName
);
else
list
.
push_back
(
FindFileData
.
cFileName
);
}
}
while
(
FindNextFile
(
hFind
,
&
FindFileData
));
FindClose
(
hFind
);
}
#else
DIR
*
dp
;
struct
dirent
*
dirp
;
if
((
dp
=
opendir
(
path
.
c_str
()))
==
NULL
)
{
return
list
;
}
while
((
dirp
=
readdir
(
dp
))
!=
NULL
)
{
if
(
dirp
->
d_type
==
DT_DIR
)
list
.
push_back
(
static_cast
<
string
>
(
dirp
->
d_name
));
}
closedir
(
dp
);
#endif
return
list
;
}
std
::
vector
<
std
::
string
>
Directory
::
GetListFilesR
(
const
string
&
directoryName
,
bool
addPath
)
{
std
::
vector
<
std
::
string
>
list
=
Directory
::
GetListFiles
(
directoryName
,
addPath
);
std
::
vector
<
std
::
string
>
dirs
=
Directory
::
GetListFolders
(
directoryName
,
addPath
);
std
::
vector
<
std
::
string
>::
const_iterator
it
;
for
(
it
=
dirs
.
begin
();
it
!=
dirs
.
end
();
++
it
)
{
std
::
vector
<
std
::
string
>
cl
=
Directory
::
GetListFiles
(
*
it
,
addPath
);
list
.
insert
(
list
.
end
(),
cl
.
begin
(),
cl
.
end
());
}
return
list
;
}
}
\ 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