我是Python初学者。我设法制作了一个网络摄像头捕获程序,但是我想在此窗口中放一些文字。我找到了.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
答案 0 :(得分:0)
更改
data.classID = id;
new course(data).save((error) => {
if(error){
console.log('oops! Could not save course');
} else {
conn3.close();
}
});
//update instructor's classID's variable in intructor database
instructor.findOne({"instructorEmail":data.Instructor}, (err,x)=>{
var arr = x.classIDs;
arr.push(id);
instructor.findOneAndUpdate({"instructorEmail":data.Instructor},{$set:{classIDs: arr}});
})
到
cv2.putText(videoNpArr, "Hello World!!!", (200, 200), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 255))