ComfyUI Node
CV Sample Array At Points
Reads the values of an HxW (xC) array at a set of 2D point coordinates - the generic 'look up this map where the features are' step. Feed the XYZ map of cv2.reprojectImageTo3D and the matched points of 'OpenCV Match Features' to get the 3D positions of the matches (then cv2.estimateAffine3D registers two clouds); it equally samples a depth map, an optical-flow field, a confidence map or a colour image at keypoints. Coordinates are in pixels (x, y), sub-pixel allowed. Points outside the array are clamped to the edge and flagged in 'valid' (0), so an out-of-frame keypoint never raises - filter with 'CV Filter Points 3D By Mask' / 'CV Filter Points By Mask'.
CV Sample Array At Points
- nparray
- points
- valid_in
- values
- valid
- count
◄interpolationnearest►
◄validityin bounds and finite►
Categoryimage/CV/points
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| nparray | NPARRAY | HxW or HxWxC array to sample (XYZ map, depth, flow, confidence, colour image...). Any dtype. | |
| points | NPARRAY | Sample positions in pixels, Nx2 or Nx1x2 (x, y) - e.g. 'CV Match Features' points_a/points_b. None/empty gives an empty result, not an error. | |
| interpolation | COMBO | nearest | nearest: exact pixel value, never invents data - the right choice for XYZ / label / disparity maps whose neighbours may be invalid. bilinear: sub-pixel weighted average, smoother but mixes in neighbours (good for smooth fields, bad across depth edges). |
| validityopt | COMBO | in bounds and finite | What 'valid' means. 'in bounds and finite' also clears the flag where the sampled value is NaN or Inf (cv2.reprojectImageTo3D marks missing disparity that way); 'in bounds only' flags every sample that landed inside the array, whatever its value. |
| valid_inopt | NPARRAY | Optional mask from an earlier sampler (one entry per point): its zeros are carried into this node's 'valid' output. Chain samplers through it to AND several validity tests together - it stays correct for an empty point set, which cv2.bitwise_and does not (cv2 returns None for empty input). |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| values | NPARRAY | NxC array of sampled values (C = 1 for a 2D input); same dtype as the input for 'nearest', float for 'bilinear'. |
| valid | NPARRAY | Nx1 uint8 mask, 255 where the point was inside the array (and finite, if require_finite). |
| count | INT | Number of valid samples. |