Is there a way to reading text from an image from a specific fixed location?
def read_image_data(request):
import cv2
import pytesseract
pytesseract.pytesseract.tesseract_cmd = "C:/Program Files/Tesseract-OCR/tesseract.exe"
img = cv2.imread("workcenter_dash.png")
text = pytesseract.image_to_string(img)
print(text)
In above example I used "pytesseract" to read image text which working fine for reading text, But in my case I want read text from specificed location.
For Example: In the above image, I want to read text from only where selected with a red rectangle.
So please give me the best solutions regarding this. Thanks in advance.
I'm fixed this issue by cropping the image then after reading its data.
It's working for me, Any better solutions for this issue so please suggest me.
def read_image_data(request):
import cv2
import pytesseract
pytesseract.pytesseract.tesseract_cmd = "C:/Program Files/Tesseract-OCR/tesseract.exe"
img = cv2.imread("workcenter_dash.png")
height, width = img.shape[0:2]
startRow = int(height * 0.10)
startCol = int(width * 0.10)
endRow = int(height * 0.90)
endCol = int(width * 0.40)
croppedImage = img[startRow:endRow, startCol:endCol]
text = pytesseract.image_to_string(croppedImage)
print(text)