Nodes/comfyui_cv/CV Find Quadrilateral
ComfyUI Node

CV Find Quadrilateral

Finds the largest convex quadrilateral among the contours - the classic document/whiteboard outline detector. Each contour (largest first) is simplified with cv2.approxPolyDP; the first one that simplifies to 4 convex corners and covers at least min_area_fraction of the image wins. When that strict pass finds nothing, a second pass simplifies each contour's CONVEX HULL instead, raising the tolerance until 4 corners remain - recovering pages with curled corners, shadow notches or texture-broken edges. The corners come out ordered top-left, top-right, bottom-right, bottom-left, ready for 'CV Quad To Rectangle' + cv2.getPerspectiveTransform. Failure-tolerant: when no quad qualifies it returns found=false and the full image corners (warping with them is a no-op), so the workflow keeps running - branch on 'found' with an if/else node.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Find Quadrilateral
  • image
  • contours
  • corners
  • found
  • area_fraction
epsilon_ratio0.020
min_area_fraction0.05
Categoryimage/CV/contours

Inputs (4)

NameTypeDefaultDescription
imageNPARRAY,IMAGE,MASKThe photographed image - used for the area reference and the not-found fallback corners. 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.
contoursCV_CONTOURSFrom 'CV Find Contours'.
epsilon_ratioFLOAT0.0200.001–0.5approxPolyDP tolerance as a fraction of the contour perimeter. Higher merges wobbly edges into straight lines more aggressively.
min_area_fractionFLOAT0.050–1Smallest acceptable quad area as a fraction of the image area - rejects small rectangles that are not the document.

Outputs (3)

NameTypeDescription
cornersNPARRAY4x1x2 float32, ordered TL/TR/BR/BL (full image corners if not found).
foundBOOLEAN
area_fractionFLOATArea of the detected quad relative to the image (0.0 if not found).