c++ - Hierarchical k-Means in OpenCV without knowledge of "k" -


I'm trying to cluster the set of 4D vectors without having to know in advance how many groups should be in advance. In the past, I have been able to use cvkmeans2 for the cluster, given the knowledge of the number of clusters. I was trawling through the API and came across. It seems like what I want (i.e., k-means, split clusters where necessary, as a result of the division, it's deteriorating, repeating), but I'm actually struggling with the "index parameter".

I thought I needed to make one which goes as a second parameter, but I get an error from the following code:

cv :: flann :: index fln_idx = cv :: Flan :: Cemans IndieParams :: Createindex (framepoint);

Error getting:

../ src / Segmentation_1.cpp: 592: Error: Can not call member function? Virtual Flow :: Index * cv :: flann :: Cmens IndexParams :: Createindex (Const CV :: Matte & amp;)

cvmat * framePoints = cvCreateMat (frameTracklets.size ()), 4, without any object

framepoint is defined: CV_32FC1);

I'm pretty sure I'm stupid (my C ++ knowledge is fine, but not good). I think I have posted all the relevant bits of the code but if not, then let me know and I will post more.

Thanks in advance!

UPDATE

I have followed the advice of LumpN and have created a CAMEENS object using the following:

  Cv :: Mat center; Cv :: flann :: Cmens IndexParms fln_idx = cv :: flann :: Cmens IndexParam (); Fln_idx.createIndex (Frame Points); Int numClust; NumClust = Hierarchical clustering (frame points, center, fln_idx);   

Now when I run it I get an error message from hierarchicalclustering () such as "the number of desired groups should be = 1 "(I should work when I work - I will update with the actual error). I have assumed that createIndex () gave it the starting point, then a good result was found to hierarchicalclustering () divided groups (not sure whether it is optimal or not ). Do I have to call cv :: flann :: KMeansIndexParams () with some code? I have seen the API and are completely confused! Thanks again!

You must pass the reference to createIndex , that is, createindex ( * Frame Points) (Asterix note!). Another error may be createIndex in a non-static (member) function, in which case you have to create the CAMENS INDEXPARMS object and call createIndex .

Comments