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 12 13def setup(): 14 global img 15 M5.begin() 16 Widgets.fillScreen(0x222222) 17 camera.init(pixformat=camera.RGB565, framesize=camera.QVGA) 18 19 20def loop(): 21 global img 22 M5.update() 23 img = camera.snapshot() 24 M5.Lcd.show(img, 0, 0, 320, 240) 25 26 27if __name__ == "__main__": 28 try: 29 setup() 30 while True: 31 loop() 32 except (Exception, KeyboardInterrupt) as e: 33 try: 34 from utility import print_error_msg 35 36 print_error_msg(e) 37 except ImportError: 38 print("please update to latest firmware")
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

