Nodes/comfyui_cv/CV Quad Warp
ComfyUI Node

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.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Quad Warp
  • image
  • points
  • canvas
  • warped
  • matrix
  • success
modeextract: rectify the quad to a rectangle
max_size8192
Categoryimage/CV/contours

Inputs (5)

NameTypeDefaultDescription
imageCOMFY_MATCHTYPE_V3extract: 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.
pointsNPARRAY4 corner points (Nx1x2 or Nx2), any order.
modeCOMBOextract: rectify the quad to a rectangleextract: straighten the quad into a rectangle (document scan). fill: warp this image into the quad on a canvas (poster/screen replacement).
max_sizeINT819264–32768extract only: cap on the output width/height.
canvasoptNPARRAY,IMAGEfill 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)

NameTypeDescription
warpedCOMFY_MATCHTYPE_V3Same format as the image input.
matrixNPARRAY3x3 homography used (identity when success=false).
successBOOLEAN