nopnop2002 / esp-idf-video-streaming

Capture video from a USB camera using ESP-IDF
MIT License
38 stars 4 forks source link

How many memory is needed while working at 240*320,mjpeg format? #21

Open 2054686334 opened 1 month ago

2054686334 commented 1 month ago
I (22243) example: uvc_start_streaming=0
Streaming...
Guru Meditation Error: Core  0 panic'ed (StoreProhibited). Exception was unhandled.

Core  0 register dump:
PC      : 0x40056fcc  PS      : 0x00060d30  A0      : 0x820137b8  A1      : 0x3fcea7a0  
A2      : 0x00000000  A3      : 0x3fcedc1c  A4      : 0x000001fe  A5      : 0x00000000  
A6      : 0x3d4d7b9e  A7      : 0xb5e23d4d  A8      : 0xd88eb750  A9      : 0x01ffffff  
A10     : 0x3fce891c  A11     : 0x00000002  A12     : 0x00000001  A13     : 0x01ffffff  
A14     : 0x3fca2270  A15     : 0x00000001  SAR     : 0x00000010  EXCCAUSE: 0x0000001d  
EXCVADDR: 0x00000000  LBEG    : 0x40056fc5  LEND    : 0x40056fe7  LCOUNT  : 0x0000001e

when i switch in my uvc device,i will get a StoreProhibited Exception and reboot,using ESP32S3 N16R8

2054686334 commented 1 month ago

streaming work fine when i use 120*160,uncompressed format,although i got bad image

2054686334 commented 1 month ago
Waiting for device
Device found
DEVICE CONFIGURATION (2bdf:0101/F) ---
Status: idle
VideoControl:
        bcdUVC: 0x0110
VideoStreaming(1):
        bEndpointAddress: 129
        Formats:
        UncompressedFormat(1)
                  bits per pixel: 16
                  GUID: 5955593200001000800000aa00389b71 (YUY2)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 00
                          size: 120x160
                          bit rate: 7680000-7680000
                          max frame size: 38400
                          default interval: 1/25
                          interval[0]: 1/25
                        FrameDescriptor(2)
                          capabilities: 00
                          size: 240x320
                          bit rate: 36864000-36864000
                          max frame size: 153600
                          default interval: 1/30
                          interval[0]: 1/30
                        FrameDescriptor(3)
                          capabilities: 00
                          size: 640x360
                          bit rate: 110592000-110592000
                          max frame size: 460800
                          default interval: 1/30
                          interval[0]: 1/30
        MJPEGFormat(2)
                  bits per pixel: 0
                  GUID: 4d4a5047000000000000000000000000 (MJPG)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 00
                          size: 120x160
                          bit rate: 7680000-7680000
                          max frame size: 38400
                          default interval: 1/25
                          interval[0]: 1/25
                        FrameDescriptor(2)
                          capabilities: 00
                          size: 240x320
                          bit rate: 10240000-10240000
                          max frame size: 153600
                          default interval: 1/30
                          interval[0]: 1/30
                        FrameDescriptor(3)
                          capabilities: 00
                          size: 640x360
                          bit rate: 10240000-10240000
                          max frame size: 460800
                          default interval: 1/30
                          interval[0]: 1/30
        FrameFormat(3)
                  bits per pixel: 16
                  GUID: 4832363400001000800000aa00389b71 (H264)
                  default frame: 1
                  aspect ratio: 0x0
                  interlace flags: 00
                  copy protect: 00
                        FrameDescriptor(1)
                          capabilities: 00
                          size: 240x320
                          bit rate: 8192000-8192000
                          max frame size: 0
                          default interval: 1/30
                          interval[0]: 1/30
END DEVICE CONFIGURATION
I (3793) example: format_desc->fourccFormat=(YUY2)
I (3803) example: frame_desc->wWidth=120
I (3803) example: frame_desc->wHeight=160
I (3813) example: format_desc->bDescriptorSubtype=4
I (3813) example: frame_desc->dwDefaultFrameInterval=400000
I (3823) example: format_desc->bDescriptorSubtype == UVC_VS_FORMAT_UNCOMPRESSED
W (3833) example: FRAME SIZE=240x320 FRAME RATE=30
W (3833) example: FRAME FORMAT=MJPEG
I (3843) example: format=7 width=240 height=320 fps=30
bmHint: 0001
bFormatIndex: 2
bFrameIndex: 2
dwFrameInterval: 333333
wKeyFrameRate: 0
wPFrameRate: 0
wCompQuality: 0
wCompWindowSize: 0
wDelay: 0
dwMaxVideoFrameSize: 4147200
dwMaxPayloadTransferSize: 512
bInterfaceNumber: 1
I (3873) example: uvc_start_streaming=0
Streaming...
I (11773) HTTP: root_get_handler
I (15753) wifi:<ba-add>idx:0 (ifx:0, ea:c8:29:bd:68:7a), tid:0, ssn:11, winSize:64

this is another status:no reboot,no streaming,use 240*320,30fps,mjpeg to stream.

nopnop2002 commented 1 month ago

Did you enable PSRAM using Menuconfig?

ESP module without external PSRAM will fail to initialize.

2054686334 commented 1 month ago

Did you enable PSRAM using Menuconfig?

ESP module without external PSRAM will fail to initialize.

yes,i enable PSRAM using menoconfig boot log:

