I have a C++ project and I want to access some data I have saved in folder images
.
I have tried from calibration.cpp
to do:
std::string path = "images/*.jpg";
cv::glob(path, images);
But it gave me an error of not detecting the directory. In order to determine in which directory the execution was looking at I created a dummy text file and save it to see where it got saved.
It gets saved in cmake-build-debug , which is a folder created automatically when building the CMakeLists.txt in CLion. Then if I put my images
folder in cmake-build-debug it gets seen but I want to have the images folder in parent directory.
- How can I set the current directory to look for files from there?
My project looks like:
Camera Motion
-- cmake-build-debug
---- ...
-- images
---- image1.png
-- CMakeLists.txt
-- calibration.cpp
# CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(CameraMotion)
set(CMAKE_CXX_STANDARD 14)
find_package( OpenCV REQUIRED )
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(CameraMotion calibration.cpp)
target_link_libraries(CameraMotion ${OpenCV_LIBS})
# calibration.cpp
#include <iostream>
int main()
{
std::ofstream myfile;
myfile.open("output.txt");
myfile << "output\n";
myfile.close();
std::string path = "images/*.jpg";
cv::glob(path, images);
}
When I run the project in CLion it says:
====================[ Build | CameraMotion | Debug ]============================
/Applications/CLion.app/Contents/bin/cmake/mac/bin/cmake --build /Users/hectoresteban/CLionProjects/CameraMotion/cmake-build-debug --target CameraMotion -- -j 4
[100%] Built target CameraMotion