Combine multiple output into single output

4 次查看(过去 30 天)
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 个评论
Muhamad Luqman Mohd Nasir
when i search on matlab it stated that These errors usually indicate that MATLAB cannot find a particular variable or MATLAB program file in the current directory or on the search path.
but the file is in the same directory
Muhamad Luqman Mohd Nasir
This is my GUI script
% --- Executes on button press in Digit_recognition.
function Digit_recognition_Callback(hObject, eventdata, handles)
% hObject handle to Digit_recognition (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
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(k) = classify(net,I);
label(k)=cellstr(classify(net,I));
title([' Recognized Digit is ' char(label(k))])
end
Perimeter = fprintf( 'student id: %s\n',label);
handles.text1.String = Perimeter;

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2021-6-21
but the file is in the same directory
Are you indicating that you have a file net.m in the same directory, which is a function that will return a Network suitable for use by classify() ?
but work fine on my matlab script
You loaded (or assigned to) a variable named net in your base workspace. The base workspace is not automatically searched when a function is invoked.
You can force the base workspace to be looked in... but when you shut down for the evening and come back tomorrow, the base workspace will have been cleared and you will be out of sorts.
You should be loading the net from a .mat file at the time that the GUI starts, and making it available within your GUI; see http://matlab.wikia.com/wiki/FAQ#How_can_I_share_data_between_callback_functions_in_my_GUI.28s.29.3F
  5 个评论
Muhamad Luqman Mohd Nasir
And now how can i output the iteration into static text in gui like this
student id: 164335
it seem that when i use this script to output my result in static text it shows the value 108 and not 164335 can i know why, because at my command promt it shows
Now reading D:\CNN test\segmentedImages1\image2.png
Now reading D:\CNN test\segmentedImages1\image3.png
Now reading D:\CNN test\segmentedImages1\image4.png
Now reading D:\CNN test\segmentedImages1\image5.png
Now reading D:\CNN test\segmentedImages1\image6.png
Now reading D:\CNN test\segmentedImages1\image7.png
student id: <undefined>
student id: 8
student id: 6
student id: 4
student id: 3
student id: 3
student id: 5
Walter Roberson
Walter Roberson 2021-6-22
Perimeter = fprintf( 'student id: %s\n',label);
The output of fprintf is the number of items transfered, not the content of the string. Use sprintf() to get the content.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Pattern Recognition and Classification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by