# 获取视频设备,0表示调用摄像头,地址表示调用本地的视频,视频用/
cap = cv2.VideoCapture(0)
cap = cv2.VideoCapture('F:/sers/20848/Desktop/184734-873923034_small.mp4')
while True:
# 从摄像头读视频帧
ret, frame = cap.read()
# 将视频帧在窗口中显示
cv2.imshow('video', frame)
# 等待键盘事件,如果为q,退出
key = cv2.waitKey(0)
if (key & 0xFF == ord('q')):
break
# 释放VideoCapture
cap.release()
cv2.destroyAllWindows()
opencv视频学习记录
最新推荐文章于 2024-05-20 22:37:12 发布