Demo路徑:./opencv/sources/samples/cpp/imagelist_creator.cpp
“This create a yaml or xml list of files from the command line args”
用法:
在Debug目錄下,輸入命令行:imagelist_creator.exe imglist.xml 1.bmp 2.bmp
輸出文件
imglist.xml
<?xml version="1.0"?>
<opencv_storage>
<images>
"1.bmp" "2.bmp" </images>
</opencv_storage>
需要注意的是,該demo不從任何地方讀取圖片,它只接受通過命令行輸入文件名並創建相應格式的文件,個人覺得需要創建一個包含幾十個圖像文件名的xml文件時,該方法太笨重,不如考慮下面的方法:1.把需要創建xml路徑的全部圖片放到指定文件夾中
2.在該文件夾下使用命令行 dir /s /b >imglist.txt
3.使用word等編輯工具打開,替換文件名
4.複製到xml文件裏面並保存
實測並不複雜!