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
6e767e23
Commit
6e767e23
authored
Jul 23, 2018
by
Alexander Alekhin
Committed by
Dmitry Kurtaev
Jul 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ts: add findDataDirectory() function
parent
28e08ae0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
ts.hpp
modules/ts/include/opencv2/ts.hpp
+5
-0
ts.cpp
modules/ts/src/ts.cpp
+25
-7
No files found.
modules/ts/include/opencv2/ts.hpp
View file @
6e767e23
...
...
@@ -654,6 +654,11 @@ void addDataSearchSubDirectory(const std::string& subdir);
*/
std
::
string
findDataFile
(
const
std
::
string
&
relative_path
,
bool
required
=
true
);
/*! @brief Try to find requested data directory
@sa findDataFile
*/
std
::
string
findDataDirectory
(
const
std
::
string
&
relative_path
,
bool
required
=
true
);
#ifndef __CV_TEST_EXEC_ARGS
#if defined(_MSC_VER) && (_MSC_VER <= 1400)
...
...
modules/ts/src/ts.cpp
View file @
6e767e23
...
...
@@ -772,16 +772,24 @@ void addDataSearchSubDirectory(const std::string& subdir)
TS
::
ptr
()
->
data_search_subdir
.
push_back
(
subdir
);
}
st
d
::
string
findDataFile
(
const
std
::
string
&
relative_path
,
bool
required
)
st
atic
std
::
string
findData
(
const
std
::
string
&
relative_path
,
bool
required
,
bool
findDirectory
)
{
#define TEST_TRY_FILE_WITH_PREFIX(prefix) \
{ \
std::string path = path_join(prefix, relative_path); \
/*printf("Trying %s\n", path.c_str());*/
\
FILE* f = fopen(path.c_str(), "rb"); \
if(f) { \
fclose(f); \
return path; \
if (findDirectory) \
{ \
if (isDirectory(path)) \
return path; \
} \
else \
{ \
FILE* f = fopen(path.c_str(), "rb"); \
if(f) { \
fclose(f); \
return path; \
} \
} \
}
...
...
@@ -842,11 +850,21 @@ std::string findDataFile(const std::string& relative_path, bool required)
}
#endif
#endif
const
char
*
type
=
findDirectory
?
"directory"
:
"data file"
;
if
(
required
)
CV_Error
(
cv
::
Error
::
StsError
,
cv
::
format
(
"OpenCV tests: Can't find required data file: %s"
,
relative_path
.
c_str
()));
throw
SkipTestException
(
cv
::
format
(
"OpenCV tests: Can't find data file: %s"
,
relative_path
.
c_str
()));
CV_Error
(
cv
::
Error
::
StsError
,
cv
::
format
(
"OpenCV tests: Can't find required %s: %s"
,
type
,
relative_path
.
c_str
()));
throw
SkipTestException
(
cv
::
format
(
"OpenCV tests: Can't find %s: %s"
,
type
,
relative_path
.
c_str
()));
}
std
::
string
findDataFile
(
const
std
::
string
&
relative_path
,
bool
required
)
{
return
findData
(
relative_path
,
required
,
false
);
}
std
::
string
findDataDirectory
(
const
std
::
string
&
relative_path
,
bool
required
)
{
return
findData
(
relative_path
,
required
,
true
);
}
}
//namespace cvtest
...
...
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