halcon學習筆記——遍歷文件夾與文件選擇


1)遍歷文件夾:

list_files( : : Directory, Options : Files)

星星Directory:目錄(文件夾路徑)

星星Options:選項

'files' 指定搜索的格式為文件
'directories' 指定搜索的格式為文件夾
'recursive' 指定可以遍歷子文件夾下的文件
'follow_links'  
'max_depth 5' 指定遍歷的深度
'max_files 1000' 指定遍歷的最大文件數目

星星Files:文件(文件的路徑)

2)文件格式篩選

tuple_regexp_select( : : Data, Expression : Selection)

雨傘Data:被選擇的文件路徑數組

雨傘Expression:文件格式的篩選規則

//. 轉義          .
(bmp|JPG) 篩選的文件格式
'ignore_case' 忽略大小寫

雨傘Selection:選擇出的文件路徑數組

 

示例:

   1: * 遍歷文件夾D:/資料庫/Downloads
   2: list_files ('D:/資料庫/Downloads', ['files','follow_links'], ImageFiles)
   3:  
   4: * 篩選bmp或jpg格式的文件
   5: tuple_regexp_select (ImageFiles, ['\\.(bmp|jpg)$','ignore_case'], ImageFiles)
   6:  
   7: * 依次讀取圖片
   8: for Index := 0 to |ImageFiles| - 1 by 1
   9:     read_image (Image, ImageFiles[Index])
  10:     
  11: endfor


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM