如何修复边界框中的文本大小?
我是计算机视觉的新手。我正在努力修复文本周围的边界框的大小。
这是示例代码
#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')
我想将边界框大小调整到相同的大小。因此,当我粘贴翻译文本时,它将被一行对齐。
我可以在这部分上做一些更改,以便将翻译的文本在一行中对齐,
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 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论