1 Star 0 Fork 101

小码编程AI / self_drive

forked from Timthony / self_drive 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
collectdata_zth 835 Bytes
一键复制 编辑 原始数据 按行查看 历史
Timthony 提交于 2018-09-29 22:41 . 注释
import io
import os
import threading
import time
import picamera
class SplitFrames(object):
def __init__(self):
self.frame_num = 0
self.output = 0
# 处理图像的函数write,实时保存每一张照片
# 对视频拍摄的每一帧进行处理,构造一个自定义输出类,每拍摄一帧都会进来write处理
def write(self, buf):
global key
if buf.startswith(b'\xff\xd8'): # 代表一个JPG图片的开始,新照片的开头
if self.output:
self.output.close()
self.frame_num += 1
self.output = io.open('%s_image%s.jpg' % (key, time()), 'wb') # 打开
self.output.write(buf)
while True:
# 多线程处理照片
#with picamera.Picamera(resolution=('160, 120')) as camera:
#pass
Python
1
https://gitee.com/small_code_programming_ai/self_drive.git
git@gitee.com:small_code_programming_ai/self_drive.git
small_code_programming_ai
self_drive
self_drive
master

搜索帮助