我想添加一些文本以显示在网络摄像头的视频上,但我似乎听不到。我之前使用Opencv在图像中添加了文本,但是视频中的方法似乎有所不同,所以我该怎么做。这是我的网络摄像头脚本:
import cv2
import numpy as np
# Create a VideoCapture object and read from input file
# If the input is the camera, pass 0 instead of the video file name
cap = cv2.VideoCapture(0)
# Check if camera opened successfully
if (cap.isOpened()== False):
print("Error opening video stream or file")
# Read until video is completed
while(cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
if ret == True:
# Display the resulting frame
cv2.imshow('Frame',frame)
# Press Q on keyboard to exit
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Break the loop
else:
break
# When everything done, release the video capture object
cap.release()
# Closes all the frames
cv2.destroyAllWindows()
答案 0 :(得分:1)
看看OpenCV's docs about putText。这是我做的一个快速技巧,目的是显示一些边界框标签:
<form id='main'>
i1: "#333", i2: "#000"<input id='i0' type='radio' name='rad'><br> i1: "#333"<input id='i1' type='radio' name='rad'> <br> i2: "#000"<input id='i2' type='radio' name='rad'> <br> {}
<input id='i3' type='radio' name='rad'> <br>
</form>
在您的代码中应执行以下操作:
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//."));
您是否以某种方式在调用imshow之后绘制了 ?我看不出视频的行为有何不同。