在图片上画矩形框

 

 

import matplotlib.pyplot as plt
import matplotlib.patches as mpatches

# draw rectangles on the original image
fig, ax = plt.subplots(ncols=1, nrows=1, figsize=(6, 6))
ax.imshow(img)
for x, y, w, h in candidates:
    print(x, y, w, h)
    rect = mpatches.Rectangle(
        (x, y), w, h, fill=False, edgecolor='red', linewidth=1)
    ax.add_patch(rect)
posted @ 2020-01-10 19:56  悦悦的小屋  阅读(664)  评论(0编辑  收藏  举报