zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    python requests模块
    python 模拟豆瓣登录(豆瓣6.0)
    python 抓取糗事百科糗图
    python bz2模块
    the python challenge闯关记录(9-16)
    python之PIL库(Image模块)
    python之zipfile
    python之pickle模块
    the python challenge闯关记录(0-8)
    KVO简介
  • 原文地址:https://www.cnblogs.com/hanzhaoxin/p/2832149.html
Copyright © 2011-2022 走看看