Error using Eigenfaces Too many output arguments. Error in ONL_REC (line 37) testimage=Eigenfaces*E;
Mostrar comentarios más antiguos
i want to check or recognized the image using my computer webcam by the following code that had trained in the neural network previously... i mean first i trained the image and save them by outputtttt.mat extension, but i had faced a problem in the line 37 or on the line i stated above
function [ ] =ONL_REC();
load latest
load outputttt
FDetect = vision.CascadeObjectDetector;
vid=videoinput('winvideo',1,'YUY2_320x240');
set(vid,'ReturnedColorSpace','rgb');
preview(vid)
pause (2)
start(vid);
im=getdata(vid,1);
figure(4),imshow(im)
title ('captured image');
closepreview(vid)
is = imresize(im, [256 256]);
imwrite(is,'test.jpg');
closepreview(vid)
I = imread('test.jpg');
BB = step(FDetect,I);
if numel(BB) == 0
error('Nothing was detected, try again');
clc
close all
clear all
else figure,imshow(I);
end
hold on
for i=1
rectangle('Position',BB(i,:),'LineWidth',2,'LineStyle','-','EdgeColor','r');
end
title('Face Detection');
J = imcrop(I,([BB(1) BB(2) BB(3) BB(4)]));
is = imresize(J, [256 256]);
is=rgb2gray(is);
figure(4), imshow (is);
E=reshape(is,65536,1);
E=double(E)-m;
testimage=Eigenfaces'*E;
testimagen=net(testimage);
euc_dist=[];
for i=1:size(outputs,2)
q=outputs(:,i);
temp=(norm(testimagen-q))^2;
euc_dist=[euc_dist temp];
end
euc_distp=[];
for i=1:size(outputs,2)
q=outputs (:,i);
temp=(norm(testimage-q))^2;
euc_distp=[euc_distp temp];
end
[minEcuDist recognizedIndex]=min(euc_dist);
[minEcuDistp recognizedIndexp]=min(euc_distp);
if recognizedIndexp >1.1086e-6
a=imread('ERROR.PNG');
imshow(a);
clc
else
disp('reached');
str1=int2str(recognizedIndexp);
str1=strcat(str1,'.jpg');
im=imread(str1);
figure(5),imshow(im);
title('EQUIVALENT IMAGE ee');
end
if recognizedIndex >1.1086e-6
a=imread('ERROR.PNG');
imshow(a);
clc
else
disp('reached');
str1=int2str(recognizedIndex);
str1=strcat(str1,'.jpg');
im=imread(str1);
figure(6),imshow(im);
title('EQUIVALENT IMAGE nn');
end
hold off
end
%some one please help me with this.....
%but if you need the eigenfaces function, here we go
by the way this code is corretly work. the only problem is in the above ONL_REC function line 37
function [ ] = Eigenfaces( )
z=[];
ta=[];
for ii=1:374
str=int2str(ii);
str=strcat(str,'.JPG');
im=imread(str);
im=rgb2gray(im);
im=imresize(im,[256 256]);
temp=reshape(im,65536,1);
z=[z temp];m=mean(z,2);
end
for i=1:size(z,2)
t=double(z(:,i))-m;
ta=[ta t];
end
R=ta'*ta;
[v,d]=eig(R);
L_eig_vec=[];
for i=1:size(v,2)
if(d(i,i)>1)
L_eig_vec=[ L_eig_vec v(:,i) ];
end
end
Eigenfaces = ta*L_eig_vec;
disp('eig finished');
projectedimages = [];
Train_Number = size(ta,2);
for i = 1 : Train_Number
temp = Eigenfaces'*ta(:,i);
projectedimages = [projectedimages temp];
end
target=eye(Train_Number);
save latest.mat
end
% thank you
1 comentario
Bereket Ayalew
el 25 de Mayo de 2019
Respuesta aceptada
Más respuestas (1)
Bereket Ayalew
el 25 de Mayo de 2019
Editada: Bereket Ayalew
el 25 de Mayo de 2019
0 votos
Categorías
Más información sobre Nearest Neighbors en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!