halcon批量读取图片并保存分辨率

批量打开文件夹并读取图片

* Image Acquisition 01: Code generated by Image Acquisition 01
list_files ('F:/Huizong/test/ckpt9/test/0', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
for Index := 0 to |ImageFiles| - 1 by 1
    read_image (Image, ImageFiles[Index])

读取分辨率

get_image_size (Image, Width, Height)

保存分辨率

(没找到换列的方法,索性将图片来源、图像宽、高分成三个表)

*保存图像分辨率
    open_file ('D:/0width.xls', 'append', FileHandle)
    open_file ('D:/0height.xls', 'append', FileHandle2)
    open_file ('D:/0name.xls', 'append', FileHandle3)
if (Width<128 or Height<64)
    fwrite_string (FileHandle, Width)
    fwrite_string (FileHandle2, Height)
    fwrite_string (FileHandle3, ImageFiles[Index])
    fnew_line (FileHandle)
    fnew_line (FileHandle2)
    fnew_line (FileHandle3)
endif    
    close_file (FileHandle)
    close_file (FileHandle2)
    close_file (FileHandle3)
endfor

删除当前读取的图片

if (Width<128 or Height<64)
*     fwrite_string (FileHandle, Width)
*     fwrite_string (FileHandle2, Height)
*     fwrite_string (FileHandle3, ImageFiles[Index])
*     fnew_line (FileHandle)
*     fnew_line (FileHandle2)
*     fnew_line (FileHandle3)
    delete_file (ImageFiles[Index])
endif    
*     close_file (FileHandle)
*     close_file (FileHandle2)
*     close_file (FileHandle3)
endfor

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值