Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Python. K-nearest neighbour TypeError: samples data type = 17 is not supported

I'm trying to classify some images using SIFT for detect and compute keypoints and descriptors, and then use KNN for classify them into python interpreter:

## Detect keypoints and compute descriptors for train images
for file in files:
    ima = cv2.imread(file)
    kpts, des = sift.detectAndCompute(gray, None) 

## Train knn
dsc_train = np.array(dsc_train)
responses = np.arange(len(kp_train),dtype = np.float32)
knn =
knn.train(dsc_train,, responses)

But I'm a little stuck with the next error:

>>> knn.train(dsc_train,,responses)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: dsc_train data type = 17 is not supported

I really don't know how can fix this. Any help would be great. files is a list with 10 images, so the loop detects and computes keypoints and descriptor for each image. Thanks