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