Update app.py
Browse files
app.py
CHANGED
|
@@ -132,17 +132,17 @@ def main():
|
|
| 132 |
st.success(text)
|
| 133 |
elif uploaded_photo.type != "application/image":
|
| 134 |
img = Image.open(uploaded_photo)
|
| 135 |
-
img = img.save("img.
|
| 136 |
-
|
| 137 |
# get co-ordinates to crop the image
|
| 138 |
-
|
| 139 |
c = lc[1]
|
| 140 |
# cropping image img = image[y0:y1, x0:x1]
|
| 141 |
-
|
| 142 |
-
plt.figure(figsize=(10,10))
|
| 143 |
-
|
| 144 |
# convert the image to black and white for better OCR
|
| 145 |
-
ret,thresh1 = cv2.threshold(
|
| 146 |
# pytesseract image to string to get results
|
| 147 |
text = str(pytesseract.image_to_string(thresh1, config='--psm 6',lang="ben")) if st.checkbox("Bangla") else str(pytesseract.image_to_string(thresh1, config='--psm 6'))
|
| 148 |
#text = pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
|
|
|
|
| 132 |
st.success(text)
|
| 133 |
elif uploaded_photo.type != "application/image":
|
| 134 |
img = Image.open(uploaded_photo)
|
| 135 |
+
img = img.save("img.jpg")
|
| 136 |
+
imge = cv2.imread("img.jpg")
|
| 137 |
# get co-ordinates to crop the image
|
| 138 |
+
imag, lc = line_cor.mark_region(imge)
|
| 139 |
c = lc[1]
|
| 140 |
# cropping image img = image[y0:y1, x0:x1]
|
| 141 |
+
imgg = imge[c[0][1]:c[1][1], c[0][0]:c[1][0]]
|
| 142 |
+
#plt.figure(figsize=(10,10))
|
| 143 |
+
# plt.imshow(img)
|
| 144 |
# convert the image to black and white for better OCR
|
| 145 |
+
ret,thresh1 = cv2.threshold(imgg,120,255,cv2.THRESH_BINARY)
|
| 146 |
# pytesseract image to string to get results
|
| 147 |
text = str(pytesseract.image_to_string(thresh1, config='--psm 6',lang="ben")) if st.checkbox("Bangla") else str(pytesseract.image_to_string(thresh1, config='--psm 6'))
|
| 148 |
#text = pytesseract.image_to_string(img, lang="ben") if st.checkbox("Mark to see Bangla Image's Text") else pytesseract.image_to_string(img)
|