读取图片数据
# image_path => 图片路径
img = cv2.imread(image_path)
画框
# img => 图片数据;
# left_top => (最左,最上) 是个tuple;
# right_bottom => [最右,最下] 是个tuple;
# (0, 0, 255) => rgb 颜色;
# 3 => 粗细程度
cv2.rectangle(img, left_top, right_bottom, (0, 0, 255), 3)
写字
# img => 图片数据;
# key => 需要显示的信息;
# (x, y) => 给定一个元组 里面给定点坐标 x, y;
# cv2.FONT_HERSHEY_COMPLEX_SMALL => 模式;
# 0.8 => 字体粗细;
# (0, 0, 255) => rgb 颜色;
cv2.putText(img, key, (x, y), cv2.FONT_HERSHEY_COMPLEX_SMALL, 0.8, (255, 0, 0))
保存图片
# target_path => 保存路径
# img => 图片数据
cv2.imwrite(save_path, img)