1 Star 0 Fork 6

七夜星雨/stm32-camera

forked from lantsang/stm32-camera 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
bluestone_camera.py 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
lantsang 提交于 2021-04-26 14:16 . 支持串口设置
'''
File: bluestone_camera.py
Project: bluestone esp32 camera
Author: daniel dong
Email: dongzhenguo@lantsang.cn
Copyright 2021 - 2021 bluestone tech
'''
import camera
import machine
import time
# logging.basicConfig(level = logging.INFO)
# _main_log = logging.getLogger("MAIN")
class BlueStoneCamera(object):
inst = None
def __init__(self):
BlueStoneCamera.inst = self
self.file_name = 'number.txt'
self.led = machine.Pin(4, machine.Pin.OUT)
def take_one_picture(self, image_file):
camera.init()
self.led.on()
time.sleep(0.5)
buf = camera.capture()
self.led.off()
camera.deinit()
with open(image_file, 'wb') as f:
f.write(buf)
def start_capture(self):
time.sleep(5)
number = None
with open(self.file_name, 'w+') as f:
number = f.read()
print('Number is {}'.format(number))
if not number:
number = 1
self.take_one_picture('sd/Image' + str(number) + '.jpg')
new_number = int(number) + 1
print('New number is {}'.format(new_number))
with open(self.file_name, 'w') as f:
f.write(str(new_number))
#machine.deepsleep()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/seven-night-star-rain/stm32-camera.git
git@gitee.com:seven-night-star-rain/stm32-camera.git
seven-night-star-rain
stm32-camera
stm32-camera
master

搜索帮助