Nodes/Image Processing Suite for ComfyUI/Interactive Point Collector (SAM2)
ComfyUI Node

Interactive Point Collector (SAM2)

Click on the image to add SAM2 points — the node that finally makes point prompts usable

By marcoc2·Created 2 years ago·Updated 5 months ago· 1
Interactive Point Collector (SAM2)
  • image
  • pos_points_json
  • neg_points_json
coordinates[]
neg_coordinates[]

SAM2 can cut out basically anything you can point at - the question has always been how you point at it inside ComfyUI. Typing raw pixel coordinates into a text box is a miserable experience. PointCollectorSAM2 is the answer: it draws your image right on the node, lets you click to add positive points (things to keep) and negative points (things to exclude), and emits them as JSON ready for a SAM2 inference node.

This is one of those "oh, that's how it should work" nodes. It renders the image in an interactive canvas, tracks how many points you've placed, and hands you a clean pos_points_json / neg_points_json pair on the other end. If you've ever fought with SAM point prompts in ComfyUI, you'll feel the relief immediately.

How it works

The heavy lifting happens in the JavaScript side. A custom extension replaces the node's boring widgets with a canvas overlay showing your input image. You click to drop a positive point, and there's a way to mark negative points (the code tracks them separately), with a counter showing the running tally. The coordinates are recorded in pixel units relative to the image.

On the Python side it's a nearly pure pass-through: the node just validates that your coordinates are well-formed JSON and hands them through. It also sends the image back to the UI as a base64 preview so the canvas can update - and it forces a refresh whenever the points change, so the node re-executes as you click rather than going stale.

There's a hidden string widget for coordinates and another for negative coordinates. They're hidden and populated by the JS - you'll see them in a workflow's raw JSON if you dig, but you never touch them directly.

Inputs and outputs

  • image (IMAGE) - the image you're clicking on. One image in, one set of points out.
  • Outputs pos_points_json and neg_points_json (both STRING) - JSON arrays of {"x": ..., "y": ...} objects in pixel coordinates.

Both outputs plug directly into AnotherSAM2Inference's points_pos / points_neg inputs. The pack's SAM2 plumbing is deliberately consistent, so these wire up without conversion.

Installing it

Part of the AnotherUtils pack - and the JS needs to actually load, so this one has a real install requirement:

cd ComfyUI/custom_nodes
git clone https://github.com/marcoc2/ComfyUI-AnotherUtils.git

Then restart ComfyUI completely. If you installed while ComfyUI was running, the frontend extension won't register and you'll just get a dead node. Install via ComfyUI Manager (search "AnotherUtils") and restart, and you're set. No models, no extra Python deps - but you'll want AnotherLoadSAM2 + AnotherSAM2Inference from the same pack (those auto-download the SAM2 checkpoints on first run).

Gotchas

The image goes through a JPEG re-encode (quality 75) when it's pushed to the canvas, so the preview is slightly lossy - fine for clicking, but don't trust it for fine color work. Points are in image pixel coordinates, which is exactly what the SAM2 service expects, so keep that in mind if you're cropping or resizing anywhere before the inference node - coordinate spaces have to match.

And the usual interactive-node caveat: these point sets are manual and don't travel in saved workflows the way you'd hope if you're re-running unattended. If your workflow is meant to run headless later, this is a design-time node - at runtime, use bbox or detection-derived points instead.

CategoryAnotherUtils/sam2

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
coordinatesSTRING[]
neg_coordinatesSTRING[]

Outputs (2)

NameTypeDescription
pos_points_jsonSTRING
neg_points_jsonSTRING