Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4123280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T23:35:29+00:00 2026-05-20T23:35:29+00:00

I’m trying to cluster a set of 4D vectors, without knowing how many clusters

  • 0

I’m trying to cluster a set of 4D vectors, without knowing how many clusters there should be in advance. In the past, I’ve been able to use cvKmeans2 to cluster, given knowledge of the number of clusters. I was trawling through the API and came across cv::flann::hierarchicalClustering. This looks like it will do what I need (namely, perform k-means, split clusters where necessary, iterate until splitting worsens the result), but I’m really struggling with the “index parameters”.

I’ve figured out I need to create an index structure which goes in as the second parameter, but I’m getting an error from the following code:

cv::flann::Index fln_idx = cv::flann::KMeansIndexParams::createIndex( framePoints );

The error being:

../src/segmentation_1.cpp:592: error: cannot call member function ‘virtual flann::Index* cv::flann::KMeansIndexParams::createIndex(const cv::Mat&) const’ without object

framePoints is defined as below:

CvMat *framePoints = cvCreateMat( frameTracklets.size( ), 4, CV_32FC1 );

I’m fairly sure I’m doing something pretty stupid (my C++ knowledge is ok, but not great). I think I’ve posted all the relevant bits of code but if not, let me know and I’ll post more.

Thanks in advance!

UPDATE

I’ve followed LumpN’s advice and created a Kmeans object, using the following:

cv::Mat centres;
cv::flann::KMeansIndexParams fln_idx = cv::flann::KMeansIndexParams();
fln_idx.createIndex( framePoints );

int numClust;
numClust = hierarchicalClustering(framePoints, centres, fln_idx);

Now when I run it I get an error message from hierarchicalClustering() saying something like “the number of desired clusters should be >= 1” (I need to check when I get to work – I’ll update then with the actual error). I assumed that the createIndex() gave it starting point, then hierarchicalClustering() split clusters until a good result was found (not sure if this is optimal or not). Do I need to call cv::flann::KMeansIndexParams() with some arguments? I’ve looked at the api and am thoroughly confused!
Thanks again!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T23:35:29+00:00Added an answer on May 20, 2026 at 11:35 pm

    You have to pass a reference to createIndex, i.e. createIndex(*framePoints) (note the asterix!). Another error might be createIndex being a non-static (member) function. In that case you’d have to create a KMeansIndexParams object and call createIndex on that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.