nopnop2002 / esp-idf-video-streaming

Capture video from a USB camera using ESP-IDF
MIT License
38 stars 4 forks source link
camera esp-idf esp32 usb-camera video-streaming web-camera

esp-idf-video-streaming

Capture video from a USB camera using ESP-IDF.

This example demonstrates how to:

This example enumerates the attached camera descriptors, negotiates the selected resolution and FPS, and starts capturing video.

I based it on this official example.

Change from official example

Hardware Required

ESP32-S2/ESP32-S3

This example requires any ESP32-S2 or ESP32-S3 with external PSRAM and exposed USB connector attached to USB camera.
ESP module without external PSRAM will fail to initialize.
I used this board.
esp32-s3-1

Note for ESP32S2
In earlier versions of the ESP32-S2 chip, USB transfers can cause SPI data contamination (esp32s2>=ECO1 and esp32s3 do not have this bug).
Software workaround is here.

Stable power supply

USB cameras consume a lot of electricity.
If the power supplied to the USB port is insufficient, the camera will not operate and ESP32 resets.

USB Type-A Femail connector

Breakout boards are available from AliExpress or eBay.

USB camera with UVC support

Here is a list of USB cameras that support UVC that work with FreeBSD.
From what I've researched, ESP-IDF has limited USB support.
For example, the Logitech C615 works with Linux, but not with ESP-IDF.
I tested with these cameras.

It is very hard to find a camera that works with ESP-IDF.
On this document says that these cameras work with ESP-IDF.

When usb support provided by ESP-IDF is updated, this issue may eliminate the problem.
Detail is here.

cameras

Software Required

esp-idf v5.0 or later.
A compilation error occurs in ESP-IDF Ver4.

Wireing

ESP BOARD          USB CONNECTOR (type A)
                         +--+
5V        -------------> | || VCC
[GPIO19]  -------------> | || D-
[GPIO20]  -------------> | || D+
GND       -------------> | || GND
                         +--+

Installation

git clone https://github.com/nopnop2002/esp-idf-video-streaming
cd esp-idf-video-streaming
idf.py set-target {esp32s2/esp32s3}
idf.py menuconfig
idf.py flash monitor

Configuration

config-main

config-app-1

Some cameras need to change frame size, frame rate and frame format.
config-app-2

How to use

Limitations

Using ESP32-CAM development board

You can use this repository.

References

https://github.com/nopnop2002/esp-idf-video-snapshot