多帧图像转为视频
程序员文章站
2022-03-31 20:54:06
...
使用的opencv版本是3.4,图片的名称为0001.jpg,0002.jpg,……2409.jpg.
import cv2
fps = 25 #视频帧率
fourcc = cv2.VideoWriter_fourcc('M','J','P','G')
videoWriter = cv2.VideoWriter('/home/jianyuchen/flownet2-master/flownet2-tool/flow/video13.avi', fourcc, fps, (1280,720)) #(1360,480)为视频大小
for i in range(1,2410):
if i<10:
p1 = 'flow_y_000'
p2 = i
img = cv2.imread('/home/jianyuchen/flownet2-master/flownet2-tool/flow/video13/'+str(p1)+str(p2)+'.jpg')
if 10<=i<100:
p1 = 'flow_y_00'
p2 = i
img = cv2.imread('/home/jianyuchen/flownet2-master/flownet2-tool/flow/video13/'+str(p1)+str(p2)+'.jpg')
if 100<=i<1000:
p1 = 'flow_y_0'
p2 = i
img = cv2.imread('/home/jianyuchen/flownet2-master/flownet2-tool/flow/video13/'+str(p1)+str(p2)+'.jpg')
if i>=1000:
p1= 'flow_y_'
p2 = i
img = cv2.imread('/home/jianyuchen/flownet2-master/flownet2-tool/flow/video13/'+str(p1)+str(p2)+'.jpg')
# cv2.imshow('img', img12)
# cv2.waitKey(1000/int(fps))
videoWriter.write(img)
videoWriter.release()
上一篇: 将avi视频转换为多帧的dicom图
下一篇: 数值分析中MATLAB的应用
推荐阅读
-
小米星空拍摄专利公布,可融合多帧采样图像
-
小米星空拍摄专利公布,可融合多帧采样图像
-
Find X2系列配独立图像处理芯片:30帧视频能最高升级至120帧
-
将Matplotlib可视化的连续帧的图像转化为视频(代码简单且直接可用)
-
Python cv指定间隔截取视频帧并保存图像到指定路径
-
Youtube扒视频+ffmpeg批量将 png图像转换为avi、MP4以及将avi、MP4转换为单帧图像
-
Find X2系列配独立图像处理芯片:30帧视频能最高升级至120帧
-
将Matplotlib可视化的连续帧的图像转化为视频(代码简单且直接可用)
-
《itk实用demo》-多帧DCM转序列图像
-
将avi视频转换为多帧的dicom图