halcon_一些代码片段

1.将box中的坐标存储到txt中

root:='D:/temp/'
txtpath:=root+'1.txt'
box1:=[0,5,6,20,30]
box2:=[0,30,33,20,21]
open_file(txtpath,'output',FileHandle)
tuple_regexp_replace(txtpath,'.txt','.jpg',filename)
fwrite_string(FileHandle,filename)
fnew_line(FileHandle)
fwrite_string(FileHandle,box1[0]+' '+box1[1]+' '+box1[2]+' '+box1[3]+' '+box1[4])
fnew_line(FileHandle)
fwrite_string(FileHandle,box2[0]+' '+box2[1]+' '+box2[2]+' '+box2[3]+' '+box2[4])
close_file(FileHandle)

txt中的存储结果:

 2.筛选文件和遍历

img_root:='D:/my_code/visual_proj/feature_match/images/S02_jpgs_vertical_0912'
list_files(img_root,['files'],ImageFiles)
* 正则表达式,.*表示匹配全部字符,$表示匹配文本的结束,ignore_case是忽略大小写,因为有些会是.BMP的图片
* tuple_regexp_select (ImageFiles, ['\\.(bmp|jpg)$','ignore_case'], ImageFiles)
tuple_regexp_select(ImageFiles,['mix'+'.*'+'.(bmp|jpg)$','ignore_case'],ImageFiles)
imgnames:=[]
for i:=0 to |ImageFiles|-1 by 1
    imgpath:=ImageFiles[i]
    * 根据文件路径,解析文件名称,后缀,文件夹路径
    parse_filename(imgpath,Basename,Extension,Directory)
    tuple_concat(imgnames,Basename,imgnames)
endfor

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值