MatAnyone2 Prompt From Text
Type Your SAM Points Instead of Clicking Them
- prompt
- point_count
Clicking is fine when you're staring at one frame. When you're matting fifty clips where the subject is always in the same spot, clicking is fifty times the work. MatAnyonePromptFromText is the node that turns a block of text into a SAM prompt - coordinates in, a reusable MATANYONE_PROMPT structure out - so your point positions can live in a text field, a file, or a workflow JSON and get replayed identically.
This is the "programmatic" half of the pack's extended demo, and it's the natural answer to anyone who wants batch matting without babysitting an editor. The format is one point per line, x,y,label:
512,320,+
540,318,-
The default is exactly that: a positive point at (512,320) and a negative point at (540,318). + means foreground, - means background. Coordinates are pixels in the frame you'll feed alongside the prompt - so if your frame is 1920×1080, the default points land somewhere near the middle-left, which is fine for testing and wrong for anything real.
What comes out
prompt - the parsed MATANYONE_PROMPT, ready for SAM Refine or further Add Point chaining. point_count - an INT telling you how many points parsed, which is your sanity check: if you wrote three lines and it says 2, one of them didn't parse (or the format drifted). The parser handles the core case cleanly; keep lines tight and you won't trip it.
The workhorse pattern
The reusable trick: keep the same text prompt and just swap the image input on SAM Refine. The prompt doesn't care what frame it's applied to - it's just coordinates. That's the entire appeal of the text path over the editor: the mask definition becomes a value, not a session, so it can be stored, copied, and run against frame after frame. Combine it with Slice Frames on a batch of clips and you've automated the boring part of rotoscoping.
Install & gotchas
Same pack install as everything here - ComfyUI Manager search "MatAnyone2", or clone + pip install -r requirements.txt + python install.py + restart.
The classic mistake: pasting coordinates from the editor, which are already in frame pixels, and assuming they carry over to a differently-sized video. They don't - a point is a point in the frame you run it on. If you're reusing prompts across clips of different resolutions, rescale your coordinates or your mask will drift. And remember +/- are the labels; mixing in a bare number or a third column breaks the parse. When in doubt, watch point_count.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt_text | STRING | 512,320,+ 540,318,- | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| prompt | MATANYONE_PROMPT | — |
| point_count | INT | — |