I use CVKnearest Class in opencv to classify 6 classes with 10 functions as follows:
CvKNearest knn(trainData, trainClasses, Mat(), false, K );
then i use:
response = knn.find_nearest(testData,K,Results,nearests,dists);
but the results are always equal to 1, even if I give the functions of a training sample, which should give me the distance to zero and be selected as a class!
when I print Mat results like this:
FileStorage f; f.open("result.xml", FileStorage::WRITE); f << "t" << Results; f.release();
He gives me a floating number,
so my question is what am i doing wrong? or how do I get the desired class labels ?!
source share