Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
import numpy as np
|
2 |
import cv2
|
3 |
import imutils
|
4 |
-
import
|
5 |
import pandas as pd
|
6 |
import time
|
|
|
7 |
|
8 |
from PIL import Image
|
9 |
import streamlit as st
|
@@ -46,14 +47,12 @@ if img_file_buffer is not None:
|
|
46 |
# Display the image with contours
|
47 |
st.image(image_with_contours, caption="Image with detected license plate")
|
48 |
|
49 |
-
#
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
# Concatenate the recognized text as a single string
|
56 |
-
text = ' '.join(results)
|
57 |
|
58 |
# Data is stored in CSV file
|
59 |
raw_data = {'date': [time.asctime(time.localtime(time.time()))], 'v_number': [text]}
|
@@ -67,5 +66,4 @@ if img_file_buffer is not None:
|
|
67 |
st.write(text)
|
68 |
|
69 |
if bytes_data is None:
|
70 |
-
st.stop()
|
71 |
-
|
|
|
1 |
import numpy as np
|
2 |
import cv2
|
3 |
import imutils
|
4 |
+
import pytesseract
|
5 |
import pandas as pd
|
6 |
import time
|
7 |
+
import os
|
8 |
|
9 |
from PIL import Image
|
10 |
import streamlit as st
|
|
|
47 |
# Display the image with contours
|
48 |
st.image(image_with_contours, caption="Image with detected license plate")
|
49 |
|
50 |
+
# Configuration for tesseract
|
51 |
+
tesseract_path = os.path.abspath("tessract/tesseract.exe")
|
52 |
+
pytesseract.pytesseract.tesseract_cmd = tesseract_path
|
53 |
+
|
54 |
+
# Run tesseract OCR on the cropped image
|
55 |
+
text = pytesseract.image_to_string(new_img, lang="eng")
|
|
|
|
|
56 |
|
57 |
# Data is stored in CSV file
|
58 |
raw_data = {'date': [time.asctime(time.localtime(time.time()))], 'v_number': [text]}
|
|
|
66 |
st.write(text)
|
67 |
|
68 |
if bytes_data is None:
|
69 |
+
st.stop()
|
|