✨博客主页:米开朗琪罗~
✨博主爱好:羽毛球
✨年轻人要:Living for the moment(活在当下)!
推荐专栏:【图像处理】【千锤百炼Python】【深度学习】【排序算法】
话不多说,直接看代码!
import cv2
cap = cv2.VideoCapture(0)
while(True):
ret, frame = cap.read()
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
贴一张博主用代码得到的视频截图吧!(浅浅的做了个P图)
通过下面的程序就可以读取视频啦!
import cv2
cap = cv2.VideoCapture('C:\\Users\\Lenovo\\Desktop\\LLDZ.mp4')
while cap.isOpened():
ret, frame = cap.read()
video = cv2.cvtColor(frame, 1)
video = cv2.resize(video, (641, 360))
cv2.imshow('frame', video)
if cv2.waitKey(1) == ord('q'):
break
cap.release()
cv2.destroyAllWindows()