diff --git a/Application/src/tracker/python/GPURecognition.cpp b/Application/src/tracker/python/GPURecognition.cpp index fc0f9779468b9dcf5c698e860a79f520e2891791..9042f2d4ea211076d532a92445e179c6b7bcfa34 100644 --- a/Application/src/tracker/python/GPURecognition.cpp +++ b/Application/src/tracker/python/GPURecognition.cpp @@ -347,7 +347,10 @@ namespace track { if (!getenv("TREX_DONT_SET_PATHS")) { std::string sep = "/"; auto home = Py_GetPythonHome(); - auto home2 = SETTING(python_path).value<file::Path>().remove_filename().str(); + auto home2 = SETTING(python_path).value<file::Path>().str(); + if(file::Path(home2).exists() && file::Path(home2).is_regular()) + home2 = file::Path(home2).remove_filename().str(); + Debug("Setting home to '%S'", &home2); if (!home2.empty()) { home2 = utils::find_replace(home2, "/", sep); @@ -356,6 +359,7 @@ namespace track { wchar_t* pwcsName = new wchar_t[nChars]; MultiByteToWideChar(CP_ACP, 0, home2.c_str(), -1, (LPWSTR)pwcsName, nChars); Py_SetPythonHome(pwcsName); + SetEnvironmentVariable("PYTHONHOME", home2.c_str()); // delete it delete[] pwcsName; diff --git a/Application/src/tracker/tracking/Recognition.cpp b/Application/src/tracker/tracking/Recognition.cpp index ccb1b10cf74da662ee100023851c09d333beaba2..4debfb1b6b5ebc8aeed7847d0934fbbdf623934c 100644 --- a/Application/src/tracker/tracking/Recognition.cpp +++ b/Application/src/tracker/tracking/Recognition.cpp @@ -155,7 +155,10 @@ Image::Ptr Recognition::calculate_diff_image_with_settings(const default_config: #else exec = "./"+exec+" 2> /dev/null"; #endif - + if ((SETTING(wd).value<file::Path>() / exec).exists()) { + exec = (SETTING(wd).value<file::Path>() / exec).str(); + Debug("Exists in working dir: '%S'", &exec); + } auto ret = system(exec.c_str()) == 0; #if WIN32 SetErrorMode(0); @@ -180,7 +183,10 @@ Image::Ptr Recognition::calculate_diff_image_with_settings(const default_config: #ifdef TREX_PYTHON_PATH auto home = ::default_config::conda_environment_path().str(); if (home.empty()) - home = SETTING(python_path).value<file::Path>().remove_filename().str(); + home = SETTING(python_path).value<file::Path>().str(); + if (file::Path(home).exists() && file::Path(home).is_regular()) + home = file::Path(home).remove_filename().str(); + Debug("Setting home to '%S'", &home); if (!can_initialize_python() && !getenv("TREX_DONT_SET_PATHS")) { if (!SETTING(quiet)) diff --git a/Application/trex_build_windows.bat b/Application/trex_build_windows.bat index 7c1c8d16e01c4913e1d4f2df3a5c6e0738327728..0df20a60a300ea8a6a3fdd66fb63890f0fd0776d 100644 --- a/Application/trex_build_windows.bat +++ b/Application/trex_build_windows.bat @@ -22,6 +22,6 @@ cmake --build . --target libzip --config Release cmake --build . --target libpng_custom --config Release cmake --build . --target CustomOpenCV --config Release cmake .. -cmake --build . --target INSTALL --config Release +cmake --build . --config Release endlocal \ No newline at end of file