For the Spanish version, see README.es.md.
Repository for converting PNGs to vector strokes, generating/editing SVGs, and producing animations and multimedia resources. Includes GUI tools, conversion utilities, and code for playing/organizing audio and lyrics for animations.
This project demonstrates advanced techniques in image processing, vector graphics, and multimedia application development in Python, integrating scientific and rendering libraries to create conversion and animation pipelines.
- Language: Python 3.8+
- Main Libraries:
pygame: Real-time rendering, audio management, and events.numpy: Mathematical calculations and array manipulation.Pillow: Basic image processing.opencv-python: Contour extraction and raster image vectorization.svgpathtools: Manipulation and conversion of SVG paths, including Bézier curves.manim: Generation of mathematical animations and frame extraction.tkinter: Native graphical interfaces (included in Python standard).tkfontawesome: Icons for tkinter interfaces.
- External Tools:
ffmpeg: Video frame extraction.
- Clone or download the repository.
- Create a virtual environment (recommended):
python -m venv .venv .\.venv\Scripts\Activate.ps1 - Install dependencies:
pip install -r requirements.txt - Ensure you have resources like
res/txt/letra.txtandres/wav/capibara.wav(optional). For development, installmanimandffmpegif you want to regenerate animations.
Run from the repository root:
python main.pyThis opens a main menu with a tkinter interface that allows access to the following functionalities:
- Play capibara karaoke: Starts the main animation and audio/lyrics synchronization application.
- Color Picker: Interactive tool for assigning colors to SVG paths.
- Point Picker: Tool for marking landmarks (reference points) in SVGs.
- Convert PNG drawing to SVG Bézier: Graphical interface for converting PNG images to SVGs with Bézier curves.
main.py: Main menu with graphical interface (tkinter) to access tools.png_to_bezier_gui.py: GUI for automatic PNG → SVG linear → SVG Bézier conversion.recreate_pngs.py: Script to regenerate animations: runs Manim and extracts frames with ffmpeg.requirements.txt: List of Python dependencies.res/: Static resources (SVGs, texts, colors, audio).media/: Generated media (images, videos).src/: Main source code:audio.py: Audio management withpygame.mixer.capibara_model.py: Loading and rendering of PNG frames, center calculation withsvgpathtools.game.py: Main loop, events, and scene composition.lyrics.py: Processing and synchronization of lyrics.
utils/: Technical utilities:color_picker.py: Interactive color assignment to SVG paths.point_picker.py: Landmark marking in SVGs.convertir_png_a_svg_lineal.py: Raster image vectorization to linear SVG with OpenCV.convert_svg_to_bezier.py: Conversion of SVG paths to cubic Bézier curves.animar_svg_manim.py: Manim scene for animation based on colored SVGs.
-
Raster to linear SVG vectorization (
convertir_png_a_svg_lineal.py):- Uses OpenCV to extract contours from PNG images.
- Generates SVG paths with polygonal lines.
-
Conversion to Bézier curves (
convert_svg_to_bezier.py):- Uses
svgpathtoolsto convert lines to cubic Bézier curves using Catmull-Rom approximation.
- Uses
-
Unified graphical interface (
png_to_bezier_gui.py):- Automates the previous steps in a tkinter GUI.
-
Color Picker (
color_picker.py):- Renders SVG in Pygame, allows color selection and assignment to closed paths.
- Saves mapping in JSON for use in animations.
-
Point Picker (
point_picker.py):- Interface for marking reference points (landmarks) in SVGs.
- Facilitates mapping of anatomical parts for precise animations.
-
Manim Scene (
animar_svg_manim.py):- Loads colored SVGs, applies landmarks for deformations.
- Produces MOV video and extracts PNG frames.
-
Complete regeneration (
recreate_pngs.py):- Runs Manim and ffmpeg to update animation resources.
- Image Processing: Integration of OpenCV for morphological analysis and feature extraction.
- Vector Graphics: Use of
svgpathtoolsfor computational geometry and parametric curves. - Mathematical Animation: Manim for visualization of landmark-based transformations.
- Interface and Usability: Tkinter for accessible GUIs, Pygame for interactive rendering.
- Audio and Synchronization:
pygame.mixerfor playback, with timestamps for lyrics alignment. - Compatibility: Configured for Windows (e.g.,
SDL_VIDEODRIVER=windibin Pygame). - Architecture: Modular, with separation of utilities, application logic, and resources.
This repository serves as a practical example for learning the integration of Python libraries in multimedia and graphics pipelines.
The rights to the song and lyrics belong to the Canta y Baila page. Reference: YouTube Link
Andrey Rodríguez Araya



