代码拉取完成,页面将自动刷新
同步操作将从 lantsang/stm32-camera 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
'''
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()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。