cuda::connectedComponents random label numbers?

I’m suprised I would have expected it to be the lowest indexed pixel in the blob.

If you need a structure similar to the CPU version I would use NPP, otherwise you have to write your own routine to compress the labels and extract the blob info. See NPP CompressedMarkerLabelsUFInfo for details.

Notes regarding NPP:

  1. You need to use CUDA 12.3 as there was a bug in the NPP routine which returned the info in earlier versions.
  2. The NPP version doesn’t label the background (0 intensity pixels) as 0 which is the expected behaviour in OpenCV.