halcon 图像路径 写txt
* Image Acquisition 02: Code generated by Image Acquisition 02
list_files ('F:/keras-retinanet-master/CSV/JPEGImages', ['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])
* 分割文件名
parse_filename(ImageFiles[Index], BaseName, Extension, Directory)
* Image Acquisition 02: Do something
threshold(Image, Region, 128, 255)
dilation_circle(Region, RegionDilation, 20)
erosion_circle(RegionDilation, RegionErosion, 10)
connection(RegionErosion, ConnectedRegions)
select_shape(ConnectedRegions, SelectedRegions, 'area', 'and', 1500, 99999)
*循环个数
count_obj(SelectedRegions, Number)
open_file ('C:/Users/xian/Desktop//scratch.txt', 'append', FileHandle)
for Index1 := 0 to Number-1 by 1
select_obj(SelectedRegions, ObjectSelected, Index1+1)
smallest_rectangle1(ObjectSelected, Row1, Column1, Row2, Column2)
gen_rectangle1(Rectangle, Row1, Column1, Row2, Column2)
filename := Directory+BaseName
string_a := filename+'.bmp'+','+Column1+','+Row1+','+Column2+','+Row2+','+'scratch'
fwrite_string (FileHandle, string_a)
fnew_line (FileHandle)
endfor
close_file (FileHandle)
endfor