1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

videoio: plugins support on Win32

This commit is contained in:
Alexander Alekhin
2019-05-31 16:18:00 +03:00
committed by Alexander Alekhin
parent 66d7956e67
commit 7b099e0fe2
16 changed files with 298 additions and 927 deletions
+38 -4
View File
@@ -144,11 +144,38 @@ static cv::String getModuleLocation(const void* addr)
return cv::String();
}
std::string getBinLocation()
bool getBinLocation(std::string& dst)
{
return getModuleLocation((void*)getModuleLocation); // use code addr, doesn't work with static linkage!
dst = getModuleLocation((void*)getModuleLocation); // using code address, doesn't work with static linkage!
return !dst.empty();
}
#ifdef _WIN32
bool getBinLocation(std::wstring& dst)
{
void* addr = (void*)getModuleLocation; // using code address, doesn't work with static linkage!
HMODULE m = 0;
#if _WIN32_WINNT >= 0x0501
::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCTSTR>(addr),
&m);
#endif
if (m)
{
wchar_t path[4096];
const size_t path_size = sizeof(path)/sizeof(*path);
size_t sz = GetModuleFileNameW(m, path, path_size);
if (sz > 0 && sz < path_size)
{
path[sz] = '\0';
dst.assign(path, sz);
return true;
}
}
return false;
}
#endif
cv::String findDataFile(const cv::String& relative_path,
const char* configuration_parameter,
const std::vector<String>* search_paths,
@@ -292,8 +319,15 @@ cv::String findDataFile(const cv::String& relative_path,
}
}
cv::String module_path = getBinLocation();
CV_LOG_DEBUG(NULL, "Detected module path: '" << module_path << '\'');
cv::String module_path;
if (getBinLocation(module_path))
{
CV_LOG_DEBUG(NULL, "Detected module path: '" << module_path << '\'');
}
else
{
CV_LOG_INFO(NULL, "Can't detect module binaries location");
}
if (!has_tested_build_directory &&
(isSubDirectory(build_dir, module_path) || isSubDirectory(utils::fs::canonical(build_dir), utils::fs::canonical(module_path)))
+8
View File
@@ -91,6 +91,14 @@ CV_EXPORTS cv::String getParent(const cv::String &path)
return std::string(path, 0, loc);
}
CV_EXPORTS std::wstring getParent(const std::wstring& path)
{
std::wstring::size_type loc = path.find_last_of(L"/\\");
if (loc == std::wstring::npos)
return std::wstring();
return std::wstring(path, 0, loc);
}
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
cv::String canonical(const cv::String& path)