python 读取摄像头数据并保存的实例

yipeiwu_com6年前Python基础

如下所示:

import cv2

cap = cv2.VideoCapture(0)

k = 0 
while k != 27: # esc 
ret, img = cap.read(0) 
cv2.imshow(‘233', img) 
k = cv2.waitKey(20) & 0xff

print( ‘begin to record images…' )

for ii in range(1000): 
ret, img = cap.read(0) 
cv2.imshow(‘233', img) 
cv2.imwrite(‘imaged%04d.jpg'%(ii), img) 
cv2.waitKey(20)

以上这篇python 读取摄像头数据并保存的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

python try except返回异常的信息字符串代码实例

问题 https://docs.python.org/3/tutorial/errors.html https://docs.python.org/3/library/exception...

pandas pivot_table() 按日期分多列数据的方法

如下所示: date 20170307 20170308 iphone4 2...

Python定时任务工具之APScheduler使用方式

APScheduler (advanceded python scheduler)是一款Python开发的定时任务工具。 文档地址 apscheduler.readthedoc...

对pandas处理json数据的方法详解

对pandas处理json数据的方法详解

今天展示一个利用pandas将json数据导入excel例子,主要利用的是pandas里的read_json函数将json数据转化为dataframe。 先拿出我要处理的json字符串:...

Python中用format函数格式化字符串的用法

自python2.6开始,新增了一种格式化字符串的函数str.format(),可谓威力十足。那么,他跟之前的%型格式化字符串相比,有什么优越的存在呢?让我们来揭开它羞答答的面纱。 语法...