Issue with getrect and WindowKeyPressFcn
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I have a code which displays an image and allows user to draw rectangles using getrect function in an infinite loop. I also want to set the title of the figure interactively using key press. But getrect is blocking keyboard events and is not allowing WindowKeyPressFcn callback to execute. Any suggestions on how to enable keyboard events during getrect.
figure('WindowKeyPressFcn',@keypress_fun)
hold on
imshow('peppers.png')
title('a')
while(1)
rect=getrect();
bbxmin=floor(rect(1));
bbymin=floor(rect(2));
bbwidth=floor(rect(3));
bbheight=floor(rect(4));
rectangle('Position', [bbxmin, bbymin, bbwidth, bbheight],'EdgeColor','g', 'LineWidth', 2)
end
function keypress_fun(src,eventdata)
title(eventdata.Key)
end
Thanks
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!