my
Browse files
app.py
CHANGED
@@ -128,23 +128,6 @@ def process_image():
|
|
128 |
print(f"Checking contents of /app/data: {bounding_box_save_path}")
|
129 |
print(f"Directory listing: {os.listdir('./app/Folder1')}")
|
130 |
print(f"Bounding box coordinates saved at {bounding_box_save_path}")
|
131 |
-
try:
|
132 |
-
reader = easyocr.Reader(['en'],recog_network='en_sample',model_storage_directory='./EasyOCR-Trainer/EasyOCR/easyocr/model', user_network_directory='./EasyOCR-Trainer/EasyOCR/user_network')
|
133 |
-
except Exception as e:
|
134 |
-
print(f"Error initializing EasyOCR Reader: {e}")
|
135 |
-
raise
|
136 |
-
reader = easyocr.Reader(
|
137 |
-
['en'],
|
138 |
-
recog_network='en_sample',
|
139 |
-
model_storage_directory='./EasyOCR-Trainer/EasyOCR/easyocr/model',
|
140 |
-
user_network_directory='./EasyOCR-Trainer/EasyOCR/user_network')
|
141 |
-
import re
|
142 |
-
input_file_path = './bounding_boxes.txt'
|
143 |
-
cropped_images_folder = './app/cropped_images/'
|
144 |
-
output_csv_path = './Folder2/' + ii + 'bounding_boxes_with_recognition.csv'
|
145 |
-
print(f"Checking contents of ./app/data: {bounding_box_save_path}")
|
146 |
-
print(f"Directory listing: {os.listdir('./app/data')}")
|
147 |
-
|
148 |
with open(input_file_path, 'r') as infile:
|
149 |
lines = infile.readlines()
|
150 |
with open(output_csv_path, 'w', newline='', encoding='utf-8') as csvfile:
|
@@ -163,11 +146,6 @@ def process_image():
|
|
163 |
else:
|
164 |
print("No bounding box found in the info.")
|
165 |
cropped_image = cv2.imread(cropped_image_path, cv2.IMREAD_GRAYSCALE)
|
166 |
-
horizontal_list1, free_list1 = reader.detect(cropped_image)
|
167 |
-
free_list1 = free_list1 if free_list1 is not None else []
|
168 |
-
horizontal_list1 = [box for sublist in horizontal_list1 for box in sublist]
|
169 |
-
free_list1 = []
|
170 |
-
horizontal_list_for_recognize = detected_boxes if not horizontal_list1 else horizontal_list1
|
171 |
recognized_text = pytesseract.image_to_string(cropped_image)
|
172 |
print(f"Recognized Text: {recognized_text}")
|
173 |
|
|
|
128 |
print(f"Checking contents of /app/data: {bounding_box_save_path}")
|
129 |
print(f"Directory listing: {os.listdir('./app/Folder1')}")
|
130 |
print(f"Bounding box coordinates saved at {bounding_box_save_path}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
with open(input_file_path, 'r') as infile:
|
132 |
lines = infile.readlines()
|
133 |
with open(output_csv_path, 'w', newline='', encoding='utf-8') as csvfile:
|
|
|
146 |
else:
|
147 |
print("No bounding box found in the info.")
|
148 |
cropped_image = cv2.imread(cropped_image_path, cv2.IMREAD_GRAYSCALE)
|
|
|
|
|
|
|
|
|
|
|
149 |
recognized_text = pytesseract.image_to_string(cropped_image)
|
150 |
print(f"Recognized Text: {recognized_text}")
|
151 |
|