Python cv2,将文本放在网络摄像头捕获中

Python cv2, putting text on webcam capture

我是 Python 初学者。我设法制作了一个网络摄像头捕获程序,但我想在此 window 上放一些文字。我找到了 .putText() 方法。但是我无法让它工作。所以我知道我不应该这样做,但我别无选择......这是完整的代码:

import cv2

video = cv2.VideoCapture(0)
a = 0
img_counter = 0
videoNpArr = cv2.imread("test-image.jpg")

while True:

    a = a + 1
    check, frame = video.read()

    print(check)
    print(frame)

    cv2.putText(videoNpArr, "Hello World!!!", (200, 200), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255))

    cv2.imshow("Main frame thing", frame)

    # cv2.waitKey(0)
    key = cv2.waitKey(1)

    if key == ord('q'):
        break
    elif key == ord('i'):
        # SPACE pressed
        img_name = "opencv_frame_{}.png".format(img_counter)
        cv2.imwrite(img_name, frame)
        print("{} written!".format(img_name))
        img_counter += 1
    print(a)

video.release()
cv2.destroyAllWindows()

如有任何帮助,我将不胜感激。 <3

改变

cv2.putText(videoNpArr, "Hello World!!!", (200, 200), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255))

cv2.putText(frame, "Hello World!!!", (200, 200), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255))