I have 200 images and 200 classes and I try to use opencv cv :: ml :: Boost
cv :: ml :: KNearest
. But the results are not accurate.
so ,which machine learning should I use?
Create vocabulary:
cv::BOWKMeansTrainer bowtrainer(10);
bowtrainer.add(trainingDescriptors);
vocabulary = bowtrainer.cluster();
Recoginze:
cv::BOWImgDescriptorExtractor bowide(extractor, matcher);
bowide.setVocabulary(vocabulary);
std::vector<cv::KeyPoint> keypoints;
detector->detect(trainingMat, keypoints);
if (keypoints.empty()) {
return -1;
}
cv::Mat imgDescriptor;
bowide.compute(trainingMat, keypoints, imgDescriptor);
if (imgDescriptor.empty()) {
return -1;
}
Mat testResponse;
kclassifier->predict(imgDescriptor, testResponse, 0);
Some Images:
train Image : https://drive.google.com/file/d/1n2ehRyOUXsNQUqZpMAVIJ21rFZkrVY6K/view?usp=sharing
test Image : https://drive.google.com/file/d/1Txxoht5EctGYJel9WAOK4jwls-UGNXnC/view?usp=sharing