Opencv kmeans predict equivalent I'm moving my project from Python's libraries to opencv, and I have one big problem.

In Python skylearn, I have kmeans object, which has two useful methods: fit_predict and fit, which both are nescessery for my project.

The problem is I can't find any equivalent in opencv.
There is only function cv::kmeans, which is not enough for me.

When I'm using Python skylearn the pseudo code of my program looks like:

kmeans.fit_predict(train_data) // it gaves me labels, and compute centers

kmeans.predict(test_sample) // it gaves me labels for test sample computed from centers which were computed above


Is there any equivalent or way to do the same in opencv?
The OpenCV kmeans function is equivalent to fit(). It returns the cluster centers, and you can use this to implement your own predict()function. For a new sample, calculate the distance to each of the cluster centers. The cluster with the lowest distance is the predicted class.