- read_dict ('C:/Users/12820/Desktop/数据/分割.hdict', [], [], DictHandle)
- * Image Acquisition 01: Code generated by Image Acquisition 01
- create_dict (NEWDictHandle1)
- class_ids:=[0,1,2,3,4,5]
- class_names:=['孔','印刷','断裂','短','多','线条']
- image_dir:='D:/BaiduNetdiskDownload/PCB_DATASET/PCB_DATASET/images/'
- set_dict_tuple (NEWDictHandle1, 'class_ids', class_ids)
- set_dict_tuple (NEWDictHandle1, 'class_names', class_names)
- set_dict_tuple (NEWDictHandle1, 'image_dir', image_dir)
- list_files ('C:/Users/12820/Desktop/分割测试文件夹/image', ['files','follow_links','recursive'], ImageFiles)
- tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
- list_files ('C:/Users/12820/Desktop/分割测试文件夹/anno', ['files','follow_links','recursive'], xmladdress)
- samples:=[]
- for Index := 0 to |ImageFiles| - 1 by 1
- read_image (Image, ImageFiles[Index])
-
-
-
-
-
- open_file (xmladdress[Index], 'input', FileHandle)
- IsEof := false
- bbox_row1:=[]
- bbox_col1:=[]
- bbox_row2:=[]
- bbox_col2:=[]
- bbox_label_id:=[]
- while (not(IsEof))
- fread_line (FileHandle, XmlElement, IsEof)
- if (IsEof)
- break
- endif
- tuple_split (XmlElement, '<''>', Substrings)
- create_dict (image)
- if (Substrings[1]=='folder')
- floder:= Substrings[2]
- endif
- if (Substrings[1]=='filename')
- filename:= Substrings[2]
- endif
- if (Substrings[1]=='name')
- if (Substrings[2]=='missing_hole' )
- bbox_label_id:=[bbox_label_id,0]
- elseif (Substrings[2]=='mouse_bite')
- bbox_label_id:=[bbox_label_id,1]
- elseif (Substrings[2]=='open_circuit')
- bbox_label_id:=[bbox_label_id,2]
- elseif (Substrings[2]=='short')
- bbox_label_id:=[bbox_label_id,3]
- elseif (Substrings[2]=='spur')
- bbox_label_id:=[bbox_label_id,4]
- elseif (Substrings[2]=='spurious_copper')
- bbox_label_id:=[bbox_label_id,5]
- endif
- endif
-
- if (Substrings[1]=='xmin')
- bbox_col1:= [bbox_col1,Substrings[2]]
- tuple_number (bbox_col1, bbox_col1)
-
- endif
- if (Substrings[1]=='ymin')
- bbox_row1:= [bbox_row1,Substrings[2] ]
- tuple_number (bbox_row1, bbox_row1)
- endif
- if (Substrings[1]=='xmax')
- bbox_col2:=[bbox_col2, Substrings[2] ]
- tuple_number (bbox_col2, bbox_col2)
- endif
- if (Substrings[1]=='ymax')
- bbox_row2:=[bbox_row2, Substrings[2] ]
- tuple_number (bbox_row2, bbox_row2)
- endif
- endwhile
-
-
- * gen_rectangle1 (Rectangle,bbox_row1 , bbox_col1,bbox_row2 , bbox_col2)
-
- set_dict_tuple (image, 'image_id', Index+1)
- set_dict_tuple (image, 'image_file_name', floder+'/'+filename)
- set_dict_tuple (image, 'bbox_label_id', bbox_label_id)
- set_dict_tuple (image, 'bbox_row1', bbox_row1)
- set_dict_tuple (image, 'bbox_col1', bbox_col1)
- set_dict_tuple (image, 'bbox_row2', bbox_row2)
- set_dict_tuple (image, 'bbox_col2', bbox_col2)
- samples:=[samples,image]
-
- *stop()
- endfor
- set_dict_tuple (NEWDictHandle1, 'samples', samples)
-
- write_dict (NEWDictHandle1, 'C:/Users/12820/Desktop/数据/全电路板数据.hdict', [], [])
复制代码 |