image thumbnail

Robot Simulator

by

 

02 Aug 2007 (Updated )

Simulation Model of Industrial Robot Manipulator

Camera.m
function Camera(hObject, eventdata, handles)

global R G B s

s=1;
x=0; 
rel1=0;
rel=0;
vfm('show',0);
%**************Aquisio de imagem*************************
A=vfm('grab',1);
while (s==1) 
    pause(0.01);
    B=vfm('grab',1);
%                           Cb=A(:,:,3);
%                           Cr=A(:,:,1);
%                           Cg=A(:,:,2);
    axes(handles.axes1);    
    %subplot(2,2,1);
    image(A);
    axis off;    
    axes(handles.axes2);
    image(B);
    axis off;  
    axes(handles.axes3);
    %diferena entre duas imagens consecutivas
    C=B-A;
    image(C);
    axis off;
    A=B;
%    tic
   %somatrio dos elementos da diferena entre duas imagens consecutivas
    D=sum(C);
    E=sum(D);
    F=sum(E);
 %   toc
 % *****************detectar movimento*********************
  set(handles.textMovDetec,'string','No');
    if F>350000%480x640/2500000%3200000
             %   x=x+1;
                set(handles.textMovDetec,'string','Sim');
              %  tic;
    else set(handles.textMovDetec,'string','No');
    end
    
    %*******************detectar cor****************************
    %laranja 210/150/190
    %vermelho caneta 255/110/160
%     R=200;
%     G=20;
%     B=40;
    k=0;
    si=0;
    sj=0;
    filtR=50;   %pode ser constante
    filtG=30;   % //   //   //
    filtB=50;   % //   //   //

%     for i=1:240
%         for j=1:320
%             if (A(i,j,1)>=R-filtR & A(i,j,1)<=R+filtR &...
%                A(i,j,2)>=G-filtG & A(i,j,2)<=G+filtG &...      
%                A(i,j,3)>=B-filtB & A(i,j,3)<=B+filtB)
%                 si=si+i;
%                 sj=sj+j;
%                 k=k+1;
%             end
%         end
%     end
    
%     si=si/k;
%     sj=sj/k;
%      hold on;
%     plot(sj,si,'*');  %Testar
%     axis off;
%     
% hold off;
    
end

Contact us