本站改版新增arduino频道
micropython的esp32-cam入门学习
import camera
# 初始化摄像头
try:
camera.init(0, format=camera.JPEG)
except Exception as e:#如果报错
camera.deinit()
camera.init(0, format=camera.JPEG)
# 拍摄一张图片
buf = camera.capture() # 大小是640x480
# 保存图片到文件
with open("第一张图片.png", "wb") as f:
f.write(buf) # buf中的数据就是图片的数据,所以直接写入到文件就行了
print("拍照已完成,点击Thonny左侧【MicroPython设备】右侧的三,\n然后看到‘刷新’,点击刷新会看到 图片,\n然后右击图片名称,选择下载到电脑的路径即可...")
camera.deinit()参考来源:https://doc.itprojects.cn/0006.zhishi.esp32/02.doc/index.html#/e02.debuginit
Copyright © 2014 ESP56.com All Rights Reserved
晋ICP备14006235号-22 晋公网安备14108102001165号
执行时间: 0.0094401836395264 seconds