0
我想從顯示的圖像中獲取矩形座標。我想要移動圖像。這是我的matlab GUI。
如何不停止正確的Matlab GUI?
所以,當我按下它應該顯示下一個圖像的系列和類似的後退按鈕。我使用此代碼
function next_Callback(hObject, eventdata, handles)
% hObject handle to next (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if handles.mypointer~=length(handles.cur_images)
handles.mypointer=handles.mypointer+1;
pic=imread(fullfile('images',handles.cur_images(handles.mypointer).name));
handles.imageName=handles.cur_images(handles.mypointer).name;
imshow(pic);
h=imrect;
getMyPos(getPosition(h));
addNewPositionCallback(h,@(p) getMyPos(p));
fcn = makeConstrainToRectFcn('imrect',get(gca,'XLim'),get(gca,'YLim'));
setPositionConstraintFcn(h,fcn);
handles.output = hObject;
handles.posi=getPosition(h);
guidata(hObject, handles);
但這種代碼的缺點是,當按下一個按鈕則停在h=imrect
所以等待用戶繪製矩形。它不做任何事,如果我不繪製一個矩形。即使我再次按下或下一個按鈕,它什麼都不做,因爲它仍在等待用戶繪製矩形。我很抱歉,如果這是一個明顯的問題,但我是matlab GUI新手。
問:
如何不要讓程序停止在Imrect
爲「不正確」做一個單獨的按鈕... – excaza