Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 41027

Hi, I am trying to use bowtrainer for image classification(opencv 2.4.6 + VS2010). I am getting an error.

$
0
0
"OpenCV Error: Assertion failed (N >=k) in unknown function, file ..\..\..\src\opencv\modules\core\src\matrix.cpp, line 2717" Here is the code: cv::initModule_nonfree(); Ptr matcher = DescriptorMatcher::create("FlannBased"); Ptr extractor = new SurfDescriptorExtractor(); SurfFeatureDetector detector(500); TermCriteria tc(CV_TERMCRIT_ITER, 10, 0.001); int dictionarySize = 1500; int retries = 1; int flags = KMEANS_PP_CENTERS; BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags); BOWImgDescriptorExtractor bowDE(extractor, matcher); Mat im1 = imread("image1.jpg", CV_LOAD_IMAGE_GRAYSCALE); Mat im2 = imread("image2.jpg", CV_LOAD_IMAGE_GRAYSCALE); Mat descriptor1,descriptor2; vector keypoints1,keypoints2; detector.detect(im1, keypoints1); detector.compute(im1, keypoints1,descriptor1); detector.detect(im2, keypoints2); extractor->compute(im2, keypoints2,descriptor2); bowTrainer.add(descriptor1); bowTrainer.add(descriptor2); Mat dictionary = bowTrainer.cluster(); bowDE.setVocabulary(dictionary);

Viewing all articles
Browse latest Browse all 41027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>