Manim Vision v2: spatial collision intelligence for Manim scenes, with LLM-friendly check digests, grouped telemetry, and layout-aware overlap filtering.
Project description
Manim Vision
Manim Vision adds spatial collision awareness to Manim Community scenes. It watches your scene as add, play, and remove run, detects meaningful overlaps, and emits collision timelines that an LLM can use to fix layout problems without reading video frames.
| PyPI | pip install manim-vision |
| Python | 3.10, 3.11, or 3.12 |
| License | MIT |
What it does
- Hooks a live
Scenewithout changing your source class at import time. - Converts tracked
VMobjectgeometry to Shapely shapes and checks overlap with anSTRtree. - Suppresses obvious noise such as glyph-on-glyph kerning, centered text-in-cell layouts, and tiny dust overlaps.
- Tracks overlap intervals, so a collision that persists for 100 plays is reported once with a start time and end time.
- Labels collisions with scene-meaningful names instead of raw memory ids.
- Aggregates leaf-precise hits into scene-level collision episodes, so one visual problem becomes one readable record.
- Produces a compact scene summary by default, with optional human-readable or silent modes.
- Can replay any monitored scene as a separate collision-overlay video for visual debugging.
Installation
pip install manim-vision
Dependencies are declared in pyproject.toml and include manim, shapely, wrapt, numpy, and jsonschema.
Quick start
Call ManimVision.monitor(self) early in construct(), then shut it down at the end so queued collision work can flush.
from manim import BLUE, RED, Create, Circle, RIGHT, Scene, Square
from manim_vision import ManimVision
class MyScene(Scene):
def construct(self):
ManimVision.monitor(self) # default: compact LLM summary
circle = Circle(radius=1, color=BLUE)
square = Square(side_length=1.2, color=RED)
square.next_to(circle, RIGHT, buff=0)
self.add(circle, square)
self.play(Create(circle), Create(square))
ManimVision.shutdown(self)
print(ManimVision.results(self))
Output modes
ManimVision.monitor(scene, output_mode=...) accepts one optional mode:
"llm": default. Collects collision events during the scene and writes one semantic v2 summary at shutdown tomedia/manim_vision/<SceneName>_check_digest.jsonl."human": collects the same events but writes a readable interval report for developers."silent": writes nothing to disk or stdout and keeps results available throughManimVision.results(scene).
Example:
ManimVision.monitor(self, output_mode="silent")
# ...
ManimVision.shutdown(self)
summary = ManimVision.results(self)
To generate a diagnostic overlay video after a run:
overlay_path = ManimVision.render_overlay(
r"C:\path\to\scene.py",
"MyScene",
)
print(overlay_path)
Output files
By default, Manim Vision writes under your Manim media directory:
media/manim_vision/<SceneName>_check_digest.jsonl: semantic collision timeline with object names, intervals, contact spans, hotspots, and fix hints.media/manim_vision/<SceneName>_finalcontextcollisionreport.json: compact LLM-facing report for feedback loops.media/manim_vision/<SceneName>_overlaydata.json: geometry-rich replay payload used to render diagnostic overlay videos.media/manim_vision/<SceneName>_spatial_log.txt: human-readable collision timeline in human mode.media/manim_vision/<SceneName>_spatial.jsonl: legacy per-event JSONL, only whenMANIM_VISION_PER_PAIR_JSONL=1.
Override the directory with MANIM_VISION_REPORT_DIR.
Public API
ManimVision.monitor(scene, output_mode="llm")ManimVision.shutdown(scene)ManimVision.results(scene)ManimVision.render_overlay(scene_or_script, scene_name=None, ...)
Exceptions re-exported from manim_vision:
ManimVisionErrorManimVisionGeometryErrorManimVisionSchemaErrorManimVisionProxyError
How it works
ManimVision.monitor(scene)attaches an engine, solver, dispatcher, lock, and worker executor to the live scene instance.- A mixin is inserted at runtime so
add,play, andremovecan register, resync, and deregister geometry. - Collision checks run on a single-worker background executor under a scene lock.
- Raw leaf collisions are filtered, merged by semantic owner pair into one continuous overlap episode, and flushed on shutdown.
- The default v2 report keeps exact timings and contact locations while hiding animation-internal path noise from the final LLM-facing output.
Notes
- Analysis is 2D and based on overlap area, not full 3D physics.
- Touching edges without positive overlap are ignored.
- Some concave cases use centroid-based fallbacks for fix hints.
- Internal lock-bearing state stays on proxies, so Manim creation-style animations still deep-copy safely.
Development
python -m venv .venv
.venv\Scripts\activate
pip install -e ".[dev]"
python -m pytest
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file manim_vision-0.2.0.tar.gz.
File metadata
- Download URL: manim_vision-0.2.0.tar.gz
- Upload date:
- Size: 43.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac3485e58d7dd9dea552e254fcd69f77a047dd6d39e8c7da672367e72398c731
|
|
| MD5 |
80b67c622128b5f94b853e638a0fd0d6
|
|
| BLAKE2b-256 |
2c125854800c9ac1e8fc16c60b797a3af7d6fa426b38e701c1504fc9c300f774
|
File details
Details for the file manim_vision-0.2.0-py3-none-any.whl.
File metadata
- Download URL: manim_vision-0.2.0-py3-none-any.whl
- Upload date:
- Size: 41.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
309278d47e1cfd63db11a00801755da9f49d36523d7299af8cff357b8ec1cb1f
|
|
| MD5 |
3385502dda17afdf0cad0bbef8ffc0c7
|
|
| BLAKE2b-256 |
2fa8ec9b61ffc64d4a247c23f7507e9b9620b5122f4a23421fa65c8eff617ee8
|