Add get sdk dirs

This commit is contained in:
John Zhao 2018-11-05 12:17:35 +08:00
parent f7abe90c04
commit fccc52eceb
3 changed files with 38 additions and 2 deletions

View File

@ -16,6 +16,7 @@
#pragma once
#include <memory>
#include <string>
#include "mynteye/mynteye.h"
@ -55,6 +56,20 @@ namespace utils {
MYNTEYE_API float get_real_exposure_time(
std::int32_t frame_rate, std::uint16_t exposure_time);
/**
* @ingroup utils
*
* Get sdk root dir.
*/
MYNTEYE_API std::string get_sdk_root_dir();
/**
* @ingroup utils
*
* Get sdk install dir.
*/
MYNTEYE_API std::string get_sdk_install_dir();
} // namespace utils
MYNTEYE_END_NAMESPACE

View File

@ -88,7 +88,7 @@ bool dir_exists(const std::string &p) {
#endif
std::vector<std::string> get_plugin_paths() {
std::string info_path(MYNTEYE_SDK_INSTALL_DIR);
std::string info_path = utils::get_sdk_install_dir();
info_path.append(MYNTEYE_OS_SEP "share" MYNTEYE_OS_SEP "mynteye" MYNTEYE_OS_SEP "build.info");
cv::FileStorage fs(info_path, cv::FileStorage::READ);
@ -183,7 +183,8 @@ std::vector<std::string> get_plugin_paths() {
}
plats.push_back(host_os + "-" + host_arch);
std::vector<std::string> dirs{MYNTEYE_SDK_ROOT_DIR, MYNTEYE_SDK_INSTALL_DIR};
std::vector<std::string> dirs{
utils::get_sdk_root_dir(), utils::get_sdk_install_dir()};
for (auto &&plat : plats) {
for (auto &&dir : dirs) {
auto &&plat_dir = dir + MYNTEYE_OS_SEP "plugins" + MYNTEYE_OS_SEP + plat;

View File

@ -13,6 +13,8 @@
// limitations under the License.
#include "mynteye/device/utils.h"
#include <cstdlib>
#include "mynteye/logger.h"
#include "mynteye/device/context.h"
@ -110,6 +112,24 @@ float get_real_exposure_time(
return exposure_time * real_max / 480.f;
}
std::string get_sdk_root_dir() {
if (const char* root = std::getenv("MYNTEYES_SDK_ROOT")) {
// LOG(INFO) << "Environment variable MYNTEYES_SDK_ROOT found: " << root;
return std::string(root);
} else {
return std::string(MYNTEYE_SDK_ROOT_DIR);
}
}
std::string get_sdk_install_dir() {
if (const char* root = std::getenv("MYNTEYES_SDK_ROOT")) {
// LOG(INFO) << "Environment variable MYNTEYES_SDK_ROOT found: " << root;
return std::string(root);
} else {
return std::string(MYNTEYE_SDK_INSTALL_DIR);
}
}
} // namespace utils
MYNTEYE_END_NAMESPACE