MATLAB Answers

Error using vision.int​ernal.Kdtr​ee/index Invalid input class.

10 views (last 30 days)
Pradip Gupta
Pradip Gupta on 16 Mar 2017
Commented: Raju Pal on 23 Nov 2019
Error using bagOfFeatures. It was earlier working fine but suddenly it stopped. I am using custom extractor function.
extractorFcn= @calcFeatures;
bag = bagOfFeatures(trainingSet,'CustomExtractor',extractorFcn,'VocabularySize',500);
% function [T, TMetric] = calcFeatures(pic) Custom Extractor looks like this
The Error I get is:
Clustering...completed 0/100 iterations Error using vision.internal.Kdtree/index
Invalid input class.
Error in vision.internal.approximateKMeans>assignDataToClustersSerial (line 172)
searcher.index(centers);
Error in vision.internal.approximateKMeans>assignDataToClusters (line 153)
[assignments, dists, varargout{1:nargout-2}] = assignDataToClustersSerial(features, centers, randState);
Error in vision.internal.approximateKMeans (line 73)
[assignments, dists, isValid] = assignDataToClusters(features, centers, params);
Error in bagOfFeatures/createVocabulary (line 640)
clusterCenters = vision.internal.approximateKMeans(descriptors, K, ...
Error in bagOfFeatures (line 197)
this.Vocabulary = this.createVocabulary(descriptorSet, ...
  11 Comments
Raju Pal
Raju Pal on 23 Nov 2019
I have faced the problem in knn search when using alexnet features
* Clustering...completed 0/100 iterations Error using vision.internal.Kdtree/index
Invalid input class.
Error in vision.internal.approximateKMeans>assignDataToClustersSerial (line 172)
searcher.index(centers);
Error in vision.internal.approximateKMeans>assignDataToClusters (line 153)
[assignments, dists, varargout{1:nargout-2}] = assignDataToClustersSerial(features, centers, randState);
Error in vision.internal.approximateKMeans (line 73)
[assignments, dists, isValid] = assignDataToClusters(features, centers, params);

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 23 Oct 2018
Digging into this: that error is being triggered by the fact that the features array that vision.internal.approximateKMeans is being asked to work on is a single column; it is expecting a minimum of two columns.
I am still tracing through to figure out what the one column is at that point, and why it is not multiple columns.
  2 Comments
Suvidha Tripathi
Suvidha Tripathi on 23 Oct 2018
Yes, You are right. I ran the example code by MATLAB, and figured out the error yesterday. I corrected it by reshaping my array like this
features=reshape(trainFeatures,[size(trainFeatures,1)*size(trainFeatures,2) ,size(trainFeatures,3),size(trainFeatures,4)]);
This worked for me. Thank you for your time.

Sign in to comment.


Dr. Murtaza Khan
Dr. Murtaza Khan on 23 Jan 2019
I got the same error when my features matrix was of size M-by-1 in the custom feature extractor function. I changed it to size 1-by-M then the error did not appear.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!