Nodes/comfyui_cv/CV Downsample Point Cloud
ComfyUI Node

CV Downsample Point Cloud

Thins a point cloud onto a GRID whose cell size is a fraction of the bounding-box diagonal (cv2.ppf_match_3d.samplePCByQuantization): one averaged representative survives per occupied cell. That sets the cloud's DENSITY, not a hard minimum distance - two points either side of a cell boundary can still end up close. Spacing-based, not stride-based - which is the point, because a cloud from 'CV Depth to 3D Points' arrives in raster order and every Nth point would sample the IMAGE evenly and the SURFACE unevenly. Put this in front of 'CV PPF Pose Estimation' and 'CV Point Cloud Normals': PPF training is quadratic in the sampled count, so a 38k-point depth cloud is minutes of work and its 1.4k-point downsample is seconds, with the same pose. Nx6 clouds keep their normal columns. Failure tolerant: an empty cloud returns empty with found=false.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Downsample Point Cloud
  • points
  • points
  • count
  • found
relative_sampling_step0.050
weightinguniform
Categoryimage/CV/points

Inputs (3)

NameTypeDefaultDescription
pointsNPARRAYNx3, or Nx6 (x,y,z,nx,ny,nz). The kept point is the AVERAGE of its cell, normals included (re-normalized here, since cv2 does not) - so a cell that spans two opposing surfaces, the two faces of a thin wall or a sign-arbitrary plane fit, averages to nothing and that row comes back with a ZERO normal. Downsample FIRST and compute normals after when the cloud is thin or noisy; normals-first is fine (and cheaper) for a mesh, where they are exact.
relative_sampling_stepFLOAT0.0500.005–0.5Grid cell size, as a fraction of the bounding-box diagonal: 0.05 leaves points ~5% of the diagonal apart on average. Match it to the relative_sampling_step of 'CV PPF Pose Estimation' - that node quantizes internally at the same scale, so a finer cloud than its own step buys nothing and costs the plane fits.
weightingoptCOMBOuniformHow the representative of a cell is chosen. 'uniform' averages the cell's points; the weighted form pulls it toward the points furthest from the cloud's origin, which biases the sample toward the silhouette. Leave it uniform unless you are deliberately sampling a rim.

Outputs (3)

NameTypeDescription
pointsNPARRAYThe thinned cloud, float32, with the same number of columns as the input.
countINTPoints that survived. Watch it against the input size - this is the number PPF's cost is quadratic in.
foundBOOLEANFalse when the cloud was empty or cv2 refused it.