| 32 | |
| 33 | |
| 34 | def get_image_file_list(img_file): |
| 35 | imgs_lists = [] |
| 36 | if img_file is None or not os.path.exists(img_file): |
| 37 | raise Exception("not found any img file in {}".format(img_file)) |
| 38 | |
| 39 | if os.path.isfile(img_file) and _check_image_file(img_file): |
| 40 | imgs_lists.append(img_file) |
| 41 | elif os.path.isdir(img_file): |
| 42 | for single_file in os.listdir(img_file): |
| 43 | file_path = os.path.join(img_file, single_file) |
| 44 | if os.path.isfile(file_path) and _check_image_file(file_path): |
| 45 | imgs_lists.append(file_path) |
| 46 | if len(imgs_lists) == 0: |
| 47 | raise Exception("not found any img file in {}".format(img_file)) |
| 48 | imgs_lists = sorted(imgs_lists) |
| 49 | return imgs_lists |
| 50 | |
| 51 | |
| 52 | def binarize_img(img): |