Last active
June 12, 2016 19:21
-
-
Save wngreene/09c73bb4e1c7be41c29e3cef8a04454e to your computer and use it in GitHub Desktop.
Example of using readlink to get directory of executable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <boost/filesystem.hpp> | |
namespace fs = boost::filesystem; | |
// Get directory of executable (<base_dir>). | |
char exe_str[200]; | |
readlink("/proc/self/exe", exe_str, 200); | |
fs::path exe_path(exe_str); | |
std::string base_dir = exe_path.parent_path().string(); | |
// Use <base_dir> to load a file using relative path to executable. | |
cv::Mat truth = cv::imread(base_dir + "/../mlm_test_images/RasterizationTest_DrawLineInterpolatedTest.png", |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment