Computer vision
Capture frames for on-device inference using TensorFlow Lite Micro or edge AI pipelines. The ISP handles preprocessing.
The ESP32-P4 includes a MIPI-CSI receiver interface with an integrated image signal processor (ISP) and H.264 video encoder. This guide covers connecting a camera module and capturing images or video.
| Specification | Value |
|---|---|
| Interface | 2-lane MIPI-CSI |
| Supported sensor | OV5647 (5MP) |
| Maximum usable resolution | 2MP (1920 x 1080) |
| ISP | Integrated — auto exposure, white balance, noise reduction |
| Video encoder | H.264, 1080P at 30fps |
| Connector | 15-pin FPC (standard Raspberry Pi camera form factor) |
Power off the board (disconnect USB).
Locate the MIPI-CSI FPC connector on the board. It uses the standard 15-pin Raspberry Pi camera ribbon cable layout.
Lift the connector latch gently.
Insert the camera ribbon cable with the contacts facing the PCB. The blue backing of the cable should face away from the board.
Press the connector latch down to secure the cable.
Verify the cable is firmly seated and not at an angle.
Reconnect USB power.
Create or open an ESP-IDF project targeting ESP32-P4.
The camera driver is part of the ESP-IDF framework. Configure it via menuconfig:
idf.py menuconfigNavigate to Component config > Camera Configuration and enable the MIPI-CSI driver.
Initialize the camera in your application:
#include "esp_camera.h"
static camera_config_t camera_config = { .pin_pwdn = -1, .pin_reset = -1, .xclk_freq_hz = 20000000, .pixel_format = PIXFORMAT_JPEG, .frame_size = FRAMESIZE_HD, // 1280x720 .jpeg_quality = 12, .fb_count = 2,};
void app_main(void){ esp_err_t err = esp_camera_init(&camera_config); if (err != ESP_OK) { printf("Camera init failed: 0x%x\n", err); return; }
camera_fb_t *fb = esp_camera_fb_get(); if (fb) { printf("Captured: %dx%d, %d bytes\n", fb->width, fb->height, fb->len); esp_camera_fb_return(fb); }}Build and flash:
idf.py buildidf.py -p /dev/ttyUSB0 flash monitorThe ESP32-P4’s image signal processor handles common camera processing tasks in hardware, reducing CPU load:
These features are enabled by default when using the ESP-IDF camera driver. Fine-tuning parameters are available through the ISP configuration API.
The hardware H.264 encoder can produce compressed video streams at up to 1080P 30fps. This is particularly useful for:
#include "esp_video_enc.h"
// Configure H.264 encoderesp_video_enc_config_t enc_config = { .width = 1920, .height = 1080, .fps = 30, .bitrate = 4000000, // 4 Mbps};Computer vision
Capture frames for on-device inference using TensorFlow Lite Micro or edge AI pipelines. The ISP handles preprocessing.
Machine vision
Industrial inspection, barcode/QR scanning, and defect detection at the edge — no cloud dependency.
Video streaming
Stream H.264-encoded video over WiFi 6 for security cameras, baby monitors, or remote inspection.
Time-lapse capture
Periodic image capture stored to microSD, powered by the RTC for accurate scheduling.
| Symptom | Cause | Fix |
|---|---|---|
Camera init returns ESP_ERR_NOT_FOUND | Ribbon cable not seated properly | Reseat the FPC cable, ensure contacts face the PCB |
| Image is dark or overexposed | ISP auto-exposure not converging | Allow 1—2 seconds after init before capturing; check lighting |
| Horizontal lines in image | CSI clock mismatch | Verify XCLK frequency matches sensor datasheet (20 MHz for OV5647) |
Crash on fb_get() | Insufficient PSRAM or framebuffers | Reduce frame_size or fb_count |