繁体   English   中英

使用Matlab App Designer获取鼠标点

[英]Getting Mouse Points using Matlab App Designer

我意识到App设计器不支持交互式图形操作,但是我想知道是否可以打开一个单独的图形窗口(而不是UI窗口),并在其上显示图形,以便仍能获得鼠标单击的位置。 当前,下面的代码在我的GUI上显示该图,然后打开另一个记录我的鼠标点击的空白图。 很好,但是我还需要在新窗口中显示该图,这样做很麻烦。

first frame = vid(:,:,:,1);
imshow(firstframe,'Parent',app.UIAxes); 
[centers_X centers_Y]=getpts;

对我有用的是在图像而不是轴上设置回调:

ih = imshow(firstframe,'Parent',app.UIAxes);
ih.ButtonDownFcn = {@im_ButtonDownFcn, app}; %app will be passed to the callback

然后在同一文件夹中的单独文件中(或作为appdesigner中的私有函数...它应该可以工作,但我没有尝试过):

function im_ButtonDownFcn(im, hit, app)
mouse_pos = flip(hit.IntersectionPoint(1:2)); %gives floats. Round if you want integers e.g. for indexing pixels

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM