TriangleVision is a high-performance video processing tool that converts standard video (e.g., MP4) into a stylized, real-time mesh of triangles. It blends geometry and aesthetics to create a unique visual style while maintaining image detail and screen ratio.
- Real-time Processing: Process webcam or video files at 30+ FPS (on modern hardware).
- GPU-Accelerated Rendering: Utilizes ModernGL for high-performance triangle rendering.
- Intelligent Point Sampling:
- Delaunay Triangulation: Creates a smooth, connected mesh.
- Edge Density Adaptation: Automatically adds more detail to high-complexity areas.
- Human/Face Detection: Enhanced detail in areas containing people.
- Motion Tracking: Increased triangle density in regions with significant movement.
- Custom
.trivCodec: A custom binary format for storing triangle-based video data with high efficiency. - Multiple Modes:
- Realtime: Live camera or video file playback with real-time triangulation.
- Encode: Convert standard videos into optimized
.trivfiles. - Player: High-speed playback of
.trivfiles. - Export: Export triangulated videos back to standard formats (MP4, MKV).
- Visual Styles: Toggle between standard triangulation, Rotoscope (ink edges + cell shading), and Heatmap modes.
TriangleVision is built with Python and leverages several powerful libraries for performance and geometric calculations:
- OpenCV: Core image processing, feature detection (Shi-Tomasi), and human detection (HOG + Haar Cascades).
- SciPy (Delaunay): High-speed triangulation of sampled points.
- ModernGL: GPU-accelerated triangle rendering with custom GLSL shaders.
- NumPy & Numba: Vectorized operations and JIT compilation for color sampling and data processing.
- Threaded Capture: Multi-threaded video grabbing to ensure smooth input regardless of processing load.
- Python 3.8+
- A GPU supporting OpenGL 3.3+ (for hardware acceleration)
-
Clone the repository:
git clone https://github.com/yourusername/triangleVision.git cd triangleVision -
Install dependencies:
pip install -r requirements.txt
Run the tool on your webcam with default settings:
python3 main.py realtime --quality medium --humanConvert an MP4 to a .triv file at high quality:
python3 main.py encode input.mp4 output.triv --quality high --humanEnjoy the triangulated version of your video:
python3 main.py play output.trivExport a stylized version for sharing:
python3 main.py export output.triv finished_video.mp4 --rotoscope--source: Camera ID or video file path (forrealtime).--triangles: Manually set the target number of triangles.--quality: Adaptive quality presets (low,medium,high).--rotoscope: Enable ink edges and cell-shading aesthetics.--human: Enable smart detail enhancement on humans.--output: Save arealtimesession directly to a.trivfile.
This project is licensed under the MIT License - see the LICENSE file for details.