import camera
The camera module initializes an ESP32 camera sensor, captures frames, reports frame and memory status, and exposes named pin presets for common camera boards. Use a preset name for known hardware, or pass a JSON config string when a board needs custom wiring.
Quick example
import camera
camera.begin("xiao_s3_sense")
camera.capture()
print(camera.info())
camera.release()
custom = camera.config("xiao_s3_sense")
camera.begin(custom)
importcamera
Camera native Berry module.
The camera module initializes an ESP32 camera sensor, captures frames, reports frame and memory status, and exposes named pin presets for common camera boards. Use a preset name for known hardware, or pass a JSON config string when a board needs custom wiring.
camera.begin(config_json_or_preset: str) -> bool
camera.begin(config_json_or_preset: str) -> boolInitialize the camera from a named preset or JSON config.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
config_json_or_preset |
str |
positional | Yes | Preset name such as "xiao_s3_sense", "esp32s3_wroom", "esp32s3_eye", "esp32s3_goouuu", "ai_thinker", or a JSON camera config string with explicit pins. |
bool True when the camera initializes successfully.
camera.end() -> any
camera.end() -> anyStop the camera driver and release any captured frame.
any Native end result.
camera.deinit() -> any
camera.deinit() -> anyAlias for end().
any Native deinit result.
camera.ready() -> bool
camera.ready() -> boolReturn whether the camera driver is initialized.
bool True when the camera is ready for capture.
camera.capture() -> bool
camera.capture() -> boolCapture one frame and hold it until release() is called.
bool True when a frame is captured successfully.
camera.release() -> any
camera.release() -> anyRelease the currently held camera frame.
any Native release result.
camera.save(path: str) -> bool
camera.save(path: str) -> boolSave the currently held frame to a filesystem path.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
path |
str |
positional | Yes | Destination path for the captured frame. |
bool True when the frame is written successfully.
camera.capture_save(path: str) -> bool
camera.capture_save(path: str) -> boolCapture a frame and save it to a filesystem path.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
path |
str |
positional | Yes | Destination path for the captured frame. |
bool True when capture and save both succeed.
camera.set(name: str, value: any) -> bool
camera.set(name: str, value: any) -> boolSet a camera sensor option.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
name |
str |
positional | Yes | Sensor option name, such as brightness, contrast, saturation, hmirror, or vflip. |
value |
any |
positional | Yes | Integer value for the option. |
bool True when the option is applied successfully.
camera.flash(pin: int, value: bool) -> bool
camera.flash(pin: int, value: bool) -> boolSet a GPIO flash or LED pin high or low.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
pin |
int |
positional | Yes | Output GPIO pin. |
value |
bool |
positional | Yes | Truthy value turns the pin on, falsey value turns it off. |
bool True when the pin is configured and written successfully.
camera.info() -> dict
camera.info() -> dictReturn camera status, frame details, active config, and memory information.
dict Map-like value with initialized, captured, frame_width, frame_height, frame_len, config_source, heap_free, and psram_free.
camera.preset(name: str) -> str
camera.preset(name: str) -> strReturn the JSON config string for a named camera preset.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
name |
str |
positional | Yes | Preset name or alias. |
str JSON config string that can be passed to begin().
camera.config(name: str) -> str
camera.config(name: str) -> strAlias for preset().
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
name |
str |
positional | Yes | Preset name or alias. |
str JSON config string that can be passed to begin().
camera.preset_info(name: str) -> dict
camera.preset_info(name: str) -> dictReturn details for a named camera preset.
| Name | Type | Pass as | Required | Description |
|---|---|---|---|---|
name |
str |
positional | Yes | Preset name or alias. |
dict Map-like value with name, aliases, target, description, and config.
camera.presets() -> dict
camera.presets() -> dictReturn the available built-in camera presets.
dict Map-like value from preset name to short description.