camera
The camera module is used for taking pictures.
备注
This module is only applicable to the CoreS3 Controller
Micropython Example
capture display
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 Example
capture display
Functions
- camera.init(pixformat, framesize)
Initializes the camera sensor.
The
pixformatsupports:camera.RGB565
The
framesizesupports:camera.QQVGA: 160x120camera.QCIF: 176x144camera.HQVGA: 240x176camera.FRAME_240X240: 240x240camera.QVGA: 320x240
UIFlow2.0

- camera.snapshot() image.Iamge
Capture a single frame.
Returns An
image.Imageobject.UIFlow2.0

- camera.set_hmirror(enable)
Turns horizontal mirror mode on (True) or off (False). Defaults to on.
UIFlow2.0

- camera.set_vflip(enable)
Turns vertical flip mode on (True) or off (False). Defaults to off.
UIFlow2.0

- camera.get_hmirror()
Returns if horizontal mirror mode is enabled.
UIFlow2.0

- camera.get_vflip()
Returns if vertical flip mode is enabled.
UIFlow2.0

