import cv2 import matplotlib.pyplot as plt import numpy as np
vc = cv2.VideoCapture('test.mp4') #检测打开是否正确 if vc.isOpened(): open,frame = vc.read() else: open = False
while open: ret,frame = vc.read() if frame is None: break if ret ==True: gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) cv2.imshow('result',gray) if cv2.waitKey(1) &0xFF == 27: break