pdf-icon

Arduino 上手教程

CoreS3 Camera 摄像头

功能说明
M5CoreS3内置了一个30w像素的摄像头GC0308, 参考下方API & 案例即可实现图像获取。

案例程序

cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#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();
}
}

begin

函数原型:

bool begin();

功能说明:

  • 初始化摄像头

传入参数:

  • null

返回值:

  • bool:
    • true: 初始化成功
    • false: 初始化失败

get

函数原型:

bool get();

功能说明:

  • 获取一帧图像数据

传入参数:

  • null

返回值:

  • bool:
    • true: 图像获取成功
    • false: 图像获取失败

free

函数原型:

bool free();

功能说明:

  • 释放当前图像数据内存

传入参数:

  • null

返回值:

  • bool:
    • true: 图像资源释放成功
    • false: 没有资源需要释放
On This Page