Combine multiple output into single output
古いコメントを表示
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 件のコメント
dpb
2021 年 6 月 20 日
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
2021 年 6 月 20 日
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
2021 年 6 月 21 日
Muhamad Luqman Mohd Nasir
2021 年 6 月 21 日
Muhamad Luqman Mohd Nasir
2021 年 6 月 21 日
Walter Roberson
2021 年 6 月 21 日
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
2021 年 6 月 21 日
Muhamad Luqman Mohd Nasir
2021 年 6 月 21 日
Muhamad Luqman Mohd Nasir
2021 年 6 月 21 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Language Support についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!