pdf-icon

Camera

The M5CoreS3 is equipped with a 300,000-pixel camera, GC0308. Refer to the API & examples below to capture images.

begin()

Description:

  • Initializes the camera

Prototype:

bool begin()

Parameters:

  • None

Return Values:

Return Value Description
true Initialization successful
false Initialization failed

get()

Description:

  • Retrieves a frame of image data

Prototype:

bool get()

Parameters:

  • None

Return Values:

Return Value Description
true Image retrieval successful
false Image retrieval failed

free()

Description:

  • Frees the current image data memory

Prototype:

bool free()

Parameters:

  • None

Return Values:

Return Value Description
true Image resource freed successfully
false No resources to free

Example:

#include "M5CoreS3.h"
#include "esp_camera.h"

void setup() {
    auto cfg = M5.config();
    CoreS3.begin(cfg);

    if (!CoreS3.Camera.begin()) {
        Serial.println("Camera Init Fail");
    }
    Serial.println("Camera Init Success");

    CoreS3.Camera.sensor->set_framesize(CoreS3.Camera.sensor, FRAMESIZE_QVGA);
}

void loop() {
    if (CoreS3.Camera.get()) {
        CoreS3.Display.pushImage(0, 0, CoreS3.Display.width(),
                                 CoreS3.Display.height(),
                                 (uint16_t *)CoreS3.Camera.fb->buf);
        CoreS3.Camera.free();
    }
}
On This Page