CV Quad Warp
Applies the homography defined by 4 annotated corner points. 'extract' rectifies the quad into a rectangle with the TRUE aspect ratio recovered from the perspective (a manual document scan; Zhang's whiteboard method with the principal point at the image center); 'fill' warps THIS image into the quad on a canvas (poster / billboard / screen replacement). The 4 points may arrive in any order - 'CV Annotate Points' click order, detections, ... - they are sorted TL/TR/BR/BL automatically. The matrix output is the 3x3 homography actually used, ready for 'CV Homography Map' to combine with other remap distortions. Failure-tolerant: anything other than exactly 4 points passes the image through with success=false and an identity matrix - branch on success with an if/else node.
- image
- points
- canvas
- warped
- matrix
- success
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| image | COMFY_MATCHTYPE_V3 | extract: the photo containing the quad; fill: the image to warp INTO the quad. The warped output comes back in this input's format. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. | |
| points | NPARRAY | 4 corner points (Nx1x2 or Nx2), any order. | |
| mode | COMBO | extract: rectify the quad to a rectangle | extract: straighten the quad into a rectangle (document scan). fill: warp this image into the quad on a canvas (poster/screen replacement). |
| max_size | INT | 819264–32768 | extract only: cap on the output width/height. |
| canvasopt | NPARRAY,IMAGE | fill only: the background the warped image is composited onto (the points live in ITS coordinates). Black canvas around the quad when left unconnected. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| warped | COMFY_MATCHTYPE_V3 | Same format as the image input. |
| matrix | NPARRAY | 3x3 homography used (identity when success=false). |
| success | BOOLEAN | — |