MojoScale Studio Docs
API Reference

camera

Camera native Berry module.

Studio Docs Sensors & I/O

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.

API 15 available

camera.begin(config_json_or_preset: str) -> bool

Initialize the camera from a named preset or JSON config.

Parameters
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.
Returns

bool True when the camera initializes successfully.

camera.end() -> any

Stop the camera driver and release any captured frame.

Returns

any Native end result.

camera.deinit() -> any

Alias for end().

Returns

any Native deinit result.

camera.ready() -> bool

Return whether the camera driver is initialized.

Returns

bool True when the camera is ready for capture.

camera.capture() -> bool

Capture one frame and hold it until release() is called.

Returns

bool True when a frame is captured successfully.

camera.release() -> any

Release the currently held camera frame.

Returns

any Native release result.

camera.save(path: str) -> bool

Save the currently held frame to a filesystem path.

Parameters
Name Type Pass as Required Description
path str positional Yes Destination path for the captured frame.
Returns

bool True when the frame is written successfully.

camera.capture_save(path: str) -> bool

Capture a frame and save it to a filesystem path.

Parameters
Name Type Pass as Required Description
path str positional Yes Destination path for the captured frame.
Returns

bool True when capture and save both succeed.

camera.set(name: str, value: any) -> bool

Set a camera sensor option.

Parameters
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.
Returns

bool True when the option is applied successfully.

camera.flash(pin: int, value: bool) -> bool

Set a GPIO flash or LED pin high or low.

Parameters
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.
Returns

bool True when the pin is configured and written successfully.

camera.info() -> dict

Return camera status, frame details, active config, and memory information.

Returns

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

Return the JSON config string for a named camera preset.

Parameters
Name Type Pass as Required Description
name str positional Yes Preset name or alias.
Returns

str JSON config string that can be passed to begin().

camera.config(name: str) -> str

Alias for preset().

Parameters
Name Type Pass as Required Description
name str positional Yes Preset name or alias.
Returns

str JSON config string that can be passed to begin().

camera.preset_info(name: str) -> dict

Return details for a named camera preset.

Parameters
Name Type Pass as Required Description
name str positional Yes Preset name or alias.
Returns

dict Map-like value with name, aliases, target, description, and config.

camera.presets() -> dict

Return the available built-in camera presets.

Returns

dict Map-like value from preset name to short description.