Extracting features with opencv for image classification
Hi everybody, I started to study computer vision and machine learning. I have a dataset of images and my goal is to extract the features with opencv3 (using different feature detection algorithms: Fast, GoodFeaturesToTrack, Mser, Star, Sift, Surf) and using the extracted matrix of features with an algorithm of machine learning for the images classification.
After a lot of search I've started with SIFT and SURF and I used the tecnique of bag of word for obtaining my final matrix. Now the problem comes with the other algorithms, because I've noted that, for example FAST, provide only a keypoints extractor but not a descriptor, so seem that I've to use one of following descriptor:
- SIFT
- SURF
- BRIEF
- BRISK
- ORB
- FREAK
But I have a lot a doubts...I've read here that BRISK / FREAK / ORB are not for image classification problem and, since they are binary descriptors, I can't use it with the implementation of bow in opencv because the kmeans works only with non binary descriptor. If I use, for example, only the SIFT descriptor with keypoint extracted with other algorithm (Fast, Star etc) the program works but has sense?I've search and it not seems good strategy (I report belove some lines of my algorithrm)
bowTrain = cv2.BOWKMeansTrainer(10)
detector = cv2.MSER_create()
sift = cv2.xfeatures2d.SIFT_create()
kp = detector.detect(img,None)
kp,des = sift.compute(img,kp)
bowTrain.add(des)
Is correct or there are other tecniques that I can use? Thank you for help.
let's put it this way: BOW is using kmeans, thus you need float descriptors (like sift or surf) to make it work, irrespective of the keypoints used.
or you can transform the descriptors Mat:
This is in C++, I do not know how to do it in python :( But I have found this
Hi berak, thank you for answer. So I can use only SIFT or SURF descriptors but the combination (for example) FAST keypoints + SIFT descriptor does have any sense or is completely wrong?
Hi thdrksdfthmn thank you for answer, I've hear about the conversion to CV32F but i found for example here that is not a good tecnique because maybe it could be happen that there is a bad clustering.
imho, you can use any keypointdetector you want. do your own experiments, and see, what works best.
(but , most probably, sift descriptors work best with sift keypoints)
Hi berak, thank you for reply. But can I use this approach to understand which algorithm gives me the best classification for images? Suppose that I run 2 test with following combination SIFT kp +SIFT descriptor and FAST kp + SIFT descriptor. If the latter test show really bad result, how can I be sure that the the problem is due to FAST itself, and not due to an incompatibility between them?
@eruru I do not see the problem in converting to CV_32F and then back to CV_8U. Or could flann compute a small distance that in Hamming way is very long? Can you give some examples? :)