GUI Matrix dimensions must agree.
Show older comments
function numberdetect_Callback(hObject, eventdata, handles)
global t
global t1
t=timer('TimerFcn',{@timerCallback3,handles},'ExecutionMode', 'fixedDelay','Period', 0.1);
guidata(hObject,handles);
stop(t1);
start(t);
function timerCallback3(hObject, eventdata, handles)
global vid
global t
global frame
global c
if (vid==-1)
msgbox('請首先進行預覽!');
stop(t);
return;
end
frame=getsnapshot(vid);
imagen = rgb2gray(frame);
threshold = graythresh(imagen);
i_bw = ~im2bw(imagen,threshold);
i_bw2 = bwareaopen(i_bw,30);
i_bw3 = imclearborder(i_bw2);
re=i_bw3;
load templates
[fl re]=lines(re);
imgn=fl;
[L Ne] = bwlabel(imgn);
word = [];
for n=1:Ne
[r,d] = find(L==n);
n1=imgn(min(r):max(r),min(d):max(d));
img_r=imresize(n1,[42 24]);
comp=[];
for n=1: 24 : 240
sem=Corr2(templates(1:42,n:n+23),img_r);
comp=[comp sem];
end
vd=find(comp==max(comp));
%*-*-*-*-*-*-*-*-*-*-*-*-*-
if vd==1
letter='1';
elseif vd==2
letter='2';
elseif vd==3
letter='3';
elseif vd==4
letter='4';
elseif vd==5
letter='5';
elseif vd==6
letter='6';
elseif vd==7
letter='7';
elseif vd==8
letter='8';
elseif vd==9
letter='9';
else
letter='0';
end
word = [word letter];
end
if word == '40'
set(handles.text2,'string','40');
else
set(handles.text2,'string','no');
end
axes(handles.axesshow);
imshow(imagen);
end
function r = Corr2(A,B)
A = A - mean2(A);
B = B - mean2(B);
r = sum(sum(A.*B))/sqrt(sum(sum(A.*A))*sum(sum(B.*B)));
function [fl re]=lines(im_texto)
im_texto=clip(im_texto);
fl=im_texto;%Only one line.
re=[ ];
function img_out=clip(img_in)
[f c]=find(img_in);
img_out=img_in(min(f):max(f),min(c):max(c));%Crops image
I am use this function on guide but show the error: Matrix dimensions must agree.
Accepted Answer
More Answers (0)
Categories
Find more on 方差与协方差分析 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!