![]() |
PicoCamera 0.2.0
Camera library for RP2040 with an esp32-camera compatible API
|
GitHub |
PicoCamera main API, aligned with esp32-camera's esp_camera.h. More...
#include <stddef.h>#include <stdint.h>#include <stdbool.h>#include <sys/time.h>#include "sensor.h"Go to the source code of this file.
Data Structures | |
| struct | camera_config_t |
| Configuration structure for camera initialization. More... | |
| struct | camera_fb_t |
| Data structure of camera frame buffer. More... | |
Macros | |
| #define | PICO_CAMERA_OK 0 |
| #define | PICO_CAMERA_FAIL -1 |
| #define | PICO_CAMERA_ERR_NO_MEM -2 |
| #define | PICO_CAMERA_ERR_INVALID_ARG -3 |
| #define | PICO_CAMERA_ERR_INVALID_STATE -4 |
| #define | PICO_CAMERA_ERR_NOT_SUPPORTED -5 |
| #define | PICO_CAMERA_ERR_TIMEOUT -6 |
| #define | PICO_CAMERA_ERR_BASE (-100) |
| #define | PICO_CAMERA_ERR_NOT_DETECTED (PICO_CAMERA_ERR_BASE - 1) |
| #define | PICO_CAMERA_ERR_FAILED_TO_SET_FRAME_SIZE (PICO_CAMERA_ERR_BASE - 2) |
| #define | PICO_CAMERA_ERR_FAILED_TO_SET_OUT_FORMAT (PICO_CAMERA_ERR_BASE - 3) |
| #define | PICO_CAMERA_VERSION_MAJOR 0 |
| #define | PICO_CAMERA_VERSION_MINOR 4 |
| #define | PICO_CAMERA_VERSION_PATCH 2 |
| #define | PICO_CAMERA_VERSION_HEX |
| #define | PICO_CAMERA_VERSION_STRING "0.4.2" |
Typedefs | |
| typedef int | pico_camera_err_t |
Enumerations | |
| enum | camera_fb_location_t { PICO_CAMERA_FB_AUTO = 0 , PICO_CAMERA_FB_IN_PSRAM , PICO_CAMERA_FB_IN_SRAM } |
| Frame buffer location. More... | |
Functions | |
| pico_camera_err_t | pico_camera_init (const camera_config_t *config) |
| Initialize the camera driver. | |
| pico_camera_err_t | pico_camera_deinit (void) |
| Deinitialize the camera driver and free all resources. | |
| camera_fb_t * | pico_camera_fb_get (void) |
| Obtain a frame buffer with a freshly captured frame. | |
| void | pico_camera_fb_return (camera_fb_t *fb) |
| Return the frame buffer to be reused again. | |
| sensor_t * | pico_camera_sensor_get (void) |
| Get a pointer to the image sensor control structure. | |
| const camera_sensor_info_t * | pico_camera_sensor_info_get (void) |
| Get information about the detected sensor model. | |
PicoCamera main API, aligned with esp32-camera's esp_camera.h.
Example use:
camera_config_t config = {
.pin_pwdn = -1,
.pin_reset = 29,
.pin_xclk = 5,
.pin_sccb_sda = 12,
.pin_sccb_scl = 13,
.pin_d0 = 14, .pin_d1 = 15, .pin_d2 = 16, .pin_d3 = 17,
.pin_d4 = 18, .pin_d5 = 19, .pin_d6 = 20, .pin_d7 = 21,
.pin_vsync = 2, .pin_href = 3, .pin_pclk = 4,
.xclk_freq_hz = 10000000,
.sccb_i2c_port = 0,
.pixel_format = PIXFORMAT_RGB565,
.frame_size = FRAMESIZE_QVGA,
.jpeg_quality = 10,
.fb_count = 1,
.fb_location = PICO_CAMERA_FB_AUTO,
};
pico_camera_init(&config);
camera_fb_t *fb = pico_camera_fb_get();
// use fb->buf / fb->len / fb->width / fb->height
pico_camera_fb_return(fb);
| #define PICO_CAMERA_VERSION_HEX |
| enum camera_fb_location_t |
Frame buffer location.
PSRAM requires an RP2350 board with a PSRAM chip, enabled via the core's PSRAM menu (Arduino IDE) or board_upload.psram_length (PlatformIO); RP2040 has no PSRAM support. Unlike esp32-camera, PICO_CAMERA_FB_AUTO falls back to SRAM when PSRAM allocation fails — esp32-camera has no automatic fallback and fails init instead.
| camera_fb_t * pico_camera_fb_get | ( | void | ) |
Obtain a frame buffer with a freshly captured frame.
Blocks until the frame is captured. Returns NULL on error or if no free buffer is available (return buffers with pico_camera_fb_return()).
| pico_camera_err_t pico_camera_init | ( | const camera_config_t * | config | ) |
Initialize the camera driver.
Detects the sensor over SCCB, allocates frame buffers, sets up PIO + DMA. Can only be called once until pico_camera_deinit().
| config | Camera configuration parameters |
| sensor_t * pico_camera_sensor_get | ( | void | ) |
Get a pointer to the image sensor control structure.
| const camera_sensor_info_t * pico_camera_sensor_info_get | ( | void | ) |
Get information about the detected sensor model.