You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

AOI_select.py 1.9 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import cv2
  2. import os
  3. import numpy as np
  4. import shutil
  5. import argparse
  6. def parse_args():
  7. parser = argparse.ArgumentParser(description='get AOI class')
  8. parser.add_argument('--AOI_path', help='AOI path')
  9. args = parser.parse_args()
  10. return args
  11. args = parse_args()
  12. #path = "D:/Work/20211119-dsxw/PCBA_dataset/dsxw_report/SMD12-09-Report/SMD12-Manual/img/ng/"
  13. path = args.AOI_path+"/ng/"
  14. print(path)
  15. imgs = os.listdir(path)
  16. i = 0
  17. class_AOI_name = {"bu_pi_pei":"1","fang_xiang_fan":"2","err.txt_c_not_f":"3"}
  18. class_name = {"yi_wei":"1","lou_jian":"2","ce_li":"3","li_bei":"4","shang_xia_fan_t":"5","lian_xi":"6","duo_jian":"7","sun_huai":"8","shao_xi":"9","jia_han":"10","yi_wu":"11",\
  19. "移位_Component_":"1","缺件_Component_":"2","侧立_Stand_Up":"3","立碑_Tombstone":"4","翻贴_Upside_Dow":"5","连锡_Solder_Bri":"6","Solderbridge":"6",\
  20. "损坏_Bad_Compon":"8","少锡_Insufficie":"9","假焊_Pseudo_Sol":"10"}
  21. class_name_other = {"上锡不良_Poor_S":"12","qita":"13","limit_error":"13","极性错_Wrong_Po":"13","其它_Others":"13"}
  22. count = 0
  23. count_qita = 0
  24. bpp_ok = 0
  25. bpp_ng = 0
  26. count_ng = 0
  27. def cv_imread(file_path):
  28. cv_img = cv2.imdecode(np.fromfile(file_path, dtype=np.uint8), 0)
  29. return cv_img
  30. for img in imgs:
  31. i = i+1
  32. src = cv_imread(path+img)
  33. #print(img)
  34. img_name = img.split("@")
  35. #print(img_name[2], img_name[3])
  36. if img_name[2] in class_AOI_name.keys():
  37. #print(img_name[2], img)
  38. if img_name[3]=="Pseudo_Error":
  39. bpp_ok += 1
  40. else:
  41. bpp_ng += 1
  42. count += 1
  43. os.remove(path+img)
  44. continue
  45. if img_name[3] not in class_name.keys():
  46. print(img_name[3], img)
  47. count_qita += 1
  48. os.remove(path+img)
  49. continue
  50. count_ng += 1
  51. print(count, bpp_ok, bpp_ng)
  52. print(count_qita)
  53. print(count_ng)

No Description

Contributors (1)