I am using easyocr to detect mrz of passport:
.py code:
import easyocr
import cv2
reader = easyocr.Reader(['en'], gpu=False)
result = reader.readtext(gray)
for detection in result:
text = detection[1]
print(text.upper(), end="")
# PCSDNKHADIGA<ABAKAR<BABIKER<MUS****<<<<<<<<<***************************<<<<<<<<<<<<<<<*
I want to save result in variable, problem is when i use 's = (text.replace('\n', ''))' and print 's' the result not all is the same line Like:
PCSDNKHADIGA<ABAKAR<BABIKER
<MUS***<<<<<<<<<
*****************<<<<<<<<<<<<<<<*
How to save all result to variable and then print it at same line?
Any kind of help please?
Use this code to achive the result in single line
temp = ''
for detection in result:
text = detection[1]
temp = temp + text.strip() # this will strip spaces at the end .. use it for
# other special characters according to your text.
print(temp.upper(), end="")