def get_date(ocr): """Using DateParser this function process given OCR data and returns date :param ocr: as eated OCR data from an image :return: date :raise: need to handle if passing data is empty """ date_parser = DateParser(ocr) found_date = date_parser.get_date() if found_date is None: return datetime.now().strftime('%d-%m-%Y') else: return found_date
def test_bulk_image(self, path): """This function reads all images in a given directory, read OCR Data and returns expected value :param path: Directory path which contain images :return: expected value like date, total, ht, tva etc. :raise: need to handle except""" images = glob2.glob(path + "/*.*") print('--- Start recognize text from image ---') for image in images: print("Date for" + image) str = self.get_string(image) date = DateParser(str) date_found = date.get_date() print(date_found) print("--------------") print("------ Done -------")
def test_bulk_image(): # Path of working folder on Disk src_path = "./receipt/" images = glob2.glob("./receipt/*.*") print('--- Start recognize text from image ---') for image in images: print("Date for" + image) str = get_string(image) date = DateParser(str) date_found = date.get_date() print(date_found) print("--------------") #file = open(src_path + "01.png.txt", "w") #file.write(str) #file.close() print("------ Done -------")
def get_date(ocr): date_parser = DateParser(ocr) found_date = date_parser.get_date() return found_date