cv.jit.centroids problem

Ricardo's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I'm trying to get the coordinates from cv.jit.centroids, but I'm having some problems.
When I try to get at the coordinates from blob one it is working ok, but when I try to add another blob, then the coordinates are adjusting on blob one and two. What have I done wrong? How do you get to each blob coordinate separately?

Jean-Marc Pelletier's icon

You're not doing anything wrong, though it's probably easier to use jit.iter instead of jit.spill. The order of the blobs is not guaranteed. Depending on the parameters of cv.jit.label, they will either be ordered from top-left to bottom-right position, or size.

If you need to have consistent positions, consider using cv.jit.touches instead.

Jean-Marc

Ricardo's icon

Ah yes, I kind of suspected that. I'll try the jit.touches.
Thanks for your answer and the objects :) Great work!