Borrar filtros
Borrar filtros

Combine multiple output into single output

2 visualizaciones (últimos 30 días)
Muhamad Luqman Mohd Nasir
Muhamad Luqman Mohd Nasir el 20 de Jun. de 2021
Comentada: Walter Roberson el 22 de Jun. de 2021
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 comentarios
Muhamad Luqman Mohd Nasir
Muhamad Luqman Mohd Nasir el 21 de Jun. de 2021
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 el 21 de Jun. de 2021
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;

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Jun. de 2021
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 comentarios
Muhamad Luqman Mohd Nasir
Muhamad Luqman Mohd Nasir el 21 de Jun. de 2021
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 el 22 de Jun. de 2021
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by