Vikas01 commited on
Commit
6815466
·
1 Parent(s): b39907d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -1,9 +1,10 @@
1
  import numpy as np
2
  import cv2
3
  import imutils
4
- import easyocr
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
- # Initialize the OCR reader
50
- reader = easyocr.Reader(['en'])
51
-
52
- # Run OCR on the cropped image
53
- results = reader.readtext(new_img, detail=0)
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()