I am new to computer vision. I am struggling to fix the size of the bounding box around the text.
Here is the sample code
#extracting text using easyocr
output = reader_hi.readtext('/content/drive/MyDrive/hindi_image.jpg')
#translating words to other indian languages
#removing text from images
#this is the code where I am pasting the translated words
image = Image.open("image.jpg")#text removed from the image
#red color
color = (0, 0, 255)
thickness = 1
fontpath = "/content/drive/MyDrive/ArialTh.ttf"
TEXT_Font = ImageFont.truetype(fontpath, 16)
draw = ImageDraw.Draw(image)
i=0
for bound in output:
tl, tr, br, bl = bound[0]
tl = (int(tl[0]), int(tl[1]))
tr = (int(tr[0]), int(tr[1]))
br = (int(br[0]), int(br[1]))
bl = (int(bl[0]), int(bl[1]))
draw.text(tl, translation[i], font = TEXT_Font, align='left', fill='black')
i=i+1
image.save('image_translation.jpg')
I would like to resize the bounding box to same size. So that when I paste the translated text it would be aligned in one line.
Can I do some changes in this part so that the translated text will be aligned in one line
for bound in output:
tl, tr, br, bl = bound[0]
tl = (int(tl[0]), int(tl[1]))
tr = (int(tr[0]), int(tr[1]))
br = (int(br[0]), int(br[1]))
bl = (int(bl[0]), int(bl[1]))
draw.text(tl, translation[i], font = TEXT_Font, align='left', fill='black')
Is there some other way to make the text fall in one line.