六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 319|回复: 0

halcon学习笔记——遍历文件夹与文件选择

[复制链接]

升级  9.33%

20

主题

20

主题

20

主题

秀才

Rank: 2

积分
64
 楼主| 发表于 2012-12-30 11:52:29 | 显示全部楼层 |阅读模式
<div id="cnblogs_post_body">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:选择出的文件路径数组
   
  示例:
  <div id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: 'Courier New', courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet">        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
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表