cv.KMeans2 clustering indices inconsistent
Since k-means is a randomized approach, you will probably encounter this problem even when analyzing the same frame multiple times.
Try to use the previous frames cluster centers as initial centers for k-means. This may make the ordering stable enough for you, and it may even significantly speed up k-means (assuming that the green spots don't move too fast).
Alternatively, just try reordering the means so that they are closest to the previous images means.
So I have a video with 3 green spots on it. These spots have a bunch of "good features to track" around their perimeter.
The spots are very far away from each other so using KMeans I am easily able to identify them as separate clusters.
The problem comes in that the ordering of the clusters changes from frame to frame. In one frame a particular cluster is the first in the output list. In the next cluster it is the second in the output list.
It is making for a difficult time measuring angles.
Has anyone come across this or can think of a fix other than writing extra code to compare each list to the list of the previous frame?