bug: bagOfFeatures Internal calculation of array dimension match error
Afficher commentaires plus anciens
ENV: matlab 2022b, win10
When I "bagOfFeatures" some of my own images, the following error occurs.
parkingLotRoot = "./parkingLotImages";
imds = imageDatastore(parkingLotRoot);
bofData = bagOfFeatures(imds,CustomExtractor=@helperORBFeatureExtractorFunction,...
TreeProperties=[5,10]);
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 32-by-1. Error in vision.internal.kmeans.DistanceMetricHamming/dist (line 30) d(:,1) = sum(this.LUT(bitvec+1), 2); Error in vision.internal.kmeans.ClusterCompactness/clusterCompactness (line 23) d = dist(this.Metric, features, centers(assignments,:)); Error in vision.internal.kmeans.clusterdata (line 134) prevCompactness = clusterCompactness(compactnessMetric, features, centers, assignments); Error in vision.internal.bof.VocabularyBuilderKMedians/create (line 42) clusterCenters = vision.internal.kmeans.clusterdata(... Error in vision.internal.bof.VocabularyBuilderHierarchicalClustering/invokeVocabularyBuilder (line 121) words = create(this.VocabularyBuilder, features, branchingFactor); Error in vision.internal.bof.VocabularyBuilderHierarchicalClustering/buildVocabularyTree (line 105) vt.Words = invokeVocabularyBuilder(this, features, printer); Error in vision.internal.bof.VocabularyBuilderHierarchicalClustering/buildVocabularyTree (line 98) [vt.Nodes(i), step] = buildVocabularyTree(this, fgroup, level-1, i, step, printer); Error in vision.internal.bof.VocabularyBuilderHierarchicalClustering/buildVocabularyTree (line 98) [vt.Nodes(i), step] = buildVocabularyTree(this, fgroup, level-1, i, step, printer); Error in vision.internal.bof.VocabularyBuilderHierarchicalClustering/buildVocabularyTree (line 98) [vt.Nodes(i), step] = buildVocabularyTree(this, fgroup, level-1, i, step, printer); Error in vision.internal.bof.VocabularyBuilderHierarchicalClustering/buildVocabularyTree (line 98) [vt.Nodes(i), step] = buildVocabularyTree(this, fgroup, level-1, i, step, printer); Error in vision.internal.bof.VocabularyBuilderHierarchicalClustering/create (line 56) vt = buildVocabularyTree(this, features, this.NumLevels,[], step, printer); Error in bagOfFeatures/createVocabulary (line 793) vocabulary = this.VocabularyBuilder.create(descriptors); Error in bagOfFeatures (line 301) vocabulary = createVocabulary(this, descriptorSet); Error in testDebug (line 11) bofData = bagOfFeatures(imds,CustomExtractor=@helperORBFeatureExtractorFunction,...
how can i solve it ,your answer would be greatly appreciate! To reproduce the bug, since matlab answer attachments cannot be uploaded to files larger than 5Mb, I am posting them here.
support function is here:
function [features, featureMetrics]= helperORBFeatureExtractorFunction(I)
% helperORBFeatureExtractorFunction Implements the ORB feature extraction
% used in bagOfFeatures.
%
% This is an example helper function that is subject to change or removal
% in future releases.
% Copyright 2021 The MathWorks, Inc.
numPoints = 1000;
% Detect ORB features
Igray = im2gray(I);
points = detectORBFeatures(Igray, 'ScaleFactor', 1.2, 'NumLevels', 8);
% Select a subset of features, uniformly distributed throughout the image
points = selectUniform(points, numPoints, size(Igray, 1:2));
% Extract features
features = extractFeatures(Igray, points);
% Compute the Feature Metric. Use the variance of features as the metric
featureMetrics = var(single(features.Features),[],2);
end
2 commentaires
Qu Cao
le 28 Nov 2022
Thank you for reporting this! We will fix the bug in a future update. Meanwhile, do you mind trying the following workaround?
bofData = bagOfFeatures(imds,CustomExtractor=@helperORBFeatureExtractorFunction,...
TreeProperties=[4,10]);
It looks to me that a smaller value will make it work.
xingxingcui
le 28 Nov 2022
Réponses (0)
Catégories
En savoir plus sur Image Category Classification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!