Question
What code can I use if I want to add a condition wherein if I show a picture that is not registered in the database folder it will display 'Unrecognized Face"? ???? In the code shown below, when I show my face in the webcam, it will display my name since my face is already registered in the database. I tried to show another picture that is not registered in the database, but the result still display the name that is registered in the database like my name. My only concern is how can I display "Unrecognized Face" if I show a picture that is not registered in the database? Thank you ???? clc; close; clear c=webcam; load myNet1; faceDetector = vision.CascadeObjectDetector; while true e = c.snapshot; bboxes = step(faceDetector,e); if(sum(sum(bboxes))~=0) es=imcrop(e,bboxes(1,:)); es=imresize(es,[227 227]); label=classify(myNet1,es); image(e); title(char(label)); drawnow; else image(e); title('No Face Detected'); end end
Expert Answer
Prashant Kumar
PhD Expert
Answered Aug 24, 2026
You need a function that checks the current snapshot against your database. That function can return true, false, or even the name of the person it thinks it is (or null if it doesn't recognize it). For example
rgbImage = c.snapshot;
personsName = YourDatabaseCheckingFunction(rgbImage);
if isempty(personsName)
% Did not recognize anyone that was in the database.
title('This person is not recognized.', 'FontSize', 18)
% Pop up a message if you'd like...
message = sprintf('This person is not recognized.')
uiwait(helpdlg(message));
else
% Recognized the person, and we have a name that has been
% returned from our database checking function.
message = sprintf('I believe this person to be %s', personsName);
title(message, 'FontSize', 18);
uiwait(helpdlg(message));
end
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related deep learning Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →