OpenCV perspectiveTransform_1
The UMat twin of the point-warping node
- src
- m
- dst
- nparray
perspectiveTransform_1 is the UMat twin of perspectiveTransform_0: identical inputs (src, m, optional dst), identical call to cv2.perspectiveTransform, identical nparray output. The numbering is the pack's per-overload generation, nothing more. The full explanation is in the perspectiveTransform_0 article; the essentials are worth repeating because this is a node people misuse.
It transforms points, not images. You hand it an array of coordinates and a homography matrix m, and it returns where those coordinates land after the perspective transform. If you want the image warped, that's warpPerspective - a different node in the same pack. perspectiveTransform is the coordinate-mapping half of the geometry duo, and it pairs with getPerspectiveTransform (compute a 3x3 matrix from four corner correspondences) and findHomography (robust matrix estimation from many matches). The canonical use: rectify a document or map detection boxes between a skewed view and the flattened view.
How it works
Per point, cv2.perspectiveTransform computes M · (x, y, 1) and divides by the homogeneous W - that normalization step is what makes it true perspective, not affine. src must be floating point ((N, 2) or (N, 3) rows, or a single point); m is the 3x3 or 4x4 matrix. Output shape mirrors src - handy as a sanity check.
Inputs: src (points, float32), m (homography), optional dst (ignore it). Output: nparray.
How to install it
Pack-level install, once:
- ComfyUI Manager → search opencv-comfyui → Install, restart ComfyUI.
- Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
Requires opencv-contrib-python. No model downloads.
Common issues & troubleshooting
- Integer input throws.
srcmust beCV_32F/CV_64F; cast before connecting. - Wrong matrix size (
3x3vs4x4) is the usual assertion-failure culprit. - "My image didn't change" - you're using the wrong node; that's
warpPerspective's job. - Batch rule:
batch_size==1only - useImageFromBatchifImage2Nparraycomplains.
Same node as _0. Grab either number, just remember it's for points.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | — | |
| m | NPARRAY | — | |
| dstopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |