camera
camera 模块用于拍照。
备注
当前模块只适用于 CoreS3 主机
Micropython 案例
拍摄显示
1# SPDX-FileCopyrightText: 2024 M5Stack Technology CO LTD 2# 3# SPDX-License-Identifier: MIT 4import os, sys, io 5import M5 6from M5 import * 7import camera 8 9 10img = None 11 12def setup(): 13 global img 14 M5.begin() 15 Widgets.fillScreen(0x222222) 16 camera.init(pixformat=camera.RGB565, framesize=camera.QVGA) 17 18def loop(): 19 global img 20 M5.update() 21 img = camera.snapshot() 22 M5.Lcd.show(img, 0, 0, 320, 240) 23 24if __name__ == '__main__': 25 try: 26 setup() 27 while True: 28 loop() 29 except (Exception, KeyboardInterrupt) as e: 30 try: 31 from utility import print_error_msg 32 print_error_msg(e) 33 except ImportError: 34 print("please update to latest firmware") 35 36
UIFlow2.0 案例
拍摄显示
Functions
- camera.init(pixformat, framesize)
初始化摄像头
参数
pixformat仅接受以下值:camera.RGB565
参数
framesize仅接受以下值:camera.QQVGA: 160x120camera.QCIF: 176x144camera.HQVGA: 240x176camera.FRAME_240X240: 240x240camera.QVGA: 320x240
UIFlow2.0

- camera.snapshot() image.Iamge
获取一帧图像
返回一个
image.Image对象。UIFlow2.0

- camera.set_hmirror(enable)
开启或关闭水平镜像模式(True 表示开启,False 表示关闭)。默认为开启。
UIFlow2.0

- camera.set_vflip(enable)
开启或关闭垂直翻转模式(True 表示开启,False 表示关闭)。默认为关闭。
UIFlow2.0

- camera.get_hmirror()
返回当前是否启用了水平镜像模式。
UIFlow2.0

- camera.get_vflip()
返回当前是否启用了垂直翻转模式。
UIFlow2.0

