trainingSet = imageSet(imgFolder1, 'recursive');
% Using HOG Features
cellSize = [4 4];
hogFeatureSize = length(hog_4x4);
%% Train a Digit Classifier
trainingFeatures = [];
trainingLabels = [];
for digit = 1:numel(trainingSet)
numImages = trainingSet(digit).Count;
features = zeros(numImages, hogFeatureSize, 'single');
for i = 1:numImages
img = read(trainingSet(digit), i);
% Apply pre-processing steps
lvl = graythresh(img);
img = im2bw(img, lvl);
features{i}= extractHOGFeatures(img, 'CellSize', cellSize);
end
labels= repmat(trainingSet(digit).Description, numImages, 1);
trainingFeatures=[training features; features];
trainingLabels=[trainingLabels; labels];
end
Classifier=fitcecoc(trainingFeatures, training labels);
我正在尝试使用上面的代码训练svm分类器。
我在分类器行遇到错误,说
fitcecoc出错:obj = fit(temp,X,Y);
... X必须是数字矩阵
我不知道该怎么办。请帮忙