function varargout = Recognition(varargin)
% RECOGNITION MATLAB code for Recognition.fig
% RECOGNITION, by itself, creates a new RECOGNITION or raises the existing
% singleton*.
%
% H = RECOGNITION returns the handle to a new RECOGNITION or the handle to
% the existing singleton*.
%
% RECOGNITION('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in RECOGNITION.M with the given input arguments.
%
% RECOGNITION('Property','Value',...) creates a new RECOGNITION or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before Recognition_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to Recognition_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 Recognition
% Last Modified by GUIDE v2.5 16-Apr-2019 15:15:07
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @Recognition_OpeningFcn, ...
'gui_OutputFcn', @Recognition_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 Recognition is made visible.
function Recognition_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 Recognition (see VARARGIN)
% Choose default command line output for Recognition
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Recognition wait for user response (see UIRESUME)
% uiwait(handles.figure1);
axis([0 240 0 240]);
% --- Outputs from this function are returned to the command line.
function varargout = Recognition_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;
clc;
% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global ButtonDown pos1;
if strcmp(get(gcf,'SelectionType'),'normal')
ButtonDown = 1;
pos1 = get(handles.axes1,'CurrentPoint');
end
% --- Executes on mouse motion over figure - except title and menu.
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global ButtonDown pos1
if(ButtonDown == 1)
pos = get(handles.axes1,'CurrentPoint');
line([pos1(1,1) pos(1,1)], [pos1(1,2) pos(1,2)], 'Color','Black', 'LineStyle','-', 'LineWidth',8, 'Marker','.', 'MarkerSize',20)
pos1 = pos;
end
% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
function figure1_WindowButtonUpFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global ButtonDown
ButtonDown = 0;
% --- 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)
cla;
% --- Executes on button press in pushbuttonSave.
function pushbuttonSave_Callback(hObject, eventdata, handles)
% hObject handle to pushbuttonSave (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[f, p] = uiputfile({'*.bmp'},'save image file');
str = strcat(p,f);
px = getframe(handles.axes1);
curImg=frame2im(px);
imwrite(curImg,str,'bmp');
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
px=getframe(handles.axes1);
curImg=frame2im(px);
curFea=getFeature(curImg,5,5);
y=CmpDistance(curFea);
warndlg(y,'识别结果');