I need to set a directory and then read all the filenames of the files inside and store the whole path in a variable. I need to use this this variable later , to open the file and read it. I don't want use QDir
for this. I saw the second answer to the question here. I can use boost/filesystem.hpp
(I believe this need not be downloaded separately). But the problem is execution will look like this:
$ g++ -o test test.cpp -lboost_filesystem -lboost_system
$ ./test
My first line, for creating executable object is already complicated due to OpenCV libraries and I don't want to add to it. I want to keep them simple (the following line plus whatever OpenCV wants):
g++ -o test test.cpp
Is there any way to do it?
This is the python code for which I want to write C++ code:
root_dir = 'abc'
img_dir = os.path.join(root_dir,'subimages')
img_files = os.listdir(img_dir)
for files in img_files:
img_name = os.path.join (img_dir,files)
img = cv2.imread(img_name)