您好我正在尝试创建一个GUI来链接到我的3米文件。
1)findcontrolpoints.m 2)morph.m 3)morphvideo.m
在1)中,我需要获得用户输入的点数。输入将输入GUI,然后我希望将变量传递给findcontrolpoints.m文件进行处理。这将通过按下按钮1来完成。有没有办法做到这一点?
function inputpoints_Callback(hObject, eventdata, handles)
% hObject handle to inputpoints (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 inputpoints as text
% str2double(get(hObject,'String')) returns contents of inputpoints as a double
input = str2num(get(hObject, 'String'));
if (isempty(input))
set(hObject, 'String', '50')
end
guidata(hObject, handles);
% --- 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)
% hMainGui = getappdata(0, 'hMainGui');
% fileName = uigetfile('*.jpg');
points = get(handles.inputpoints,'String');
findfeaturepoint(points);
答案 0 :(得分:1)
这样的事情对你有用吗?我只是重新使用了另一个项目的旧GUI,所以你几乎可以摆脱所有的选项,它仍然可以工作。
function interface
% Main figure
figure('units','normalized',...
'position',[0.25 0.25 0.5 0.5],...
'color',[1 1 1]*0.5,...
'numbertitle','off',...
'name','Interface',...
'menubar','none',...
'toolbar','none',...
'tag','main');
% Data structure
data=guihandles(gcf);
% Input field
uicontrol('parent',data.main,...
'style','text',...
'string','Number of points',...
'horizontalalignment','center',...
'backgroundcolor',[1 1 1]*0.5,...
'units','normalized',...
'position',[0.4 0.7 0.2 0.1]);
uicontrol('parent',data.main,...
'style','edit',...
'horizontalalignment','center',...
'string','0',...
'backgroundcolor',[1 1 1],...
'units','normalized',...
'enable','on',...
'position',[0.4 0.6 0.2 0.1],...
'tag','input');
% Submit
uicontrol('parent',data.main,...
'style','pushbutton',...
'string','Submit',...
'units','normalized',...
'enable','on',...
'position',[0.4 0.45 0.2 0.1],...
'tag','submit',...
'callback',@submit);
% Data structure
data=guihandles(gcf);
% Program parameters
data.default=50;
% ... %
guidata(gcf,data);
end
% Callbacks
function submit(obj,event) %#ok
% Data structure
data=guidata(gcbf);
input=get(data.input,'string');
% Input validation
% ... %
% Functions call
% ... %
guidata(gcbf,data);
end
在输入数据后,你只需要从回调中调用你的三个函数。