I am having an error in running this code. Kindly help.

1 visualización (últimos 30 días)
Chidiebere Ike
Chidiebere Ike el 2 de Abr. de 2018
Comentada: Geoff Hayes el 2 de Abr. de 2018
Below is the error message received when I ran the classifier section of the code:
Error in SimpleFaceRecognition (line 39)
trainingFeatures(featureCount,:) = extractHOGFeatures(read(training(i),j));
Undefined function or variable 'trainingLabel'.
Error in SimpleFaceRecognition (line 47)
faceClassifier = fitcecoc(trainingFeatures,trainingLabel);
%%Load Image Information from ATT Face Database Directory
faceDatabase = imageSet('orl_faces','recursive');
%%Display Montage of First Face
title('Images of Single Face');
Display Query Image and Database Side-Side
personToQuery = 1;
galleryImage = read(faceDatabase(personToQuery),1);
for i=1:size(faceDatabase,2)
imageList(i) = faceDatabase(i).ImageLocation(5);
diff = zeros(1,9);
%%Split Database into Training & Test Sets
[training,test] = partition(faceDatabase,[0.8 0.2]);
%%Extract and display Histogram of Oriented Gradient Features for single face
person = 5;
[hogFeature, visualization]= ...
subplot(2,1,1);imshow(read(training(person),1));title('Input Face');
subplot(2,1,2);plot(visualization);title('HoG Feature');
%%Extract HOG Features for training set
trainingFeatures = zeros(size(training,2)*training(1).Count,4680);
featureCount = 1;
for i=1:size(training,2)
for j = 1:training(i).Count
trainingFeatures(featureCount,:) = extractHOGFeatures(read(training(i),j));
trainingLabel{featureCount} = training(i).Description;
featureCount = featureCount + 1;
personIndex{i} = training(i).Description;
%%Create 40 class classifier using fitcecoc
faceClassifier = fitcecoc(trainingFeatures,trainingLabel);
  3 comentarios
Geoff Hayes
Geoff Hayes el 2 de Abr. de 2018
Should trainingFeatures be a cell array? what are the dimensions of the object that you are assigning to this array? will the dimensions be the same for each iteration of the loop? From https://www.mathworks.com/matlabcentral/answers/93586-why-do-i-get-the-subscripted-assignment-dimension-mismatch-error-message,
This error occurs when you attempt to assign elements to an existing array, but the size of the variable you are trying to assign is not compatible with the existing array.

Iniciar sesión para comentar.

Respuestas (0)


Community Treasure Hunt

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

Start Hunting!

Translated by