Function varargout = Seguidor_GUI2(varargin) returns the handle to a new SEGUIDOR_GUI2, or the handle to the existing singleton. An % unrecognized property name or invalid value makes property application % stop.
Function varargout = Seguidor_GUI2(varargin) returns the handle to a new SEGUIDOR_GUI2, or the handle to the existing singleton. An % unrecognized property name or invalid value makes property application % stop.
Function varargout = Seguidor_GUI2(varargin) returns the handle to a new SEGUIDOR_GUI2, or the handle to the existing singleton. An % unrecognized property name or invalid value makes property application % stop.
% SEGUIDOR_GUI2, by itself, creates a new SEGUIDOR_GUI2 or raises the exist ing % singleton*. % % H = SEGUIDOR_GUI2 returns the handle to a new SEGUIDOR_GUI2 or the handle to % the existing singleton*. % % SEGUIDOR_GUI2('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in SEGUIDOR_GUI2.M with the given input arguments . % % SEGUIDOR_GUI2('Property','Value',...) creates a new SEGUIDOR_GUI2 or rais es the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before Seguidor_GUI2_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to Seguidor_GUI2_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES % Edit the above text to modify the response to help Seguidor_GUI2 % Last Modified by GUIDE v2.5 15-Jun-2014 18:41:42 % Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Seguidor_GUI2_OpeningFcn, ... 'gui_OutputFcn', @Seguidor_GUI2_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []); if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT % --- Executes just before Seguidor_GUI2 is made visible. function Seguidor_GUI2_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to Seguidor_GUI2 (see VARARGIN) % Choose default command line output for Seguidor_GUI2 handles.output = hObject; %handles.rgb = []; %handles.noback = []; %zeros(vidRes(2),vidRes(1),nBands) guidata(hObject, handles); try handles.video = videoinput('winvideo',1,'YUY2_320x240'); set(handles.video,'FramesPerTrigger',Inf); set(handles.video,'ReturnedColorspace','rgb'); data1=getsnapshot(handles.video); %handles.video.FrameGrabInterval=15; guidata(hObject, handles); %vidRes = get(handles.video, 'VideoResolution'); %nBands = get(handles.video, 'NumberOfBands'); hImage = image(data1,'Parent',... handles.axes1); preview(handles.video,hImage); catch msgbox('NO HAY CAMARA PRESENTE VERIFIQUE DATOS') end % UIWAIT makes Seguidor_GUI2 wait for user response (see UIRESUME) % uiwait(handles.figure1); % --- Outputs from this function are returned to the command line. function varargout = Seguidor_GUI2_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % Get default command line output from handles structure varargout{1} = handles.output; % --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) try
if (length(stats1)>0) %msgbox('ROJO'); set(handles.text1, 'String', 'ROJO'); area = bwarea(diff_imR); [g,tg]= edge(diff_imR,'canny',[0.09 0.12],0.3); %perimetro = bwarea(diff_imR); %k = perimetro^2; %cociente =k/area; %if ((18<cociente)&&(cociente <22)) % msgbox('El objeto es un triangulo'); %elseif ((10<cociente)&&(cociente <13)) % msgbox('El objeto es un circulo'); %elseif ((14<cociente)&&(cociente <17)) % msgbox('El objeto es un cuadrado'); %end imshow(diff_imR); axis off guidata(hObject, handles); else %COLOR VERDE %axes(handles.axes2); %im=getsnapshot(handles.video); diff_imG=imsubtract(im(:,:,2),rgb2gray(im)); diff_imG =medfilt2(diff_imG,[3,3]); diff_imG=im2bw(diff_imG,0.07); diff_imG=bwareaopen(diff_imG,300); bw2=bwlabel(diff_imG,8); stats2= regionprops(bw2,'BoundingBox','Centroid'); if (length(stats2)>0) %msgbox('VERDE'); set(handles.text1, 'String', 'VERDE'); else %COLOR AZUL axes(handles.axes2); %im=getsnapshot(handles.video); diff_imB=imsubtract(im(:,:,3),rgb2gray(im)); diff_imB =medfilt2(diff_imB,[3,3]); diff_imB=im2bw(diff_imB,0.18); diff_imB=bwareaopen(diff_imB,300); bw3=bwlabel(diff_imB,8); stats3= regionprops(bw3,'BoundingBox','Centroid'); if (length(stats3)>0) %msgbox('ROJO'); set(handles.text1, 'String', 'AZUL'); end %imshow(diff_imB); %axis off guidata(hObject, handles);
end %imshow(diff_imG); %axis off guidata(hObject, handles); end
catch msgbox('Error') end % --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)