- Is there a specific person's face you are trying to identify in a picture? Or are you looking for any face in general?
- What are the "test" and "recognized" images for?
- Is there a specific part of this workflow, or your code, that you are having trouble with?
'Face detection and recognition' I want to display test image and recognised image and if match not found i want display match not found message
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
DBPath='D:\Matlab_prblms\face_database';
D=dir(DBPath)
[mFiles t]=size(D)
mSamples= mFiles-2;
A=zeros(size(image,1),mSamples);
size(A)
for i= 3 : mFiles
D(i).name
image=imread(strcat(DBPath,'\',D(i).name));
[x, y, z]= size(image)
if(z==3)
image=rgb2gray(image);
end
image=imresize(image,[64,64]);
image = image(:);
A(:,i-2)=double(image);
end
%At=A.';s
M=mean(A');
phi=(A-M');
C=phi'*phi;
k=10;
[V D]= eigs(C,k);
size(phi)
size(V)
U=phi*V;
size(U)
for i=1 :k
length=norm(U(:,i));
U(:,i)=U(:,i)./length;
end
wi=zeros(k,mSamples);
for i=1 : mSamples
wi(:,i)= U'*A(:,i);
end
testImage = cap_img();
[
% testImage=imread('D:\Matlab_prblms\face_database\17.tif');
testImage = rgb2gray(testImage);
testImage=imresize(testImage,[64 ,64]);
testImage=testImage(:);
t=U'*double(testImage);
mindist=999999;
index=-1;
for i=1 : mSamples
distVal = (wi(:,i) - t).*(wi(:,i) - t);
if(mindist > distVal)
mindist = distVal;
index=i;
end
end
for i = 1 : mSamples
q = t(:,i);
temp = ( norm( t - q ) )^2;
mindist= [mindist temp];
end
index
5 Commenti
Carl
il 28 Lug 2017
Are you asking how to display the message, or how to identify when there is no match? For displaying a message, you can use something simple like the "disp" function. For identifying if there is no match, that would depend on how you interpret that mindist value.
Either way, I would strongly suggest that you follow the link posted by Image Analyst below. As they mentioned, it contains a much more robust approach to your original problem.
Risposte (1)
Image Analyst
il 26 Lug 2017
I doubt any robust face recognition code is going to be only like 100 lines of code. You may want to look at how Brett, of The Mathworks, did it here: http://www.mathworks.com/matlabcentral/fileexchange/49914-streaming-face-detection--training--recognition
2 Commenti
Image Analyst
il 29 Lug 2017
It seems you're committed to getting your method working and don't want to make major changes to your existing code.
To find minimum distances I always use the Pythagorean theorem, sqrt(), to get distances and then use min() to find the min of the distances, OR use pdist2() to find distances of every point to every other point and then use min(). Whether one of those two methods will help you, I don't know. That's about all I can say.
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!