设为首页收藏本站
授权版本:2024_07
开启左侧

自己写了个开源数据集转hdict的脚本

[复制链接]
进击的烤肉 发表于 2022-4-5 22:02:42 | 显示全部楼层 |阅读模式
本来想直接论坛找现成的无奈找到的各种版本都有问题,所以自己写了个

XMLtohdict.hdev

4.64 KB, 下载次数: 7

售价: 10 视觉币  [记录]

奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
xuyongze 发表于 2022-4-6 21:15:09 | 显示全部楼层
halcon深度检测效果好吗?
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| 进击的烤肉 发表于 2022-4-7 08:00:31 | 显示全部楼层
xuyongze 发表于 2022-4-6 21:15
halcon深度检测效果好吗?

还在测试中
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
 楼主| 进击的烤肉 发表于 2022-4-11 22:52:18 | 显示全部楼层
  1. read_dict ('C:/Users/12820/Desktop/数据/分割.hdict', [], [], DictHandle)
  2. * Image Acquisition 01: Code generated by Image Acquisition 01
  3. create_dict (NEWDictHandle1)
  4. class_ids:=[0,1,2,3,4,5]
  5. class_names:=['孔','印刷','断裂','短','多','线条']
  6. image_dir:='D:/BaiduNetdiskDownload/PCB_DATASET/PCB_DATASET/images/'
  7. set_dict_tuple (NEWDictHandle1, 'class_ids', class_ids)
  8. set_dict_tuple (NEWDictHandle1, 'class_names', class_names)
  9. set_dict_tuple (NEWDictHandle1, 'image_dir', image_dir)
  10. list_files ('C:/Users/12820/Desktop/分割测试文件夹/image', ['files','follow_links','recursive'], ImageFiles)
  11. tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
  12. list_files ('C:/Users/12820/Desktop/分割测试文件夹/anno', ['files','follow_links','recursive'], xmladdress)
  13. samples:=[]
  14. for Index := 0 to |ImageFiles| - 1 by 1
  15.     read_image (Image, ImageFiles[Index])
  16.    
  17.    
  18.    
  19.    
  20.    
  21.    open_file (xmladdress[Index], 'input', FileHandle)
  22.    IsEof := false
  23.    bbox_row1:=[]  
  24.    bbox_col1:=[]  
  25.    bbox_row2:=[]  
  26.    bbox_col2:=[]  
  27.    bbox_label_id:=[]
  28.    while (not(IsEof))
  29.        fread_line (FileHandle, XmlElement, IsEof)
  30.        if (IsEof)
  31.            break
  32.        endif
  33.        tuple_split (XmlElement, '<''>', Substrings)
  34.        create_dict (image)
  35.        if (Substrings[1]=='folder')
  36.            floder:= Substrings[2]
  37.        endif  
  38.        if (Substrings[1]=='filename')
  39.            filename:= Substrings[2]
  40.        endif   
  41.        if (Substrings[1]=='name')
  42.            if (Substrings[2]=='missing_hole' )
  43.                bbox_label_id:=[bbox_label_id,0]
  44.            elseif (Substrings[2]=='mouse_bite')
  45.                bbox_label_id:=[bbox_label_id,1]
  46.            elseif (Substrings[2]=='open_circuit')
  47.                bbox_label_id:=[bbox_label_id,2]
  48.            elseif (Substrings[2]=='short')
  49.                     bbox_label_id:=[bbox_label_id,3]
  50.            elseif (Substrings[2]=='spur')
  51.                bbox_label_id:=[bbox_label_id,4]
  52.            elseif (Substrings[2]=='spurious_copper')
  53.                bbox_label_id:=[bbox_label_id,5]
  54.            endif
  55.       endif
  56.       
  57.       if (Substrings[1]=='xmin')
  58.           bbox_col1:= [bbox_col1,Substrings[2]]
  59.           tuple_number (bbox_col1, bbox_col1)
  60.    
  61.       endif  
  62.       if (Substrings[1]=='ymin')
  63.           bbox_row1:= [bbox_row1,Substrings[2] ]
  64.           tuple_number (bbox_row1, bbox_row1)
  65.       endif  
  66.       if (Substrings[1]=='xmax')
  67.           bbox_col2:=[bbox_col2, Substrings[2] ]
  68.           tuple_number (bbox_col2, bbox_col2)
  69.       endif  
  70.       if (Substrings[1]=='ymax')
  71.           bbox_row2:=[bbox_row2, Substrings[2] ]
  72.           tuple_number (bbox_row2, bbox_row2)
  73.       endif  
  74.     endwhile
  75.    
  76.    
  77.    * gen_rectangle1 (Rectangle,bbox_row1 , bbox_col1,bbox_row2 , bbox_col2)
  78.    
  79.   set_dict_tuple (image, 'image_id', Index+1)
  80.   set_dict_tuple (image, 'image_file_name', floder+'/'+filename)
  81.   set_dict_tuple (image, 'bbox_label_id', bbox_label_id)
  82.   set_dict_tuple (image, 'bbox_row1', bbox_row1)
  83.   set_dict_tuple (image, 'bbox_col1', bbox_col1)
  84.   set_dict_tuple (image, 'bbox_row2', bbox_row2)
  85.   set_dict_tuple (image, 'bbox_col2', bbox_col2)
  86. samples:=[samples,image]
  87.    
  88.     *stop()  
  89. endfor
  90. set_dict_tuple (NEWDictHandle1, 'samples', samples)
  91. write_dict (NEWDictHandle1, 'C:/Users/12820/Desktop/数据/全电路板数据.hdict', [], [])
复制代码
奖励计划已经开启,本站鼓励作者发布最擅长的技术内容和资源,流量变现就在现在,[点我]加入吧~~~Go
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表