Combine multiple output into single output
Ältere Kommentare anzeigen
I am working on a student id recognition using CNN and i manage to recognize every single digit but how can i combine every digit into one single output.
i want the output to be
student id number: 164335
below is my code
%% feed image
myFolder = 'D:\CNN test\segmentedImages1';
% Get a list of all files in the folder with the desired file name pattern.
filePattern = fullfile(myFolder, '*.png');
theFiles = dir(filePattern);
for k = 2 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
I = imread(fullFileName);
subplot(3, 4, k);
imshow(I); % Display image.
drawnow; % Force display to update immediately.
label = classify(net,I);
title([' Recognized Digit is ' char(label)])
end
%% Displaying Detected Text
fprintf('%s\n',label)
but my code right now only printing 5
9 Kommentare
dpb
am 20 Jun. 2021
label = classify(net,I);
overwrites the variable label each time through the loop; you need to allocate space for each to be recognized/stored and index into that array.
filePattern = fullfile(myFolder, '*.png');
theFiles = dir(filePattern);
label=cellstr(numel(theFiles)); % allocate for the number expected
for k = 2 : length(theFiles)
...
label(k)=cellstr(classify(net,I)); % save each as a cellstr()
end
One Q? -- why the loop over k beginning with 2 instead of 1? This will miss the first file in the folder with the desired "*.png" file extension -- is that intended or an oversight? Files are returned in a sorted order by dir(), but it isn't documented that this is guaranteed behavior.
Sulaymon Eshkabilov
am 20 Jun. 2021
In this case, this approach of file name reading could be better:
filePattern = fullfile(myFolder, '*.png');
theFiles = dir(filePattern);
Fnames = {theFiles.name};
for k = 2 : length(Fnames)
...
label(k)=...
end
Muhamad Luqman Mohd Nasir
am 21 Jun. 2021
Muhamad Luqman Mohd Nasir
am 21 Jun. 2021
Muhamad Luqman Mohd Nasir
am 21 Jun. 2021
Walter Roberson
am 21 Jun. 2021
Files are returned in a sorted order by dir(),
For some definition of sorted.. the sort order can depend upon the language settings of the person who created the file system!
Muhamad Luqman Mohd Nasir
am 21 Jun. 2021
Muhamad Luqman Mohd Nasir
am 21 Jun. 2021
Muhamad Luqman Mohd Nasir
am 21 Jun. 2021
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Language Support finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!