A comprehensive real-time camera streaming application written in Go that demonstrates 6 different GUI/backend approaches for rendering camera feeds. This project showcases various Go GUI frameworks and their performance characteristics when handling live video streams.
This project provides 6 distinct implementations of the same camera application, each using a different GUI framework or rendering backend. This allows for direct performance comparison and demonstrates the versatility of Go for multimedia applications.
- Framework: Gio UI (Pure Go)
- Description: Single-window application with both controls and camera feed rendered in Gio
- Features: Native Go implementation, hardware-accelerated rendering
- Build:
go run -o puregio
- Framework: Nucular (controls) + Gio (camera rendering)
- Description: Separate windows - Nucular for controls, Gio for optimized camera display
- Features: Good performance for camera rendering, familiar controls with Nucular
- Build:
go build -o nucular_gio
- Framework: SDL3 + Nucular
- Description: SDL3 for camera rendering with Nucular control panel
- Features: Hardware acceleration, cross-platform compatibility
- Build:
go build -o camera_sdl3
- Framework: Dear ImGui (CIMGUI-Go) with Ebiten backend
- Description: ImGui interface with Ebiten 2D game engine rendering
- Features: Game engine optimizations, Dear ImGui widgets
- Build:
go build -o imgui_ebiten
- Framework: GLFW with direct OpenGL backend
- Description: Raw OpenGL rendering for maximum performance
- Features: Direct GPU access, minimal overhead
- Build:
go build -o imgui_opengl
- Framework: Clay for layout with SDL3 backend
- Description: SDL3 for window management and rendering. Clay for UI layout management
- Features: Direct GPU access, minimal overhead
- Build:
go build -tags sdl -o imgui_sdl
Backend | Camera FPS | UI Responsiveness | Memory Usage | CPU Usage | Complexity |
---|---|---|---|---|---|
Pure Gio | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐ |
Nucular+Gio | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ |
SDL3 | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ |
ImGui+Ebiten | ⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐ | ⭐⭐⭐⭐ |
GLFW/OpenGL | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
CLAY+SDL3 | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
- Real-time camera video streaming (30-60 FPS)
- Multiple camera support with dynamic detection
- Frame statistics monitoring (FPS, dropped frames)
- MJPEG video format support
- Configurable resolution (default: 640x480)
- Live camera switching
- Frame drop detection and recovery
- Cross-platform compatibility (Linux primary, some Windows/macOS)
- Go 1.24.3 or later
- Linux operating system (primary support)
- V4L2-compatible webcam
- X11 development libraries
sudo apt-get install libsdl2-dev libsdl2-image-dev
sudo apt-get install libsdl3-dev
sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev
- Clone the repository:
- Choose and build your preferred backend:
go build -tags puregio -o puregio
go build -tags giocam -o nucular_gio
go build -tags cam -o camera_sdl
go build -tags imgui -o imgui_ebiten
go build -tags opengl -o imgui_opengl
go build -tags sdl -o imgui_sdl
- Camera Toggle: Turn camera display on/off
- Camera Selection: Switch between detected cameras
- Statistics: View real-time FPS and frame drop information
- Counter: Test UI responsiveness with increment button
The application automatically detects all V4L2 cameras at /dev/video*
and allows switching between them during runtime.
- V4L2 Device Detection: Scans
/dev/video*
devices - Camera Initialization: Opens device with MJPEG format
- Frame Capture: Continuous frame capture in background goroutine
- Image Processing: MJPEG → RGBA conversion
- Texture Upload: Backend-specific texture creation and updates
- Rendering: Backend-specific display rendering
- Gio: Native Go rendering with GPU acceleration
- SDL: Hardware-accelerated texture streaming
- ImGui: Immediate mode GUI with efficient texture binding
- OpenGL: Direct GPU memory management
Modify the camera resolution in any implementation:
go device.WithPixFormat(v4l2.PixFormat{ Width: 1280, // Change from default 640 Height: 720, // Change from default 480 PixelFormat: v4l2.PixelFmtMJPEG, Field: v4l2.FieldNone, })
- Frame Buffer Size: Adjust channel buffer sizes for latency vs. smoothness
- Render Rate: Modify ticker intervals for different FPS targets
- Memory Management: Configure GC settings for consistent performance
-
No cameras detected:
# Check camera permissions ls -la /dev/video* sudo chmod 666 /dev/video0
-
Poor performance:
- Try different backends (Nucular+Gio recommended for best camera performance)
- Reduce resolution
- Check system resources
-
Build errors:
- Ensure all system dependencies are installed
- Check Go version compatibility
- Verify build tags are correct
- Beginners: Start with Pure Gio (no external dependencies) or
- Best Performance: Use GLFW/OpenGL Also the most difficult to implement
- Game Development: Try ImGui + Ebiten
- Cross-Platform: Consider SDL3 backends
- Production: SDL3 or Pure Gio for stability
github.com/vladimirvivien/go4vl
- V4L2 camera access- Standard Go libraries for image processing
- Gio:
gioui.org
- Pure Go UI framework - Nucular:
github.com/aarzilli/nucular
- Immediate mode GUI - SDL3:
github.com/Zyko0/go-sdl3
or SDL2 bindings - ImGui:
github.com/amken3d/cimgui-go
- Dear ImGui Go bindings - Ebiten:
github.com/hajimehoshi/ebiten/v2
- 2D game engine
- Fork the repository
- Create a feature branch
- Add new backend implementations or improve existing ones
- Test with real cameras
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details. Thirdparty packages and libraries have their own licenses.
- V4L2 Linux kernel subsystem
- Go community for excellent multimedia libraries
- GUI framework maintainers for their outstanding work
- Allen Dang and Dear ImGui for the immediate mode GUI paradigm
- GIO for an amazing go based UI system
Note: This project serves as both a practical camera application and a comprehensive comparison of Go GUI frameworks for multimedia applications. Each backend implementation demonstrates different approaches to real-time video rendering in Go.