OpenCV cornerSubPix_1
CornerSubPix_1 — the twin, and a worked example of the string inputs
- image
- corners
- nparray
cornerSubPix_1 is the auto-generated twin of cornerSubPix_0 - same function (cv2.cornerSubPix), same inputs, same output. The pack emits one node per OpenCV overload and they're interchangeable. So instead of re-explaining the math, let's do what you actually came here for: make the thing run, because this node has the pack's weirdest inputs and the failure mode is a syntax error, not a crash you'll understand.
What the inputs really want
Three of the five inputs are STRING fields that get parsed as Python literals. The generator couldn't turn OpenCV composite types into widgets, so it went with ast.literal_eval - you type code-ish text into a text box. Get it right and it's fine; get it wrong and ComfyUI throws invalid syntax (<unknown>, line 0).
A working setup, end to end:
image- grayscale nparray (same image your corners came from).corners- detected corners, N×2float32nparray.winSize→(5, 5)- search window size.zeroZone→(-1, -1)- "no dead zone."criteria→(3, 40, 0.001)- TermCriteria as a tuple: type 3 =EPS + MAX_ITER, 40 iterations max, stop once movement is under 0.001 px.
Notice the parentheses. Square brackets [5, 5] also parse (a list), but the canonical form is a tuple, and anything with stray quotes or a bare word breaks literal_eval with exactly that "invalid syntax" line. If you see it, it's your typing, not the node.
What comes out
One nparray of refined corner coordinates, same shape as the input. The shifts are sub-pixel, so don't eyeball it - compare numbers. If you wire this into camera-calibration or stereo geometry, those fractions of a pixel are the entire point. If you don't have a numerical consumer for the output, you don't need this node yet; cornerHarris_0 or cornerMinEigenVal_0 for a mask is more useful.
Install
From ComfyUI Manager, search opencv-comfyui and install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
Restart. Dependencies: opencv-contrib-python, numpy, torch. No models to download.
Gotchas worth internalizing
- The
_1suffix means nothing. Same overload story as every node in this pack. cornersmust befloat32; int points from another node will trip OpenCV's type check.- Grayscale image required; color trips the
CV_8UC1assertion. - Batch size 1 only -
Image2Nparrayrefuses more; useImageFromBatchto isolate a frame.
This is the "expect dragons" part of the pack made visible: a genuinely useful classical function wearing auto-generated, string-parsed inputs. Learn the three literal formats and it becomes routine.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | NPARRAY | — | |
| corners | NPARRAY | — | |
| winSize | STRING | — | |
| zeroZone | STRING | — | |
| criteria | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |