Updating Positions of ROI

5 vues (au cours des 30 derniers jours)
Omer Akatekin
Omer Akatekin le 20 Mar 2021
Commenté : Omer Akatekin le 20 Mar 2021
Hi,
I would like to let user to draw line on image and after drawing is completed (resizing and moving line)
i would like to process position of line to determine length of line.
I = imread('File Path.jpeg');
imshow(I);
roi = drawline;
x = roi.Position;
listener(roi,'ROIMoved',@allevents);
function allevents(~,evt)
evname = evt.EventName;
if evname == 'ROIMoved'
a =evt.CurrentPosition
end
end
However when drawn line position is changed i could not get the evt.Current Position value into workspace .
  1 commentaire
Omer Akatekin
Omer Akatekin le 20 Mar 2021
Well i found another solution:
Is it possible change ROIClicked to PressEnter ?
I = imread('*.jpeg');
imshow(I);
h = drawline;
pos = customWait(h);
function pos = customWait(hROI)
% Listen for mouse clicks on the ROI
l = addlistener(hROI,'ROIClicked',@clickCallback);
% Block program execution
uiwait;
% Remove listener
delete(l);
% Return the current position
pos = hROI.Position;
end
function clickCallback(~,evt)
if strcmp(evt.SelectionType,'double')
uiresume;
end
end

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by