📄 synchronize.m
字号:
function varargout = Synchronize(varargin)%SYNCHRONIZE M-file for Synchronize.fig% SYNCHRONIZE, by itself, creates a new SYNCHRONIZE or raises the existing% singleton*.%% H = SYNCHRONIZE returns the handle to a new SYNCHRONIZE or the handle to% the existing singleton*.%% SYNCHRONIZE('Property','Value',...) creates a new SYNCHRONIZE using the% given property value pairs. Unrecognized properties are passed via% varargin to Synchronize_OpeningFcn. This calling syntax produces a% warning when there is an existing singleton*.%% SYNCHRONIZE('CALLBACK') and SYNCHRONIZE('CALLBACK',hObject,...) call the% local function named CALLBACK in SYNCHRONIZE.M with the given input% arguments.%% *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 Synchronize% Last Modified by GUIDE v2.5 30-May-2005 10:02:47% Begin initialization code - DO NOT EDITgui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @Synchronize_OpeningFcn, ... 'gui_OutputFcn', @Synchronize_OutputFcn, ... 'gui_LayoutFcn', [], ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif 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 Synchronize is made visible.function Synchronize_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 unrecognized PropertyName/PropertyValue pairs from the% command line (see VARARGIN)% Choose default command line output for Synchronizehandles.output = hObject;% Update handles structureguidata(hObject, handles);% UIWAIT makes Synchronize wait for user response (see UIRESUME)% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.function varargout = Synchronize_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 structurevarargout{1} = handles.output;% --- Executes on slider movement.function slider1_Callback(hObject, eventdata, handles)% hObject handle to slider1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slidersv = get(handles.slider1,'Value');handles.n1=round(sv*handles.nof1);if handles.n1 ==0, handles.n1=1;endset(handles.Frame_No1,'String',handles.n1);axes(handles.axes1)clahold on,[handles.I1,Map] = frame2im(handles.mov1(1,handles.n1));imshow(handles.I1);guidata(hObject, handles);% --- Executes during object creation, after setting all properties.function slider1_CreateFcn(hObject, eventdata, handles)% hObject handle to slider1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);endfunction Frame_No1_Callback(hObject, eventdata, handles)% hObject handle to Frame_No1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of Frame_No1 as text% str2double(get(hObject,'String')) returns contents of Frame_No1 as a double% --- Executes during object creation, after setting all properties.function Frame_No1_CreateFcn(hObject, eventdata, handles)% hObject handle to Frame_No1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end% --- Executes on button press in Previous1.function Previous1_Callback(hObject, eventdata, handles)% hObject handle to Previous1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)if handles.fnd1>0 handles.show1 = handles.show1 - 1; if handles.show1<1 handles.show1 = handles.fnd1; end handles.n1 = handles.pos1(handles.show1); set(handles.slider1,'Value',handles.n1/max(size(handles.mov1))); set(handles.Frame_No1,'String',handles.n1); axes(handles.axes1) cla hold on, [handles.I1,Map] = frame2im(handles.mov1(1,handles.n1)); imshow(handles.I1); guidata(hObject, handles);end% --- Executes on button press in Select1.function Select1_Callback(hObject, eventdata, handles)% hObject handle to Select1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)prompt={'Height of Rectangle:','Width of Rectangle::'};name='The Size of Region';numlines=1;sz = size(handles.I1);defaultanswer={num2str(round(sz(1)/40)),num2str(round(sz(2)/40))};answer=inputdlg(prompt,name,numlines,defaultanswer);handles.h1 = eval(char(answer(1)));handles.w1 = eval(char(answer(2)));[x,y] = ginput(1)handles.x1 = fix(x) - round(handles.w1/2)+1;handles.y1 = fix(y) - round(handles.h1/2)+1;axes(handles.axes1)rectangle('Position',[handles.x1,handles.y1,handles.w1,handles.h1],'Curvature',[0.2,0.2],'EdgeColor','g')set(handles.Start1,'Enable','on');guidata(hObject, handles);% --- Executes on button press in Next1.function Next1_Callback(hObject, eventdata, handles)% hObject handle to Next1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)if handles.fnd1>0 handles.show1 = handles.show1 + 1; if handles.show1>handles.fnd1 handles.show1 = 1; end handles.n1 = handles.pos1(handles.show1); set(handles.slider1,'Value',handles.n1/max(size(handles.mov1))); set(handles.Frame_No1,'String',handles.n1); axes(handles.axes1) cla hold on, [handles.I1,Map] = frame2im(handles.mov1(1,handles.n1)); imshow(handles.I1); guidata(hObject, handles);end% --- Executes on button press in Open1.function Open1_Callback(hObject, eventdata, handles)% hObject handle to Open1 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)clc;[filename, pathname] = uigetfile('*.avi', 'Pick an avi-file');if isequal(filename,0) disp('User selected Cancel')else file = fullfile(pathname, filename) disp(['User selected', file]) name = ['Left Camera - ' file]; set(handles.uipanel1,'Title',name) handles.mov1 = aviread(file); handles.nof1 = max(size(handles.mov1)); handles.n1 = handles.nof1; set(handles.slider1,'Value',1); set(handles.Frame_No1,'String',handles.n1); [handles.I1,Map] = frame2im(handles.mov1(1,handles.n1)); guidata(hObject, handles); axes(handles.axes1) cla hold on, imshow(handles.I1); set(handles.slider1,'SliderStep',[1/handles.nof1;.1]) set(handles.Select1,'Enable','on'); guidata(hObject, handles);end% --- Executes on slider movement.function slider2_Callback(hObject, eventdata, handles)% hObject handle to slider2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'Value') returns position of slider% get(hObject,'Min') and get(hObject,'Max') to determine range of slidersv = get(handles.slider2,'Value');handles.n2=round(sv*handles.nof2);if handles.n2 ==0, handles.n2=1;endset(handles.Frame_No2,'String',handles.n2);axes(handles.axes2)clahold on,[handles.I2,Map] = frame2im(handles.mov2(1,handles.n2));imshow(handles.I2);guidata(hObject, handles);% --- Executes during object creation, after setting all properties.function slider2_CreateFcn(hObject, eventdata, handles)% hObject handle to slider2 (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: slider controls usually have a light gray background.if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor',[.9 .9 .9]);end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -