1 回答
TA贡献1824条经验 获得超6个赞
我怀疑这是由于cv2.putText不兼容np.array是的返回值np.fliplr(frame)。我建议你frame = cv2.flip(frame, 1)改用。
import numpy as np
import cv2
import platform
if __name__ == "__main__":
print("python version:", platform.python_version())
cap = cv2.VideoCapture(0)
while(True):
# Capture frame-by-frame
ret, frame = cap.read()
cv2.putText(frame,'Hello World : Before flip',(100, 100), cv2.FONT_HERSHEY_SIMPLEX, 1,(255,255,255),2,cv2.LINE_AA)
frame = cv2.flip(frame, 1)
cv2.putText(frame,'Hello World : After flip',(100, 200), cv2.FONT_HERSHEY_SIMPLEX, 1,(255,255,255),2,cv2.LINE_AA)
# Process the keys
key = cv2.waitKey(1) & 0xFF
if key == ord('q'):
print("quit")
break
# show the images
cv2.imshow('frame',frame)
cap.release()
cv2.destroyAllWindows()
添加回答
举报