I (27) boot: ESP-IDF 5.2.1 2nd stage bootloader
I (27) boot: compile time May 24 2024 23:08:48
I (27) boot: Multicore bootloader
I (30) boot: chip revision: v0.2
I (34) boot.esp32s3: Boot SPI Speed : 80MHz
I (38) boot.esp32s3: SPI Mode       : DIO
I (43) boot.esp32s3: SPI Flash Size : 16MB
I (48) boot: Enabling RNG early entropy source...
I (53) boot: Partition Table:
I (57) boot: ## Label            Usage          Type ST Offset   Length
I (64) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (72) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (79) boot:  2 factory          factory app      00 00 00010000 00100000
I (87) boot: End of partition table
I (91) esp_image: segment 0: paddr=00010020 vaddr=3c0a0020 size=285ech (165356) map
I (129) esp_image: segment 1: paddr=00038614 vaddr=3fc9aa00 size=04c48h ( 19528) load
I (133) esp_image: segment 2: paddr=0003d264 vaddr=40374000 size=02db4h ( 11700) load
I (137) esp_image: segment 3: paddr=00040020 vaddr=42000020 size=9f34ch (652108) map
I (260) esp_image: segment 4: paddr=000df374 vaddr=40376db4 size=13c30h ( 80944) load
I (288) boot: Loaded app from partition at offset 0x10000
I (288) boot: Disabling RNG early entropy source...
I (299) cpu_start: Multicore app
I (300) octal_psram: vendor id    : 0x0d (AP)
I (300) octal_psram: dev id       : 0x02 (generation 3)
I (303) octal_psram: density      : 0x03 (64 Mbit)
I (308) octal_psram: good-die     : 0x01 (Pass)
I (314) octal_psram: Latency      : 0x01 (Fixed)
I (319) octal_psram: VCC          : 0x01 (3V)
I (324) octal_psram: SRF          : 0x01 (Fast Refresh)
I (330) octal_psram: BurstType    : 0x01 (Hybrid Wrap)
I (336) octal_psram: BurstLen     : 0x01 (32 Byte)
I (341) octal_psram: Readlatency  : 0x02 (10 cycles@Fixed)
I (347) octal_psram: DriveStrength: 0x00 (1/1)
I (353) MSPI Timing: PSRAM timing tuning index: 5
I (358) esp_psram: Found 8MB PSRAM device
I (362) esp_psram: Speed: 80MHz
I (819) esp_psram: SPI SRAM memory test OK
I (828) cpu_start: Pro cpu start user code
I (828) cpu_start: cpu freq: 160000000 Hz
I (828) cpu_start: Application information:
I (831) cpu_start: Project name:     esp32s3-uvc
I (836) cpu_start: App version:      1
I (841) cpu_start: Compile time:     May 24 2024 23:38:39
I (847) cpu_start: ELF file SHA256:  c37686bb5...
I (852) cpu_start: ESP-IDF:          5.2.1
I (857) cpu_start: Min chip rev:     v0.0
I (862) cpu_start: Max chip rev:     v0.99 
I (866) cpu_start: Chip rev:         v0.2
I (871) heap_init: Initializing. RAM available for dynamic allocation:
I (878) heap_init: At 3FCA57F8 len 00043F18 (271 KiB): RAM
I (884) heap_init: At 3FCE9710 len 00005724 (21 KiB): RAM
I (891) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM
I (897) heap_init: At 600FE010 len 00001FD8 (7 KiB): RTCRAM
I (903) esp_psram: Adding pool of 8192K of PSRAM memory to heap allocator
I (911) spi_flash: detected chip: generic
I (915) spi_flash: flash io: dio
I (919) sleep: Configure to isolate all GPIO pins in sleep state
I (926) sleep: Enable automatic switching of GPIO sleep configuration
I (933) main_task: Started on CPU0
I (943) esp_psram: Reserving pool of 146K of internal memory for DMA/internal allocations
I (943) main_task: Calling app_main()
I (973) pp: pp rom version: e7ae62f
I (973) net80211: net80211 rom version: e7ae62f
2054686334 commented 1 month ago
W (55313) example: FRAME SIZE=240x320 FRAME RATE=30
W (55313) example: FRAME FORMAT=YUYV
I (55323) example: format=3 width=240 height=320 fps=30
bmHint: 0001
bFormatIndex: 1
bFrameIndex: 2
dwFrameInterval: 333333
wKeyFrameRate: 0
wPFrameRate: 0
wCompQuality: 0
wCompWindowSize: 0
wDelay: 0
dwMaxVideoFrameSize: 153600
dwMaxPayloadTransferSize: 512
bInterfaceNumber: 1
I (55353) example: uvc_start_streaming=0
Streaming...
I (56393) example: fps: 7, bytes per second: 5795
I (57533) example: fps: 7, bytes per second: 3979
I (58683) example: fps: 7, bytes per second: 5377
I (59813) example: fps: 7, bytes per second: 3526
I (60953) example: fps: 7, bytes per second: 5960
I (62093) example: fps: 7, bytes per second: 4095
I (63233) example: fps: 7, bytes per second: 4486
I (64373) example: fps: 7, bytes per second: 11872
I (64973) HTTP: root_get_handler
I (65283) wifi:<ba-add>idx:0 (ifx:0, ea:c8:29:bd:68:7a), tid:0, ssn:24, winSize:64
I (65373) example: fps: 6, bytes per second: 4673
I (66383) example: fps: 6, bytes per second: 6712

if use yuyv,it work fine like i post,i will get some wrong image,if use mjpeg,same thing happen,it will reboot because StoreProhibited

nopnop2002 commented 1 month ago

What is the manufacturer and model number of the camera you are using?

You can check with the lsusb command.

I tested with these cameras.

It is very hard to find a camera that works with ESP-IDF.