OpenCV findHomography_0
Perspective warp without calibration — findHomography
- srcPoints
- dstPoints
- mask
- nparray_0
- nparray_1
Of all the geometry nodes in this pack, findHomography is the one you're most likely to actually use, because it's the answer to a question people hit all the time: "I have two images of the same flat thing, how do I map one onto the other?" The homography matrix H is a 3x3 perspective transform that maps points from one image plane to another. Give it four or more corresponding points, and it hands you the warp.
OpenCV findHomography_0 wraps cv2.findHomography in its full form. It's the workhorse behind image stitching, perspective correction (turning a skewed photo of a document into a straight-on view), and planar tracking. If you've ever wanted a "straighten the whiteboard photo" node in a workflow, this is the raw material for it.
Inputs
srcPoints/dstPoints- matching points,NPARRAY(Nx1x2orNx2). You're mappingsrcPointsontodstPoints, so pick corresponding landmarks: the four corners of a document, the same features in two frames.method- the estimation method.0= plain least-squares using all points (fine when your correspondences are clean),8= RANSAC (your default for real-world matches with wrong ones in the mix),4= LMEDS,16= RHO. For anything with hand-picked points, RANSAC.ransacReprojThreshold- RANSAC's tolerance in pixels;3.0default, nudge it up if your points are sloppy.maxIters,confidence- RANSAC tuning, leave the defaults.mask- optional, lets you pre-select which points participate.
Outputs: nparray_0 is the 3x3 homography matrix, nparray_1 is the inlier mask. Neither is an image. The matrix is the interesting one - feed it to this pack's warpPerspective node (plus your source image) and you've got the actual warped output you wanted.
The part beginners miss
You need at least four corresponding points, and they must be coplanar in the real world - a homography is a mapping between planes. Two views of the same building facade, or the same document from different angles: homography works. Two views of a 3D scene with depth? The mapping isn't a homography and the result will be garbage. That's not the node failing, that's the math. If your scene has real depth, you want findFundamentalMat (epipolar, not warping) instead.
Also remember this pack's data flow: srcPoints/dstPoints enter as NPARRAY, produced by detection nodes from this same pack (goodFeaturesToTrack, chessboard corners, and friends) or built elsewhere. The outputs are geometry - previewing the matrix via Nparrays2Image earns you the 'NoneType' object has no attribute 'shape' error.
Install
ComfyUI Manager → search opencv-comfyui → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
requirements.txt installs opencv-contrib-python, numpy, torch. The pack imports cv2 at startup - a missing or duplicated OpenCV install means none of the nodes register, and Cannot import name 'guidedFilter' is the classic symptom of two OpenCV packages fighting.
Verdict
findHomography_0 is the version to use - _1 is its byte-identical UMat twin. It's arguably the most practical geometric node in the pack: document straightening, logo/overlay perspective matching, and stitching all start here. Just remember it wants planar scenes, matched points, and RANSAC, and you'll be warping in no time.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| srcPoints | NPARRAY | — | |
| dstPoints | NPARRAY | — | |
| method | INT | — | |
| ransacReprojThreshold | FLOAT | — | |
| maxIters | INT | — | |
| confidence | FLOAT | — | |
| maskopt | NPARRAY | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| nparray_0 | NPARRAY | — |
| nparray_1 | NPARRAY | — |