在python上使用坐标画框

 	img = Image.open(img_fpath) 
    a = ImageDraw.ImageDraw(img)  
    x1=bbox[0]
    y1=bbox[1]
    x2=bbox[2]
    y2=bbox[3]
    a.rectangle(((x1, y1),(x2, y2)), fill=None, outline='red', width=5)  
    fnt = ImageFont.truetype('1.ttf',40)
    a.text((x1, y1), str(i), fill='green', font=fnt)
    img_fpath = img_fpath.replace("image", 'out') 
    img.save(img_fpath)

你可能感兴趣的:(Python,python)