1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

This commit is contained in:
Alexander Alekhin
2019-06-26 20:17:19 +00:00
43 changed files with 895 additions and 355 deletions
+24 -4
View File
@@ -911,25 +911,35 @@ void addDataSearchSubDirectory(const std::string& subdir)
static std::string findData(const std::string& relative_path, bool required, bool findDirectory)
{
#define TEST_TRY_FILE_WITH_PREFIX(prefix) \
#define CHECK_FILE_WITH_PREFIX(prefix, result) \
{ \
result.clear(); \
std::string path = path_join(prefix, relative_path); \
/*printf("Trying %s\n", path.c_str());*/ \
if (findDirectory) \
{ \
if (isDirectory(path)) \
return path; \
result = path; \
} \
else \
{ \
FILE* f = fopen(path.c_str(), "rb"); \
if(f) { \
fclose(f); \
return path; \
result = path; \
} \
} \
}
#define TEST_TRY_FILE_WITH_PREFIX(prefix) \
{ \
std::string result__; \
CHECK_FILE_WITH_PREFIX(prefix, result__); \
if (!result__.empty()) \
return result__; \
}
const std::vector<std::string>& search_path = TS::ptr()->data_search_path;
for(size_t i = search_path.size(); i > 0; i--)
{
@@ -956,7 +966,17 @@ static std::string findData(const std::string& relative_path, bool required, boo
{
const std::string& subdir = search_subdir[i - 1];
std::string prefix = path_join(datapath, subdir);
TEST_TRY_FILE_WITH_PREFIX(prefix);
std::string result_;
CHECK_FILE_WITH_PREFIX(prefix, result_);
#if 1 // check for misused 'optional' mode
if (!required && !result_.empty())
{
std::cout << "TEST ERROR: Don't use 'optional' findData() for " << relative_path << std::endl;
CV_Assert(required || result_.empty());
}
#endif
if (!result_.empty())
return result_;
}
}
}