opencv-python教程

1. 加bound box

  • gray-scale
img = cv2.rectangle(img, (point_1_x, point_1_y), (point_2_x, point_2_y), color=img.max(), thickness=1)

plt.imshow(img, cmap="gray")

如果想在gray-scale上加彩色bounding box:

img = np.dstack([img_arr, img_arr, img_arr])*255  # img_arr为[0,1]之间的灰度图

img = cv2.rectangle(img, (point_1_x, point_1_y), (point_2_x, point_2_y), color=(255, 0, 0), thickness=1)

plt.imshow(img, cmap="color")
  • rgb: 直接参照上面的
img = cv2.rectangle(img, (point_1_x, point_1_y), (point_2_x, point_2_y), color=(255, 0, 0), thickness=1)

plt.imshow(img, cmap="color")
©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页