YJ
USB video class(UVC) for Pico
Capture video on your Raspberry Pi Pico with a tinyUSB library.
Hardware
- RP2040 board
- Raspberry Pi Pico
- ov2640 camera module within 24Mhz osc
- ILI9341 2.8 TFT SPI 240x320 V1.2 LCD module
Build
~$ git clone https://github.com/yjdwbj/rp2040-uvc
~$ cd rp2040-uvc
~$ git submodule update --init
~$ mkdir build
~$ cd build; cmake -DUSE_FREERTOS=1 ../ && makeTips
cmake -DUSE_FREERTOS=1will enableFreeRTOSsupport which is recommand, otherwise usemain loopinstead.- If you set the OV2640 pixel format to
RGB565, write the frame buffer directly toLCDand convertrgb565 -> yuv422toUVCstream. - If you set the OV2640 pixel format to
YUV422, write the frame buffer directly toUVCand convertyuv422 -> rgb565toLCD. But there is a serious bug here, green/inverted block areas are very frequent.
Demo run
Default Pinout
| RP2040 | OV2640 | ILI9341 |
|---|---|---|
| VCC | 3v3 | 3v3 |
| GND | GND | GND |
| 5 | SIOC | |
| 4 | SIOD | |
| 2 | REST | |
| 3 | VSYNC | |
| 6 | D0 | |
| 7 | D1 | |
| 8 | D2 | |
| 9 | D3 | |
| 10 | D4 | |
| 11 | D5 | |
| 12 | D6 | |
| 13 | D7 | |
| 15 | HSYNC | |
| 18 | RESET | |
| 19 | RS/DC | |
| 20 | CLK | |
| 21 | MOSI | |
| VCC | LED | |
| GND | CS |
V42l-ctrl examples
- query the capture formats the video device supports
v4l2-ctl -d 0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Type: Video Capture
[0]: 'YUYV' (YUYV 4:2:2)
Size: Discrete 320x240
Interval: Stepwise 0.040s - 1.000s with step 0.040s (1.000-25.000 fps)- capture raw video stream from by v4l2-ctl.
v4l2-ctl --device /dev/video0
--set-fmt-video=width=320,height=240,pixelformat=YUYV --stream-mmap
--stream-to=frame.raw --stream-count=1- converted into JPEG format by ffmpeg.
ffmpeg -y -s:v 320x240 -pix_fmt yuyv422 -i frame.raw frame.jpgFFmpeg examples
- play video from uvc device on linux.
ffplay -f v4l2 -framerate 25 -video_size 320x240 -i /dev/video0



