import cv2 videoFile = ‘data/最强大脑.mp4‘ cap = cv2.VideoCapture(videoFile) frameNum = 0 while (cap.isOpened()): ret, frame = cap.read() frameNum = frameNum + 1 if frameNum % 2 == 0: # 调整帧数 cv2.imwrite(‘image/output/vieo1_‘ + str(frameNum) + ".jpg", frame) # 保存图片 cv2.namedWindow("resized", 0) # 0可以改变窗口大小了 # cv2.resizeWindow("resized", 640, 480) # 设置固定大小不能该,上面和一起使用 cv2.imshow("resized", frame) # 显示视频 if cv2.waitKey(1) & 0xFF == ord(‘q‘): break cap.release cv2.destroyAllWindows()
原文地址:https://www.cnblogs.com/jumpkin1122/p/11509786.html
时间: 2024-11-09 21:13:56