필터 지우기
필터 지우기

Combine multiple output into single output

조회 수: 2 (최근 30일)
Muhamad Luqman Mohd Nasir
Muhamad Luqman Mohd Nasir 2021년 6월 20일
댓글: Walter Roberson 2021년 6월 22일
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
Muhamad Luqman Mohd Nasir 2021년 6월 21일
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
Muhamad Luqman Mohd Nasir 2021년 6월 21일
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
Muhamad Luqman Mohd Nasir 2021년 6월 21일
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에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by