Sanjayraju30 commited on
Commit
dfdfb26
·
verified ·
1 Parent(s): 7aa5221

Update ocr_engine.py

Browse files
Files changed (1) hide show
  1. ocr_engine.py +4 -4
ocr_engine.py CHANGED
@@ -3,7 +3,7 @@ import pytesseract
3
  from PIL import Image
4
 
5
  def extract_weight(img_path):
6
- img = cv2.imread(img_path)
7
- gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
8
- text = pytesseract.image_to_string(gray, config='--psm 7 digits')
9
- return ''.join(filter(lambda x: x in '0123456789.', text))
 
3
  from PIL import Image
4
 
5
  def extract_weight(img_path):
6
+ img = cv2.imread(img_path)
7
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
8
+ text = pytesseract.image_to_string(gray, config='--psm 7 digits')
9
+ return ''.join(filter(lambda x: x in '0123456789.', text))