Reputation: 2567
Is there a meanshift clustering implementation in OpenCV? If so, is there any documentation about how I can do it?
Upvotes: 2
Views: 13303
Reputation: 1911
There is a pyramid mean shift filtering that can be used as a building block for creating your own mean shift segmentation or a GPU based mean shift segmentation.
Upvotes: 3
Reputation: 2449
As you may know, this is not the place to ask this kind of questions (here you should come with programming problems...).
Regarding your question, OpenCv only has meanshift for tracking. For example, here you can find a tutorial for Python. The basic idea of using meanshift is the following:
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)#Convert the image to HSV colorspace
dst = cv2.calcBackProject([hsv],[0],roi_hist,[0,180],1) #Use gthe Hue to backproject the color histogram
ret, track_window = cv2.meanShift(dst, track_window, term_crit) #Apply meanshit to get the new location of the element
the result track_window
will contain the new position of the element. As simple as that. Hope it helps
Upvotes: 3