1. 程式人生 > >linux下生成圖片檔案列表及讀取

linux下生成圖片檔案列表及讀取

一個很簡單的sh檔案就可以搞定

listfilepath=list.txt

filepath=./sampledata/

find $filepath -name *.png > $listfilepath

然後在windows下就是使用.bat批處理檔案來進行:

dir /b/s/p/w *.bmp>Path_Images.txt

生成之後怎麼讀取?可以用c++裡面定義的檔案流來讀取:(直接給個實際的程式碼)

std::ifstream inpos_file("G:\\學習\\畢業設計-ldw\\未來挑戰賽檔案\\標註樣本\\TSD樣本標註\\posall.txt");

按照行讀取:

std::string line;

while (std::getline(inpos_file, line))

train_image = imread(line);