我正在尝试为图像绘制一个框,但它不是预期的。请建议如何实现。
代码:
import numpy as np
bounds=[]
for i in range(len(images)):
bounds.append(reader.readtext(np.array(images[i]),min_size=0,slope_ths=0.2,ycenter_ths=0.7,height_ths=0.6,width_ths=0.8,decoder='beamsearch'))
#final.append(bounds)
在上面的代码中,有 13 个图像(图像被转换为简历 pdf),我已经附加到 bounds 变量中 #Now 想要为这些图像绘制边界,但是 o/p 根本不起作用。
代码:
import PIL
from PIL import ImageDraw
def draw_boxes(image,bounds,color='yellow',width=4):
draw=ImageDraw.Draw(image)
for bound in bounds:
p0,p1,p2,p3=bound[0]
draw.line([*p0,*p1,*p2,*p3],fill=color,width=width)
return image
执行:draw_boxes(images 1 ,bound)
结果:什么也没发生。输出/输出