python 视频逐帧保存为图片的完整实例
作者:小呆丶 时间:2022-06-06 20:54:01
我就废话不多说了,直接上代码吧!
import cv2
import os
def save_img():
video_path = r'F:\test\video1/'
videos = os.listdir(video_path)
for video_name in videos:
file_name = video_name.split('.')[0]
folder_name = video_path + file_name
os.makedirs(folder_name,exist_ok=True)
vc = cv2.VideoCapture(video_path+video_name) #读入视频文件
c=0
rval=vc.isOpened()
while rval: #循环读取视频帧
c = c + 1
rval, frame = vc.read()
pic_path = folder_name+'/'
if rval:
cv2.imwrite(pic_path + file_name + '_' + str(c) + '.jpg', frame) #存储为图像,保存名为 文件夹名_数字(第几个文件).jpg
cv2.waitKey(1)
else:
break
vc.release()
print('save_success')
print(folder_name)
save_img()
来源:https://www.cnblogs.com/xiaodai0/p/9725159.html
标签:python,视频,逐帧,图片
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
豆瓣可以做而且值得做的几件事情
2009-04-24 12:07:00
用ASP打开远端MDB数据库
2007-10-13 06:56:00
Python实现类继承实例
2023-11-13 07:44:24
python控制nao机器人身体动作实例详解
2023-08-26 11:33:17
js实现屏蔽默认快捷键调用自定义事件示例
2023-09-05 09:28:31
Python的命令行参数实例详解
2023-06-11 09:05:45
![](https://img.aspxhome.com/file/2023/9/70029_0s.png)
PHP图片库imagemagick安装方法
2023-11-16 18:54:38
LINUX下Oracle数据库用户创建方法详解
2023-07-22 02:02:20
复习Python中的字符串知识点
2022-09-13 07:32:49
关于numpy中eye和identity的区别详解
2021-11-18 14:33:08
Python turtle绘画象棋棋盘
2022-05-06 22:48:55
![](https://img.aspxhome.com/file/2023/4/86374_0s.jpg)
python数据拟合之scipy.optimize.curve_fit解读
2021-05-27 01:48:49
![](https://img.aspxhome.com/file/2023/0/79550_0s.png)
提升你设计水平的CSS3新技术[译]
2009-08-02 20:51:00
![](https://img.aspxhome.com/file/UploadPic/up/2009080221214142.gif)
js表单检测数字
2007-10-12 13:52:00
python把数组中的数字每行打印3个并保存在文档中的方法
2022-08-13 19:15:30
![](https://img.aspxhome.com/file/2023/8/78658_0s.jpg)
asp显示左边的n个字符自动识别汉字的函数
2007-09-13 12:16:00
Python3 搭建Qt5 环境的方法示例
2022-08-17 05:12:34
![](https://img.aspxhome.com/file/2023/3/83663_0s.png)
python使用pygame实现笑脸乒乓球弹珠球游戏
2021-07-26 09:49:47
![](https://img.aspxhome.com/file/2023/3/87473_0s.jpg)
PHP引用(&)各种使用方法实例详解
2023-11-01 18:12:43
Python+Selenium实现一键摸鱼&采集数据
2021-08-22 01:05:41
![](https://img.aspxhome.com/file/2023/2/92482_0s.gif)