from pathlib import Path from Checker import Checker from Printer import Printer import sys from os import listdir from os.path import isfile, join if len(sys.argv) != 2: print('The program must receive the path to the directory as a argument') sys.exit(0) pathRoot = sys.argv[1] files = [f for f in listdir(pathRoot) if isfile(join(pathRoot, f)) and f[-4:] == '.txt'] subset_filenames = list() for file in files: with open(join(pathRoot, file)) as f: ids = f.readlines() subset_filenames.extend([id.strip() for id in ids]) checker = Checker(pathRoot) dictImgsLabels, withoutMarcation, inexistentFiles = checker.check(pathRoot) printer = Printer() print("Images without labels in the JSons. Total: ", len(withoutMarcation)) for wm in withoutMarcation: print(wm) print("Images in the JSons that does not exist. Total: ", len(inexistentFiles)) for inex in inexistentFiles: print(inex) print('PRESS Q TO EXIT.') print(subset_filenames) printer.print(pathRoot, dictImgsLabels, subset_filenames) #cv2.namedWindow('image', cv2.WINDOW_NORMAL) #for path in pathImgs: # print(path.as_posix()) # img = cv2.imread(path.as_posix()) # cv2.imshow('image',img) # k = cv2.waitKey(0) # if k == ord('q'): # wait for 's' key to save and exit # break #cv2.destroyAllWindows()