PicoCamera 0.2.0
Camera library for RP2040 with an esp32-camera compatible API
GitHub
载入中...
搜索中...
未找到
pico_camera.h 文件参考

PicoCamera main API, aligned with esp32-camera's esp_camera.h. 更多...

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <sys/time.h>
#include "sensor.h"
pico_camera.h 的引用(Include)关系图:
此图展示该文件被哪些文件直接或间接地引用了:

浏览该文件的源代码.

结构体

struct  camera_config_t
 Configuration structure for camera initialization 更多...
struct  camera_fb_t
 Data structure of camera frame buffer 更多...

宏定义

#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"

类型定义

typedef int pico_camera_err_t

枚举

enum  camera_fb_location_t { PICO_CAMERA_FB_AUTO = 0 , PICO_CAMERA_FB_IN_PSRAM , PICO_CAMERA_FB_IN_SRAM }
 Frame buffer location 更多...

函数

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_tpico_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_tpico_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);

宏定义说明

◆ PICO_CAMERA_VERSION_HEX

#define PICO_CAMERA_VERSION_HEX
值:
((PICO_CAMERA_VERSION_MAJOR << 16) | \
(PICO_CAMERA_VERSION_MINOR << 8) | \
PICO_CAMERA_VERSION_PATCH)

枚举类型说明

◆ 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.

函数说明

◆ pico_camera_fb_get()

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_init()

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().

参数
configCamera configuration parameters
返回
PICO_CAMERA_OK on success. PICO_CAMERA_ERR_NOT_SUPPORTED if PIXFORMAT_JPEG is requested on a sensor without a JPEG encoder (see camera_sensor_info_t.support_jpeg; esp32-camera behaves the same way). A frame_size beyond the sensor's maximum is clamped to the maximum instead of failing.

◆ pico_camera_sensor_get()

sensor_t * pico_camera_sensor_get ( void )

Get a pointer to the image sensor control structure

返回
pointer to the sensor, NULL if not initialized

◆ pico_camera_sensor_info_get()

const camera_sensor_info_t * pico_camera_sensor_info_get ( void )

Get information about the detected sensor model

返回
pointer to static info, NULL if not initialized
English version