import cv2def vIDeo2image():vc= cv2.VIDeoCapture('test.avi' )c=1# 如果视频打开成功每隔100帧数保存一个图片if vc.isOpened() :rval, frame = vc.read ()else:rval = FalsetimeF = 1000while rval :rval, frame = vc. read ()if c%100==0:cv2.imwrite (' image/' + str(c) + '. jpg', frame)c=c+ 1cv2.waitKey (1)vc. release ()import globimport osimport cv2def images2vIDeo(image_dir,save_name):fps=24fourcc=cv2.VIDeoWriter_fourcc(*"MJPG")vIDeo_w=cv2.VIDeoWriter(save_name,fourcc,fps,(640,480))# 扫描文件夹中所有jpg文件images=glob.glob(os.path.join(image_dir,"*.jpg"))for i in range(len(images)):# 选中名为"image_{:03d}.jpg".format(1) =image_001.jpgimage_name=os.path.join(image_dir,"image_{:03d}.jpg".format(i))frame=cv2.imread(image_name)vIDeo_w.write(frame)vIDeo_w.release()总结
以上是内存溢出为你收集整理的opencv-python视频处理之图片变成视频,视频切成图片全部内容,希望文章能够帮你解决opencv-python视频处理之图片变成视频,视频切成图片所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)