Error using - Matrix dimensions must agree. Error in ONL_REC (line 48) temp=(norm​(testimage​-q))^2;

1 次查看(过去 30 天)
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
%please help me
  4 个评论
KALYAN ACHARJYA
KALYAN ACHARJYA 2019-5-28
编辑:KALYAN ACHARJYA 2019-5-28
@Bereket Most members in this forum are learner here, for this type to error, we also have try ourself, so that the size mismatch can be figure out, normally it takes time.
Also load data needed to check the code.
Rik
Rik 2019-5-28
Also, I doubt you only had 2 days in total to figure this question out (or your instructor is misjudging your abilities and/or unreasonable).

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by