m_image_matching_data.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import os
  2. from utils.utils_func import list_dir
  3. class MatchingData(object):
  4. def __init__(self):
  5. pass
  6. def get_all_folder(self, root_path):
  7. folder_list = []
  8. last_goods_no = ""
  9. last_label_color = "green"
  10. if os.path.exists(root_path):
  11. all_folder = list_dir(root_path)
  12. for folder_name in all_folder:
  13. # original_path = "{}/{}/800x800".format(root_path, folder_name)
  14. original_path = "{}/{}/原始图".format(root_path, folder_name)
  15. cut_out_path = "{}/{}/原始图_已抠图".format(root_path, folder_name)
  16. if os.path.exists(original_path) and os.path.exists(cut_out_path):
  17. if folder_name[:-1] == last_goods_no:
  18. label_color = last_label_color
  19. else:
  20. if last_label_color == "green":
  21. last_label_color = "blue"
  22. else:
  23. last_label_color = "green"
  24. last_goods_no = folder_name[:-1]
  25. label_color = last_label_color
  26. folder_list.append(
  27. {"root_path": root_path,
  28. "goods_art_no_folder_path": "{}/{}".format(root_path, folder_name),
  29. "original_path": original_path,
  30. "folder_name": folder_name,
  31. "cut_out_path": cut_out_path,
  32. "label_color": label_color,
  33. }
  34. )
  35. return folder_list