#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/7/2 13:32
# @Author : xiaodai
# -*- coding: UTF-8 -*-
import os
import cv2
from tqdm import tqdm
from multiprocessing import Pool # 图片合成视频
def pic_to_video(path,save_path,time_dir):
filelist = os.listdir(path) #获取该目录下的所有文件名
writer = None
print('-------->',path,save_path)
for item in tqdm(filelist):
if item.endswith('.jpg'): #判断图片后缀是否是.jpg
item = path + '/' + item
img = cv2.imread(item) #使用opencv读取图像,直接返回numpy.ndarray 对象,通道顺序为BGR ,注意是BGR,通道值默认范围0-255。
if writer is None:
fourcc = cv2.VideoWriter_fourcc(*"MJPG")
writer = cv2.VideoWriter(save_path+'/'+time_dir+'.mp4', fourcc, 16,
(img.shape[1], img.shape[0]), True)
if writer is not None:
writer.write(img) if __name__ == '__main__':
org_path = r"F:\temp\test"
for cam_name in os.listdir(org_path):
cam_path = os.path.join(org_path,cam_name)
p = Pool(8)
for time_dir in os.listdir(cam_path):
path = os.path.join(cam_path,time_dir,'JPEGImages')
save_path = os.path.join(cam_path,time_dir,'JPEGImages')
os.makedirs(save_path,exist_ok=True)
p.apply_async(pic_to_video, args=(path, save_path,time_dir,))
p.close()
p.join()

原文:https://blog.csdn.net/Hss891213/article/details/82468268

最新文章

  1. c#一个泛型控制Textbox 和label 控件 泛型方法。
  2. jboss:在standalone.xml中设置系统属性(system-properties)
  3. 手机端开发icon的问题
  4. C# 如何查看源程序的IL代码
  5. 使用CSC.EXE编译第一个HELLO WORLD
  6. Oracle得知(十五):分布式数据库
  7. protobuf代码生成
  8. 运行React-Native项目
  9. linux内核中断之看门狗
  10. Three.js学习笔记02
  11. 前端开发【第四篇: Dom操作】
  12. luogu P1268 树的重量
  13. 奇怪吸引子---GenesioTesi
  14. Android之把eoe客户端的关联ViewPager的滑动条勾出来使用
  15. 解释一下文件/etc/fstab的内容
  16. 解决NSImage绘制的时候图像模糊
  17. Java - io输入输出流 --转换流
  18. git 和github
  19. JavaScript DOM编程艺术学习笔记-第二章JavaScript语法
  20. 【leetcode刷题笔记】Permutation Sequence

热门文章

  1. 转载【oracle切换表空间】
  2. 定期删除IIS日志文件
  3. GraphQL学习之原理篇
  4. CentOS 7中安装和配置Promethues
  5. 最新 腾讯java校招面试题(含整理过的面试题大全)
  6. ios客户端浏览器样式加载失效问题
  7. 缓存利器之Ehcache
  8. JVM —— 类文件结构(上)
  9. 【转】Linux下查看CPU、内存、磁盘信息
  10. 新浪sae对storage的文档进行读写操作