在Webcam Stream -Python上绘制线条

时间:2016-09-30 06:57:40

标签: python opencv

我正在尝试为网络摄像头输出画一条线。但是,我对以下代码有困难,特别是绘制线函数的“img”部分。我已经看过很多将图像添加到另一个图像的示例,所以请不要将我引用到这些示例中。这特别是网络摄像头输出输出上的线条或方块的问题。

cv2.line(img= vc, pt1= 10, pt2= 50, color =black,thickness = 1, lineType = 8, shift = 0)

以下是完整代码:

import cv2

cv2.namedWindow("preview")
vc = cv2.VideoCapture(0)

if vc.isOpened(): # try to get the first frame
    rval, frame = vc.read()
else:
    rval = False

while rval:
    cv2.imshow("preview", frame)
    rval, frame = vc.read()
    key = cv2.waitKey(20)
    if key == 27: # exit on ESC
        break
    else:
        cv2.line(img= vc, pt1= 10, pt2= 50, color =black,thickness = 1, lineType = 8, shift = 0)
vc.release()
cv2.destroyWindow("preview")

1 个答案:

答案 0 :(得分:2)

您需要在<link type="text/css" rel="stylesheet" href="/dist/css/all.css" /> 上绘制线条。请尝试以下方法:

frame