diff --git a/.agents/skills/formvfx-harness/references/tools.md b/.agents/skills/formvfx-harness/references/tools.md index d21ca6e..5a7241a 100644 --- a/.agents/skills/formvfx-harness/references/tools.md +++ b/.agents/skills/formvfx-harness/references/tools.md @@ -145,7 +145,7 @@ Turns SVG markup into a shape layer (paths, fills, strokes, gradients, groups an ## planar_track -Planar tracking: follows a flat surface (a screen, a sign, a wall, a tabletop) through footage and corner-pins another layer onto it. Draw a mask around the surface on the footage layer first (mask.new or layer.addMask, in layer pixels at the reference time). track forward, backward or both analyses the mask with the Perspective method from the reference time (a homography from features inside the mask, every frame); without track the mask must already be tracked. surface is the plane's four corners at the reference time (upper left, upper right, lower left, lower right, layer pixels; default the mask's four vertices or its bounding box). With target, a Corner Pin is keyed on that layer so its corners ride the surface; the result is also kept as a Perspective tracker on the footage for re-applying to other layers. One undo step for the corner pin (tracking is its own step). +Planar tracking: follows a flat surface (a screen, a sign, a wall, a tabletop) through footage and corner-pins another layer onto it. Draw a mask around the surface on the footage layer first (mask.new or layer.addMask, in layer pixels at the reference time). track forward (reference to the end), backward (start to the reference) or both analyses the mask with the Perspective method from the reference time (a homography from features inside the mask, every frame); without track nothing is analysed: the layer's existing Perspective tracker (an earlier planar_track, or an analysed perspective track.new) is pinned onto target, which is then required, and surface is not read. held in the result lists the times of frames that did not track and hold the last tracked surface (confidence 0 on the tracker). surface is the plane's four corners at the reference time (upper left, upper right, lower left, lower right, layer pixels; default the mask's four vertices or its bounding box). With target, a Corner Pin is keyed on that layer so its corners ride the surface; the result is also kept as a Perspective tracker on the footage for re-applying to other layers. One undo step for the corner pin (tracking is its own step). - `layer`: id or name; required; Layer id, `#n` (1 = top) or name. - `mask`: id or name; Mask uid, 1-based index or name (default the first mask). diff --git a/.claude/skills/formvfx-harness/references/tools.md b/.claude/skills/formvfx-harness/references/tools.md index d21ca6e..5a7241a 100644 --- a/.claude/skills/formvfx-harness/references/tools.md +++ b/.claude/skills/formvfx-harness/references/tools.md @@ -145,7 +145,7 @@ Turns SVG markup into a shape layer (paths, fills, strokes, gradients, groups an ## planar_track -Planar tracking: follows a flat surface (a screen, a sign, a wall, a tabletop) through footage and corner-pins another layer onto it. Draw a mask around the surface on the footage layer first (mask.new or layer.addMask, in layer pixels at the reference time). track forward, backward or both analyses the mask with the Perspective method from the reference time (a homography from features inside the mask, every frame); without track the mask must already be tracked. surface is the plane's four corners at the reference time (upper left, upper right, lower left, lower right, layer pixels; default the mask's four vertices or its bounding box). With target, a Corner Pin is keyed on that layer so its corners ride the surface; the result is also kept as a Perspective tracker on the footage for re-applying to other layers. One undo step for the corner pin (tracking is its own step). +Planar tracking: follows a flat surface (a screen, a sign, a wall, a tabletop) through footage and corner-pins another layer onto it. Draw a mask around the surface on the footage layer first (mask.new or layer.addMask, in layer pixels at the reference time). track forward (reference to the end), backward (start to the reference) or both analyses the mask with the Perspective method from the reference time (a homography from features inside the mask, every frame); without track nothing is analysed: the layer's existing Perspective tracker (an earlier planar_track, or an analysed perspective track.new) is pinned onto target, which is then required, and surface is not read. held in the result lists the times of frames that did not track and hold the last tracked surface (confidence 0 on the tracker). surface is the plane's four corners at the reference time (upper left, upper right, lower left, lower right, layer pixels; default the mask's four vertices or its bounding box). With target, a Corner Pin is keyed on that layer so its corners ride the surface; the result is also kept as a Perspective tracker on the footage for re-applying to other layers. One undo step for the corner pin (tracking is its own step). - `layer`: id or name; required; Layer id, `#n` (1 = top) or name. - `mask`: id or name; Mask uid, 1-based index or name (default the first mask). diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0bfb5f..08d5d5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -111,6 +111,9 @@ jobs: run: | (cd backend && ./oc_install) ./formvfx install-native --dev + - name: Compositing engine unit tests + working-directory: native/fvx-core + run: cargo test --locked --no-default-features --lib - name: Engine and compositing tests working-directory: backend run: | diff --git a/README.md b/README.md index cfb385b..4185311 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@
-
+
@@ -102,7 +102,7 @@ FormVFX loads Form extensions (API 1): FormPortal installs them, form.ext makes
## Under the hood
-Version 0.61.0 · Apache-2.0 · compositing engine: FormVFX's own, in Rust (`native/fvx-core`)
+Version 0.61.1 · Apache-2.0 · compositing engine: FormVFX's own, in Rust (`native/fvx-core`)
- **Engine:** `native/fvx-core` is the compositing engine, Rust with PyO3, loaded by the engine service as the `fvx_core` extension.
- **Service:** a FastAPI engine service in `backend`, with the MCP server and the embedded terminal.
diff --git a/backend/HASHOUT_LOG.md b/backend/HASHOUT_LOG.md
index 48248c2..16620f7 100644
--- a/backend/HASHOUT_LOG.md
+++ b/backend/HASHOUT_LOG.md
@@ -435,3 +435,9 @@ Living context for the engine service. Code carries almost no comments; the reas
- Sources by slot kind (fix after the first commit): keyframe slots go up as stills on multiples of 8 from the first frame of the range; a mask slot needs its own layer and is rendered from it, never from the source; each input matches its slot's kind and the server's limits; uploads stream from disk; a footage layer's own file is sent only when trims or stretch leave it untouched; server-supplied names never leave the result folder; results land at the first frame sent; the websocket follower stops when no job is open and keeps its place across a reconnect.
- Agents: no tool takes an address or a path, so an agent cannot point the engine at another server or send a file; `comfy_run` asks like any change and `comfy_job` only knows jobs started in this session.
- Verified: against the live pack, settings get and put, the handshake, the workflow list with readiness, the selftest on a solid layer over frames 0 to 8 (a 9-frame plate, then done and a footage layer above the source as one undo step) and retry with a new seed; 403 without the window key; `test_f1_guard.py` and `test_window_key.py` 67 passed; `python3 setup/lint_text.py .` 0 findings. Not run: a matte landing, a movie output, cancel, a server restart mid-job, websocket progress. No test was added by the owner's decision.
+
+## Planar Track directions and reuse (0.61.1)
+
+- Kind: fix. Logged: v0.61.1 · 2026-12-03. Refers to `app/agent/tools.py` and the new `tests/test_planar_track.py`.
+- The engine now reads `track` (see `native/fvx-core/HASHOUT_LOG.md`, 0.61.1). The `planar_track` description says what forward and backward cover, that leaving `track` out pins the layer's existing Perspective tracker onto a required `target` without analysing, and that `held` lists the frames that hold the last tracked surface. `rpc.py` already passed `track` through and is unchanged.
+- Checked: `tests/test_planar_track.py` (4 tests) builds a textured precomp that moves, a mask and a solid through `command.execute`, then calls `track.planar` over `/api/rpc` with the window key: forward and backward key only their side of the reference, leaving `track` out pins the solid from the first tracker without a second one, and with nothing tracked it is refused. All four fail on the 0.61.0 engine.
diff --git a/backend/app/__init__.py b/backend/app/__init__.py
index a076e5d..daa1407 100644
--- a/backend/app/__init__.py
+++ b/backend/app/__init__.py
@@ -1 +1 @@
-__version__ = "0.61.0"
+__version__ = "0.61.1"
diff --git a/backend/app/agent/tools.py b/backend/app/agent/tools.py
index df238c6..4485dc2 100644
--- a/backend/app/agent/tools.py
+++ b/backend/app/agent/tools.py
@@ -104,7 +104,7 @@ def _tool(name: str, description: str, props: dict, required: list[str] | None =
{"action": {"type": "string", "enum": ["list", "apply"]}, "preset": {"type": "string"}, "query": {"type": "string"}, "category": {"type": "string"}, "layer": _LAYER, "layers": {"type": "array", "items": _LAYER}, "time": _TIME, "comp": _COMP}, ["action"]),
_tool("shapes_from_svg", "Turns SVG markup into a shape layer (paths, fills, strokes, gradients, groups and clips become editable shape contents), centred in the composition, one undo step. Use it for logos, icons and vector art you write as SVG.",
{"svg": {"type": "string"}, "name": {"type": "string"}, "comp": _COMP}, ["svg"]),
- _tool("planar_track", "Planar tracking: follows a flat surface (a screen, a sign, a wall, a tabletop) through footage and corner-pins another layer onto it. Draw a mask around the surface on the footage layer first (mask.new or layer.addMask, in layer pixels at the reference time). track forward, backward or both analyses the mask with the Perspective method from the reference time (a homography from features inside the mask, every frame); without track the mask must already be tracked. surface is the plane's four corners at the reference time (upper left, upper right, lower left, lower right, layer pixels; default the mask's four vertices or its bounding box). With target, a Corner Pin is keyed on that layer so its corners ride the surface; the result is also kept as a Perspective tracker on the footage for re-applying to other layers. One undo step for the corner pin (tracking is its own step).",
+ _tool("planar_track", "Planar tracking: follows a flat surface (a screen, a sign, a wall, a tabletop) through footage and corner-pins another layer onto it. Draw a mask around the surface on the footage layer first (mask.new or layer.addMask, in layer pixels at the reference time). track forward (reference to the end), backward (start to the reference) or both analyses the mask with the Perspective method from the reference time (a homography from features inside the mask, every frame); without track nothing is analysed: the layer's existing Perspective tracker (an earlier planar_track, or an analysed perspective track.new) is pinned onto target, which is then required, and surface is not read. held in the result lists the times of frames that did not track and hold the last tracked surface (confidence 0 on the tracker). surface is the plane's four corners at the reference time (upper left, upper right, lower left, lower right, layer pixels; default the mask's four vertices or its bounding box). With target, a Corner Pin is keyed on that layer so its corners ride the surface; the result is also kept as a Perspective tracker on the footage for re-applying to other layers. One undo step for the corner pin (tracking is its own step).",
{"layer": _LAYER, "mask": {"description": "Mask uid, 1-based index or name (default the first mask).", "anyOf": [{"type": "integer"}, {"type": "string"}]}, "target": _LAYER, "surface": {"type": "array", "items": {"type": "array", "items": {"type": "number"}, "minItems": 2, "maxItems": 2}, "minItems": 4, "maxItems": 4}, "reference": _TIME, "track": {"type": "string", "enum": ["forward", "backward", "both"]}, "start": {"type": "number"}, "end": {"type": "number"}, "comp": _COMP}, ["layer"]),
_tool("object_matte", "Object Matte: isolates one object (a person, a car, a product) in footage from one point on it. action preview segments the object at time and returns its bounding box, coverage and the model's confidence without changing anything; action select puts a Roto Paint on the layer seeded at that point (one undo step), spans the whole layer and propagates it (direction both by default; wait true blocks until done, otherwise call wait). The layer's alpha becomes the object's matte. Needs the MobileSAM model (roto.model.download {id: mobilesam}).",
{"action": {"type": "string", "enum": ["preview", "select"]}, "layer": _LAYER, "point": {"type": "array", "items": {"type": "number"}, "minItems": 2, "maxItems": 2, "description": "[x, y] in the layer's pixels"}, "time": _TIME, "direction": {"type": "string", "enum": ["both", "forward", "backward"]}, "wait": {"type": "boolean", "default": False}, "comp": _COMP}, ["action", "layer", "point"]),
diff --git a/backend/tests/test_planar_track.py b/backend/tests/test_planar_track.py
new file mode 100644
index 0000000..918b5f6
--- /dev/null
+++ b/backend/tests/test_planar_track.py
@@ -0,0 +1,90 @@
+import random
+import struct
+import zlib
+
+import pytest
+
+from conftest import LOCAL_HEADER
+
+W, H, FPS, FRAMES = 160, 120, 10, 8
+REFERENCE = 0.3
+REGION = [[50, 40], [110, 40], [110, 80], [50, 80]]
+
+
+def write_texture(path):
+ rnd = random.Random(7)
+ cells = [[rnd.randrange(256) for _ in range(W // 4 + 2)] for _ in range(H // 4 + 2)]
+ rows = b"".join(b"\x00" + bytes(cells[y // 4][x // 4] for x in range(W) for _ in range(3)) for y in range(H))
+
+ def chunk(kind, data):
+ return struct.pack(">I", len(data)) + kind + data + struct.pack(">I", zlib.crc32(kind + data) & 0xFFFFFFFF)
+
+ path.write_bytes(b"\x89PNG\r\n\x1a\n" + chunk(b"IHDR", struct.pack(">IIBBBBB", W, H, 8, 2, 0, 0, 0)) + chunk(b"IDAT", zlib.compress(rows)) + chunk(b"IEND", b""))
+
+
+@pytest.fixture
+def keyed():
+ from app.core import window_key
+
+ return {**LOCAL_HEADER, window_key.HEADER: window_key.KEY}
+
+
+@pytest.fixture
+def rpc(client, keyed):
+ def call(method, **params):
+ body = client.post("/api/rpc", json={"jsonrpc": "2.0", "id": 1, "method": method, "params": params}, headers=keyed).json()
+ return body
+
+ return call
+
+
+@pytest.fixture
+def shot(rpc, tmp_path):
+ def run(command, **params):
+ body = rpc("command.execute", command=command, params=params)
+ assert "result" in body, body
+ return body["result"]
+
+ png = tmp_path / "plane.png"
+ write_texture(png)
+ duration = FRAMES / FPS
+ plate = run("comp.new", name="Plane", width=W, height=H, frameRate=FPS, duration=duration)["comp"]
+ item = run("file.import", paths=[str(png)])["items"][0]
+ image = run("layer.addItem", item=item, comp=plate)["layer"]
+ for n in range(FRAMES):
+ run("prop.addKey", layer=image, comp=plate, path="transform/position", time=n / FPS, value=[W / 2 + 1.5 * n, H / 2 + 0.8 * n])
+ comp = run("comp.new", name="Shot", width=W, height=H, frameRate=FPS, duration=duration)["comp"]
+ insert = run("layer.newSolid", name="Insert", color="#ff0000", comp=comp)["layer"]
+ layer = run("layer.addItem", item=plate, comp=comp)["layer"]
+ run("mask.new", layer=layer, comp=comp, vertices=REGION, closed=True)
+ return {"comp": comp, "layer": layer, "insert": insert, "run": run}
+
+
+def trackers(shot):
+ status = shot["run"]("track.status", layer=shot["layer"], comp=shot["comp"])
+ return status.get("trackers") or []
+
+
+def test_the_rpc_tracks_forward_only_when_asked(rpc, shot):
+ body = rpc("track.planar", layer=shot["layer"], comp=shot["comp"], reference=REFERENCE, track="forward")
+ assert body["result"]["frames"] == FRAMES - round(REFERENCE * FPS), body
+ assert body["result"]["held"] == []
+
+
+def test_the_rpc_tracks_backward_only_when_asked(rpc, shot):
+ body = rpc("track.planar", layer=shot["layer"], comp=shot["comp"], reference=REFERENCE, track="backward")
+ assert body["result"]["frames"] == round(REFERENCE * FPS) + 1, body
+
+
+def test_the_rpc_pins_from_the_existing_tracker_when_track_is_left_out(rpc, shot):
+ first = rpc("track.planar", layer=shot["layer"], comp=shot["comp"], reference=REFERENCE, track="both")["result"]
+ again = rpc("track.planar", layer=shot["layer"], comp=shot["comp"], reference=REFERENCE, target=shot["insert"])
+ assert again["result"]["tracker"] == first["tracker"], again
+ assert again["result"]["applied"] == FRAMES
+ assert again["result"]["targetName"] == "Insert"
+ assert len(trackers(shot)) == 1
+
+
+def test_the_rpc_refuses_already_tracked_when_nothing_was_tracked(rpc, shot):
+ body = rpc("track.planar", layer=shot["layer"], comp=shot["comp"], reference=REFERENCE, target=shot["insert"])
+ assert "no Perspective tracker" in body["error"]["message"], body
diff --git a/demo/assets/demo.js b/demo/assets/demo.js
index 8c0bae1..3b4bcea 100644
--- a/demo/assets/demo.js
+++ b/demo/assets/demo.js
@@ -1,4 +1,4 @@
-(function(){var e=`0.61.0`;function t(e,t,n){let r=new Map;for(let t of Array.from(e.children)){let e=t.dataset.key;e!==void 0&&r.set(e,t)}let i=e.firstElementChild,a=new Set;for(let o of t){let t=n.key(o);a.add(t);let s=r.get(t);s||(s=n.create(o),s.dataset.key=t),n.update(s,o),s===i?i=i.nextElementSibling:e.insertBefore(s,i)}for(let[e,t]of r)a.has(e)||t.remove()}function n(e,t){e&&e.textContent!==t&&(e.textContent=t)}function r(e,t,n){e&&e.classList.contains(t)!==n&&e.classList.toggle(t,n)}function i(){document.body.classList.contains(`app-ready`)||requestAnimationFrame(()=>requestAnimationFrame(()=>{document.body.classList.add(`app-ready`),`__TAURI_INTERNALS__`in window&&requestAnimationFrame(()=>{try{Promise.resolve(window.__TAURI_INTERNALS__?.invoke?.(`app_ready`)).catch(()=>void 0)}catch{return}})}))}function a(e){let t=document.createElement(`template`);return t.innerHTML=e.trim(),t.content.firstElementChild}function o(e,t){let n=e.querySelector(t);if(!n)throw Error(`missing element: ${t}`);return n}function s(e,t){e.disabled!==t&&(e.disabled=t)}/Mac|iPhone|iPad/.test(navigator.platform||navigator.userAgent);var c={cursor:``,moveSel:``,marquee:``,ellipseSelect:``,lasso:``,lassoSelect:``,wandSelect:``,magicWand:``,brush:``,eraser:``,eyeDropper:``,hand:``,pan:``,zoomIn:``,zoomOut:``,fitView:``,tMove:``,tMarquee:``,tEllipse:``,tLasso:``,tPolyLasso:``,tObjectSelect:``,tQuickSelect:``,tWand:``,tCrop:``,tEyedropper:``,tSpotHeal:``,tHealBrush:``,tPatch:``,tRemove:``,tBrush:``,tEraser:``,tStamp:``,tSmudge:``,tBlur:``,tSharpen:``,tDodge:``,tBurn:``,tSponge:``,tGradient:``,tBucket:``,tPen:``,tFreeformPen:``,tCurvaturePen:``,tType:``,tPathSelect:``,tDirectSelect:``,tRect:``,tEllipseShape:``,tHand:``,tZoom:``,alignLeftEdge:``,alignHcenterEdge:``,alignRightEdge:``,alignTopEdge:``,alignVcenterEdge:``,alignBottomEdge:``,distributeH:``,distributeV:``,viewGrid:``,viewList:``,pilcrow:``,charA:``,panelProps:``,collapseRight:``,collapseLeft:``,more3:``,panelNav:``,swatchGrid:``,film:``,tLiquify:``,tPolygon:``,tStar:``,tLine:``,tArrow:``,tHeart:``,tCustomShape:``,quickMask:``,screenMode:``,tHistoryBrush:``,tFrame:``,tFrameEllipse:``,grip:``,tConvertPoint:``,tMagLasso:``,tRowMarquee:``,tColMarquee:``,tSelBrush:``,tPencil:``,tMagicEraser:``,tPatternStamp:``,tBgEraser:``,tColorSampler:``,tRuler:``,tNote:``,tCount:``,tTypeV:``,tTypeMask:``,tTypeMaskV:``,alignJustify:``,tTriangle:``,tCAMove:``,tRedEye:``,tRotateView:``,minus:``,halfCircle:``,sliders:``,search:``,sun:``,moon:``,alignLeft:``,alignCenter:``,alignRight:``,plus:``,crop:``,gradient:``,directSelectTool:``,smartObject:``,tween:``,camera:``,history:``,play:``,penTool:``,healBrushTool:``,patchTool:``,typeTool:``,rectTool:``,circleTool:``,smudge:``,objectSelect:``,quickSelect:``,bucket:``,dodge:``,burn:``,sponge:``,blurTool:``,dodgeBurn:``,transform:``,rotate:``,flipH:``,flipV:``,eye:``,eyeOff:``,link:``,unlink:``,mask:``,clipMask:``,folder:``,drive:``,folderOpen:``,add:``,remove:``,delete:``,duplicate:``,layers:``,chevronDown:``,chevronRight:``,chevronLeft:``,chevronUp:``,invertLayer:``,invert:``,levels:``,histogram:``,image:``,merge:``,paintbrush:``,close:``,check:``,save:``,load:``,newFile:``,download:``,upload:``,settings:``,theme:``,dots:``,menu:``,undo:``,redo:``,info:``,warning:``,error:``,success:``,loading:``,refresh:``,fileImage:``,fill:``,lock:``,unlock:``,canvasGrid:``,dragHandle:``,maximize:``,send:``,pfGeneral:``,pfInterface:``,pfType:``,pfFile:``,pfHistory:``,pfPerformance:``,pfGuides:``,pfPlugins:``,pfComposition:``,pfCube:``,pfAudio:``,pfRoto:``,pfFace:``,pfLabel:``,pfFold:``};function l(e,t=16){return``}var u=0,d=class{scrim;body;foot;titleEl;lastFocus=null;onClose=null;constructor(e,t=440){this.scrim=a(`