Is there a meanshift clustering implementation in OpenCV? If so, is there any documentation about how I can do it?
Asked
Active
Viewed 1.3k times
2 Answers
3
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

phyrox
- 2,423
- 15
- 23
-
2i think this doesn't do clustering but tracking – deniz Jan 10 '15 at 11:24
3
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.

Rosa Gronchi
- 1,828
- 15
- 25
-
Function pyrMeanShiftFiltering() uses openCL now at least for pyramid building and dilation, so it is also GPU-based hence no need to use proprietary CUDA solutions. – Vit Jan 11 '15 at 22:53