Edit: Here is the complete code for anyone with github.com problems
I am trying to complete a pattern recognition project using SIFT and BOW. So far I am trying to train and build a dictionary. I read images from 5 different classes, computed descriptors, and added them all to the python ([]) list side by side. Now I am trying to use the python version of the BOWMeansTrainer to cluster my descriptors with k = 5 (is this correct? For 5 classes?). I try to pass cluster () my descriptor vector, but I get an error
Traceback (most recent call last): File "C:\Python27\Project2\beginning.py", line 40, in <module> bow.cluster(des) TypeError: descriptors data type = 17 is not supported
I'm not quite sure what format the numpy array fits in, does anyone have any ideas?
sift = cv2.SIFT() descriptors = [] for path in training_paths: image = cv2.imread(path) print path gray = cv2.cvtColor(image, cv2.CV_LOAD_IMAGE_GRAYSCALE) kp, dsc= sift.detectAndCompute(gray, None) descriptors.append(dsc) des = np.array(descriptors) k=5 bow = cv2.BOWKMeansTrainer(k) bow.cluster(des)
As you can see, I continue to add sift descriptors, and then try to convert to a numpy array (the required format).
source share