MatAnyone2 Add Point
One Click's Worth of SAM Guidance, as a Node
- prompt
- prompt
- point_count
SAM works off points: each click tells it "the thing I want is here" (positive) or "this isn't it" (negative). MatAnyoneAddPoint is the node version of a single click. Feed it an existing MATANYONE_PROMPT, give it an x, a y, and a label, and it returns the same prompt with that point appended - plus a running point_count.
It's one of those deceptively simple nodes that makes the whole scripted pipeline possible. Chain it: Prompt Start → Add Point → Add Point → SAM Refine. Each Add Point adds exactly one point to the shared prompt, so you build up your foreground/background guidance one coordinate at a time, visibly, in the graph. The extended demo shows the pattern with a + point and a − point feeding one refine.
The inputs that matter
x/y(defaults 512 / 320, range up to 16384) - pixel coordinates in the frame you'll refine against. These defaults are just placeholder values; in practice you set them to where the subject actually is.label-positive(foreground: include this region) ornegative(background: exclude it). Under the hood positive becomes label1, negative becomes0, which is exactly what SAM's predictor expects.
Outputs: prompt (the mutated prompt - this is the one you re-feed into the next Add Point or into SAM Refine) and point_count (INT, the total points so far, so you can see the prompt growing).
The pattern that actually works
SAM is remarkably forgiving - a couple of positive points inside the subject and one negative point on a nearby background region that's confusing it is usually enough for a good first-frame mask. The iterative loop is the point of this node: mask comes back wrong, add one more point, refine again. Unlike the editor, every step is visible in your graph and replayable.
Install & gotchas
It's part of the MatAnyone2 Video Matting pack: ComfyUI Manager search "MatAnyone2", or git clone https://github.com/dreamrec/MatAnyone2_ComfyUI into custom_nodes, pip install -r requirements.txt, python install.py, restart.
The trap is the same one that bites all the coordinate nodes: pixels are relative to the frame you feed SAM Refine. The defaults (512, 320) are from the pack's demo clip, not your footage. And a small thing that trips people: the node appends, it never replaces - so if you feed in a prompt with three points and add one, you get four. To start over, re-wire from Prompt Start rather than trying to subtract. There's no remove-point here; if you overshoot, rebuild the chain. Cheap, but it's the kind of thing you feel at 2 a.m.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | MATANYONE_PROMPT | — | |
| x | INT | 5120–16384 | — |
| y | INT | 3200–16384 | — |
| label | COMBO | positive | 2 options: positive, negative |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| prompt | MATANYONE_PROMPT | — |
| point_count | INT | — |