A simple webcam capturing program using SDL2, V4L2 Linux Kernel API and libyuv
Assuming GCC is used:
gcc webcam_t1_sdl.c -o webcam_t1_sdl -lSDL2main -lSDL2 -lyuvAnd then:
./webcam_t1_sdl <device_name> <jpeg_or_yuv> <width> <height>Do remember to check for what resolution your camera support by running
v4l2-ctl -d /dev/video0 --list-formats-extIf the program receives any resolution that is not supported, undefined behaviours can occur, which, in this case, the rendered output will be broken.
Of course this program isn't at all unique and I've been able to complete this thanks to these guides
- Markus Folkesson's Capture an image with V4L2
- chendotjs' SDL2 webcam example
- ChatGPT (Mostly for debugging)
