绘图函数(线,圆,方形)

画线:

import numpy as np
import cv2 as cv

cap = cv.VideoCapture(0)
while True:
    ret, frame = cap.read()
    # 参数ret 为True 或者False,代表有没有读取到图片
    # 参数frame 表示截取到一帧的图片

    # 画线 第一个参数 图像的对象
    # 第二个参数 线的起始点
    # 第三个参数 线的中值点
    # 第四个参数 线的颜色(RGB组合)
    # 第五个参数 线的粗细
    cv.line(frame, (0, 0), (260, 100), (255, 0, 0), 3)
    cv.line(frame, (0, 0), (260, 200), (0, 255, 0), 6)
    cv.line(frame, (0, 0), (260, 300), (0, 0, 255), 9)
    cv.line(frame, (0, 0), (260, 400), (255, 255, 255), 12)

    cv.imshow('frame', frame)  # 显示帧图片

    if cv.waitKey(1) == 27:  # 与上0xff还是原始值,这里是来取waiKey返回值的低八位,防止出现bug
        break
cap.release()  # 释放图像资源
cv.destroyAllWindows()  # 关闭窗口

 

posted @ 2020-10-06 22:39  采风远行  阅读(279)  评论(0编辑  收藏  举报