NormalBayesCLassifier::predict error
I have trained a NormalBayesClassifier and saved it as yaml. The FeatureDetector used was PyramidGFTT, the DescriptorExtractor used was BRISK and the matcher was BruteForce. I have used a BOWImgDescriptorExtractor based on the mentioned types of DescriptorsExtractor and matcher. I have also used a BOWKMeansTrainer(750, cv::TermCriteria(CV_TERMCRIT_ITER, 10, 0.001), 3, KMEANS_PP_CENTERS) for training. I save the classifier trained.
Then I load it and use the same detector, extractor and matcher, it works fine, but when I do classifier->predict(descriptors, &result); It crashes saying:
OpenCV Error: Bad argument (The input samples must be 32f matrix with the number of columns = var_all) in predict, file /home/me/opencv/modules/ml/src/nbayes.cpp, line 384
terminate called after throwing an instance of 'cv::Exception'
what(): /home/me/opencv/modules/ml/src/nbayes.cpp:384: error: (-5) The input samples must be 32f matrix with the number of columns = var_all in function predict
In fact I use Ptr< NormalBayesCLassifier >, that is why I use -> instead of .. If I do not use Ptr, it gives me the same error. I have tried to convert the descriptors to CV_32FC1, but the same error is thrown.
How to predict what class an image is using NormalBayesClassifier loaded from a file (yaml)?
hmm, if you're using BOW, you will have to use the result from the bow.compute() function for the descriptor
no... I think I need a vocabulary, that I have not saved...