|
| 1 | +# USB Hub Dual Camera Example |
| 2 | + |
| 3 | +This example demonstrates how to use the [usb_host_uvc](https://components.espressif.com/components/espressif/usb_host_uvc) component to connect USB cameras and preview camera images via an HTTP server. |
| 4 | + |
| 5 | +* Supports previewing MJPEG format images only. |
| 6 | +* Supports USB Hub, allowing up to two cameras to be connected. |
| 7 | +* Web interface allows saving the current frame. |
| 8 | + |
| 9 | +## How to Use |
| 10 | + |
| 11 | +### Hardware Requirements |
| 12 | + |
| 13 | +* Development Board |
| 14 | + |
| 15 | + Any `ESP32-S2`, `ESP32-S3`, or `ESP32-P4` development board. |
| 16 | + |
| 17 | + By default, the ESP32-P4 uses the [ESP32-P4-Function-EV-Board](https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/user_guide.html#getting-started) development board. |
| 18 | + |
| 19 | +* Connection |
| 20 | + |
| 21 | + | | USB_DP | USB_DM | |
| 22 | + | ----------- | ------ | ------ | |
| 23 | + | ESP32-S2/S3 | GPIO20 | GPIO19 | |
| 24 | + | ESP32-P4 | GPIO50 | GPIO49 | |
| 25 | + |
| 26 | +### Build and Flash |
| 27 | + |
| 28 | +Build the project and flash it to the board, then run the monitor tool to view the serial output: |
| 29 | + |
| 30 | +* Run `. ./export.sh` to set IDF environment |
| 31 | +* Run `idf.py set-target esp32s3` to set target chip |
| 32 | +* Run `pip install "idf-component-manager~=2.1.0"` to upgrade your component manager if any error happens during last step |
| 33 | +* Run `idf.py -p PORT flash monitor` to build, flash and monitor the project |
| 34 | + |
| 35 | +(To exit the serial monitor, type `Ctrl-]`.) |
| 36 | + |
| 37 | +See the Getting Started Guide for all the steps to configure and use the ESP-IDF to build projects. |
| 38 | + |
| 39 | +### Preview camera image |
| 40 | + |
| 41 | +* Connect with ESP32S2 through Wi-Fi, SSID: `ESP-USB-UVC-Demo` with no password by default. |
| 42 | + |
| 43 | +* Input `192.168.4.1` in your browser, you can find a file list of the disk. |
| 44 | + |
| 45 | +Note: Safari browser is not recommended. |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +<p align="center"> |
| 50 | + <img src="https://dl.espressif.com/AE/esp-iot-solution/uvc_dual_hub_camera_2.gif" alt="demo2"> |
| 51 | +</p> |
| 52 | + |
| 53 | +### Frontend Source Files |
| 54 | + |
| 55 | +Please refer to the [frontend source files](./frontend_source). |
| 56 | + |
| 57 | +## Example Output |
| 58 | + |
| 59 | +``` |
| 60 | +I (4108) main_task: Returned from app_main() |
| 61 | +W (31940) uvc: USB device with addr(1) is not UVC device |
| 62 | +I (32025) uvc: Device connected |
| 63 | +I (32026) uvc: Cam[0] uvc_stream_index = 0 |
| 64 | +I (32026) uvc: Pick Cam[0] FORMAT_MJPEG 1280*[email protected] |
| 65 | +I (32026) uvc: Pick Cam[0] FORMAT_MJPEG 800*[email protected] |
| 66 | +I (32031) uvc: Pick Cam[0] FORMAT_MJPEG 640*[email protected] |
| 67 | +I (32036) uvc: Pick Cam[0] FORMAT_MJPEG 480*[email protected] |
| 68 | +I (32041) uvc: Pick Cam[0] FORMAT_MJPEG 320*[email protected] |
| 69 | +I (32109) uvc: Device connected |
| 70 | +I (32110) uvc: Cam[1] uvc_stream_index = 0 |
| 71 | +I (32110) uvc: Pick Cam[1] FORMAT_MJPEG 1280*[email protected] |
| 72 | +I (32110) uvc: Pick Cam[1] FORMAT_MJPEG 800*[email protected] |
| 73 | +I (32115) uvc: Pick Cam[1] FORMAT_MJPEG 640*[email protected] |
| 74 | +I (32120) uvc: Pick Cam[1] FORMAT_MJPEG 480*[email protected] |
| 75 | +I (32125) uvc: Pick Cam[1] FORMAT_MJPEG 320*[email protected] |
| 76 | +I (32246) uvc: Opening the UVC[0]... |
| 77 | +I (32246) uvc: frame_size.advanced.frame_size: 40000 |
| 78 | +I (32330) uvc: Opening the UVC[1]... |
| 79 | +I (32330) uvc: frame_size.advanced.frame_size: 40000 |
| 80 | +``` |
0 commit comments