Data set must contain at least 3 samples.

if true
% function shapedetect_Callback(hObject, eventdata, handles)
global t
global t1
t=timer('TimerFcn',{@timerCallback2,handles},'ExecutionMode', 'fixedDelay','Period', 0.1);
guidata(hObject,handles);
stop(t1);
start(t);
function timerCallback2(hObject, eventdata, handles)
global vid
global t
global frame
global c
if (vid==-1)
msgbox('first show!');
stop(t);
return;
end
frame=getsnapshot(vid);
i_gray = rgb2gray(frame);
level = graythresh(i_gray);
i_bw = im2bw(i_gray,level);
bw_edge = edge(i_bw,'canny');
boundary=bwboundaries(bw_edge,'noholes');
boundary = boundary{1};
boundaryx=boundary(:,2);
boundaryy=boundary(:,1);
centroid=[(max(boundaryx)+min(boundaryx))/2 (max(boundaryy)+min(boundaryy))/2];
boundaryx=boundaryx-centroid(1);
boundaryy=boundaryy-centroid(2);
[theta,rho]=cart2pol(boundaryx,boundaryy);
B =[theta*180/pi rho];
r=sortrows([theta*180/pi rho]);
[~,idx]=min(r(:,2));
if idx>1
r=[r(idx:end,:);r(1:idx-1,1)+360 r(1:idx-1,2)];
end
theta=B(:,1);
rho=r(:,2)/max(rho);
if min(rho)>.7
set(handles.text2,'string','circle');
else
% find peak numbers
peak_num=length(findpeaks(r(round(linspace(1,length(theta),min([length(theta) 32]))),2)));
switch peak_num
case 3
set(handles.text2,'string','triangle');
case 4
set(handles.text2,'string','rectangle');
otherwise
set(handles.text2,'string','unkonwshape');
end
end
axes(handles.axesshow);
imshow(bw_edge);
end
i use this function in gui show the error:Data set must contain at least 3 samples. Just started can operation but after awhile stop working

1 comentario

zubair younas
zubair younas el 12 de Abr. de 2019
i am also facing same issue , have u find the solution regarding this?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre 图像 en Centro de ayuda y File Exchange.

Preguntada:

el 1 de Nov. de 2017

Comentada:

el 12 de Abr. de 2019

Community Treasure Hunt

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

Start Hunting!