Open shenqili opened 3 weeks ago
I have found the reason is that uvc device has Other Speed Configuration Descriptor (for full speed). And the ideal video format can only be gotten at the high speed. So the question changes to another. Why C270 is in the supported list and how can I use the C270 with esp32s3? I really want to know, thanks a lot.
I uncommented this line https://github.com/espressif/esp-idf/blob/9106c43accd9f5e75379f62f12597677213f5023/examples/peripherals/usb/host/uvc/main/main.c#L264 And this is my output with Logitech C270
You can see many JPEG and Uncompressed formats available
And the ideal video format can only be gotten at the high speed.
What do you mean by 'ideal video format'?
ESP32-S2 and S3 are Full-Speed only, so it is not possible to stream higher quality (eg. 1280x720) video.
(ESP32-P4 is High-Speed and this is possible)
I uncommented this line
And this is my output with Logitech C270 Logitech C270 FS CFG descriptor You can see many JPEG and Uncompressed formats available
And the ideal video format can only be gotten at the high speed.
What do you mean by 'ideal video format'?
ESP32-S2 and S3 are Full-Speed only, so it is not possible to stream higher quality (eg. 1280x720) video.
(ESP32-P4 is High-Speed and this is possible)
Thanks for responding. The Ideal video format should include MJPEG video format, like 640*480. For the C270 is supported by the esp32s3 which is demonstrated in usb_host_uvc 1.0.4(https://components.espressif.com/components/espressif/usb_host_uvc). And a youtuber have successfully used it for video tranfering. The link is below: https://www.youtube.com/watch?v=Hi-6Y12Jhgs. He used esp32s3 generic and also the C270 and run the project. So I have the doubt what is the wrong with me. I am willing for your feedback. Thx again.
C270-windows vs esp32-log.docx I have upload the whole C270 configuration (captured by the windows usb description dumper) and compared to the print log of the ESP32 line by line. And as you seen, the configuration descrption gotten by esp32 is the 'Other Speed Configuration Descriptor'. It should work if get the configuration in the upper part. So I really want to how the examples of usb_host uvc 1.0.4 ror the youtube video can successfully use the C270.
It appears that your camera does not support any additional video formats in Full-Speed mode. This is unusual, as my Logitech C270 camera, which has a bcdDevice
version of 0x12, does support a wider range of formats. In contrast, your camera's bcdDevice
version is 0x21, indicating a newer version of the USB device. However, despite being newer, it seems to lack support for certain video formats in Full-Speed.
The discrepancy between the configuration descriptors seen by Windows and ESP-IDF is also notable. While Windows detects the High-Speed descriptor with the full range of video formats, ESP-IDF only accesses the Full-Speed configuration descriptor, which has a reduced subset of formats.
I’m not sure why Logitech chose to limit the available formats in Full-Speed mode for the newer version of the camera. If the data you provided is accurate, this would seem to be the most plausible explanation.
It doubts me a lot. And the difference between your C270 and my C270 in the version may be the most plausible reason for the failure. So for me, I have nothing could do more with the esp32s3 does not support the High-Speed for C270 video transferring in version 0x21. If it is possible to change from esp32s3 to another chip which supports both High-Speed and Wifi, like Raspberry Pi or use a external HS-PHY on the esp32s3?
Or is it possible to do some configuration or adjustment in ESP-IDF to access the High Speed Configuration descriptor of C270 I used.
There is no easy way how you can add USB HighSpeed support to ESP32-S3. Transferring your design to Raspberry Pi, or any other linux capable architecture will also give you a lot more computing power for video postprocessing. But it will greatly depend on what do you need to actually do
Answers checklist.
IDF version.
v5.3.1
Espressif SoC revision.
ESP32S3
Operating System used.
Windows
How did you build your project?
VS Code IDE
If you are using Windows, please specify command line type.
None
Development Kit.
ESP32-S3-DEV-KIT-N8R8
Power Supply used.
External 5V
What is the expected behavior?
I want to use Logitech C270 with esp32s3 to capture video and pictures
What is the actual behavior?
I have run the two project with the Logitech C270 which is supported by esp-idf and both failed. https://gitcode.com/gh_mirrors/es/esp-iot-solution/tree/master/examples/usb/host/usb_camera_mic_spk https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/uvc
In project of usb_camera_mic_spk I have got the wrong part of the UVC Configuration description without the video format descriptions part.
And in project of uvc. I have got the wrong part of the UVC Configuration description without the video format descriptions part. The supported video formats are not gotten by the esp32s3, which only shows the 160*120, 10frames,Uncompressed format.
ucvLog.txt usb_camera_mic_spk.txt
Steps to reproduce.
Set the C270 and the esp32s3 (Use a USB hub with power supply to power the camera and ESP32 at the same time )
Build the project and finish the menuconfig
Run the project
Here is the main.c:
/*
include
include
include
include
include "freertos/FreeRTOS.h"
include "freertos/event_groups.h"
include "freertos/task.h"
include "esp_err.h"
include "esp_log.h"
include "usb_stream.h"
include "esp_camera.h"
ifdef CONFIG_ESP32_S3_USB_OTG
include "bsp/esp-bsp.h"
endif
static const char *TAG = "uvc_mic_spk_demo"; /** configure the example working mode ***/
define ENABLE_UVC_CAMERA_FUNCTION 1 / enable uvc function /
define ENABLE_UAC_MIC_SPK_FUNCTION 0 / enable uac mic+spk function /
if (ENABLE_UVC_CAMERA_FUNCTION)
define ENABLE_UVC_FRAME_RESOLUTION_ANY 1 / Using any resolution found from the camera /
define ENABLE_UVC_WIFI_XFER 0 / transfer uvc frame to wifi http /
endif
if (ENABLE_UAC_MIC_SPK_FUNCTION)
define ENABLE_UAC_MIC_SPK_LOOPBACK 0 / transfer mic data to speaker /
static uint32_t s_mic_samples_frequence = 0; static uint32_t s_mic_ch_num = 0; static uint32_t s_mic_bit_resolution = 0; static uint32_t s_spk_samples_frequence = 0; static uint32_t s_spk_ch_num = 0; static uint32_t s_spk_bit_resolution = 0;
endif
define BIT0_FRAME_START (0x01 << 0)
define BIT1_NEW_FRAME_START (0x01 << 1)
define BIT2_NEW_FRAME_END (0x01 << 2)
define BIT3_SPK_START (0x01 << 3)
define BIT4_SPK_RESET (0x01 << 4)
static EventGroupHandle_t s_evt_handle;
if (ENABLE_UVC_CAMERA_FUNCTION)
if (ENABLE_UVC_FRAME_RESOLUTION_ANY)
define DEMO_UVC_FRAME_WIDTH 320
define DEMO_UVC_FRAME_HEIGHT 240
else
define DEMO_UVC_FRAME_WIDTH 480
define DEMO_UVC_FRAME_HEIGHT 320
endif
ifdef CONFIG_IDF_TARGET_ESP32S2
define DEMO_UVC_XFER_BUFFER_SIZE (45 * 1024)
else
define DEMO_UVC_XFER_BUFFER_SIZE (55 * 1024)
endif
if (ENABLE_UVC_WIFI_XFER)
include "app_wifi.h"
include "app_httpd.h"
include "esp_camera.h"
static camera_fb_t s_fb = {0};
camera_fb_t *esp_camera_fb_get() { xEventGroupSetBits(s_evt_handle, BIT0_FRAME_START); xEventGroupWaitBits(s_evt_handle, BIT1_NEW_FRAME_START, true, true, portMAX_DELAY); return &s_fb; }
void esp_camera_fb_return(camera_fb_t *fb) { xEventGroupSetBits(s_evt_handle, BIT2_NEW_FRAME_END); return; }
static void camera_frame_cb(uvc_frame_t frame, void ptr) { ESP_LOGI(TAG, "uvc callback! frame_format = %d, seq = %"PRIu32", width = %"PRIu32", height = %"PRIu32", length = %u, ptr = %d", frame->frame_format, frame->sequence, frame->width, frame->height, frame->data_bytes, (int) ptr); if (!(xEventGroupGetBits(s_evt_handle) & BIT0_FRAME_START)) { return; }
}
else
static void camera_frame_cb(uvc_frame_t frame, void ptr) { ESP_LOGI(TAG, "uvc callback! frame_format = %d, seq = %"PRIu32", width = %"PRIu32", height = %"PRIu32", length = %u, ptr = %d", frame->frame_format, frame->sequence, frame->width, frame->height, frame->data_bytes, (int) ptr); }
endif //ENABLE_UVC_WIFI_XFER
endif //ENABLE_UVC_CAMERA_FUNCTION
if (ENABLE_UAC_MIC_SPK_FUNCTION)
static void mic_frame_cb(mic_frame_t frame, void ptr) { // We should using higher baudrate here, to reduce the blocking time here ESP_LOGD(TAG, "mic callback! bit_resolution = %u, samples_frequence = %"PRIu32", data_bytes = %"PRIu32, frame->bit_resolution, frame->samples_frequence, frame->data_bytes); // We should never block in mic callback!
if (ENABLE_UAC_MIC_SPK_LOOPBACK)
endif //ENABLE_UAC_MIC_SPK_LOOPBACK
}
endif //ENABLE_UAC_MIC_SPK_FUNCTION
static void stream_state_changed_cb(usb_stream_state_t event, void *arg) { switch (event) { case STREAM_CONNECTED: { size_t frame_size = 0; size_t frame_index = 0;
if (ENABLE_UVC_CAMERA_FUNCTION)
endif
if (ENABLE_UAC_MIC_SPK_FUNCTION)
endif
}
void app_main(void) {
ifdef CONFIG_ESP32_S3_USB_OTG
endif
if (ENABLE_UVC_CAMERA_FUNCTION)
if (ENABLE_UVC_WIFI_XFER)
endif //ENABLE_UVC_WIFI_XFER
endif
if (ENABLE_UAC_MIC_SPK_FUNCTION)
endif
if (ENABLE_UAC_MIC_SPK_FUNCTION && !ENABLE_UAC_MIC_SPK_LOOPBACK)
endif
}
Debug Logs.
More Information.
I use the windows usb descriptior dumper to get the C270 descrption which is right。 And use amcap to connect the camera and set the format which is also successful.
C270.txt