Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

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

$
0
0
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) gray=cv2.cvtColor(ima,cv2.COLOR_BGR2GRAY) kpts, des = sift.detectAndCompute(gray, None) kp_train.append(kpts) dsc_train.append(des) ## Train knn dsc_train = np.array(dsc_train) responses = np.arange(len(kp_train),dtype = np.float32) knn = cv2.ml.KNearest_create() knn.train(dsc_train, cv2.ml.ROW_SAMPLE, responses) But I'm a little stuck with the next error: >>> knn.train(dsc_train,cv2.ml.ROW_SAMPLE,responses) Traceback (most recent call last): File "", line 1, in 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

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>