I am doing feature extraction using surf and bow , but after i add descriptors in loop
for (i = all_names.begin(); i != all_names.end(); ++i)
{
Dir=( (count < files.size() ) ? ImagesDirectory : ImagesDirectory_2);
Mat row_img = cv::imread( Dir +*i, 0 );
detector.detect( img, keypoints);
CollectBestKeypoints(keypoints, 10); // getting 10 best keypoints
extractor->compute( img, keypoints, descriptors);
bow.add(descriptors);
++count;
}
than after loop this is my code and i am getting runtime error here :
Mat vocabulary = bowTrainer.cluster();
dextract.setVocabulary(vocabulary);
here is initialization :
int dictionarySize = 1500;
TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001);
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor dextract(extractor,matcher);
Ptr<DescriptorExtractor> extractor = new SurfDescriptorExtractor();
Error :
Assertion failed (N>=K) in unknown function , file ..\..\..\src\opencv\modules\core\src\\matrix.cpp , line 2687