def __init__(self, file_json, transform): list_image, list_value, dict_json_info = get_Image_Value_List_from_json(file_json) self.list_image = list_image self.list_label = list_value self.dict_json_info = dict_json_info self.transform = transform
def read_digit(jsonfile): list_image, list_value, dict_json_info = get_Image_Value_List_from_json(jsonfile) image_first = list_image[0].convert('L') image_first = np.array(image_first) height, width = image_first.shape for pil_image in list_image[1:]: pil_image = np.array(pil_image.convert('L')) image = cv2.resize(pil_image,(width, height) ) image_first = cv2.hconcat([image_first, image]) plt.figure(figsize=(12, 10)) plt.imshow(image_first, cmap='gray') plt.show() chars = pytesseract.image_to_string(image_first, lang='kor', config='--psm 7 --oem 3') result_chars = '' for c in chars: if ord('가') <= ord(c) <= ord('힣') or c.isdigit(): result_chars += c print(result_chars)