imrect objects are being deleted in successive frames
显示 更早的评论
I'm building an interactive GUI with imrect objects surrounding objects of interest. Once the user is happy with the size and position of these rectangles, the next (or previous) frame in a video is displayed. The object is for the user to reposition the rectangle on the new frame. The position of each rectangle at each frame is saved off for later processing.
The problem in when a new image is displayed, all the imrect objects are deleted.
Creating the imrect and storing in a cell array:
rects.targrect1 = imrect(handles.inImage, initpos);
The user does his thing, presses the button to get the next image and rects.targrect1 is deleted.
rects.targrect1 on original image:
K>> getPosition(rects.targrect1)
ans =
853.0000 471.0000 40.0000 40.0000
and the same command after presenting a new image via: imshow(latestFrame,'Border','tight');
K>> getPosition(rects.targrect1) Invalid or deleted object.
Error in imrect/getPosition (line 111) pos = obj.api.getPosition();
How can I put a new image in the axes in my GUI (handles.inImage) without having all my imrect objects deleted. Each of these imrect objects has a unique color and callbacks that also disappear.
Your help is appreciated, thanks!
1 个评论
Gert
2015-10-26
Hey Jeff, I am having the exact same problem. Did you figure this out in the meanwhile?
回答(1 个)
Walter Roberson
2015-10-26
3 个投票
If "hold on" (or the internal equivalent) is not in force, then the new imshow() will trigger deleting all objects in the axes, including the imrect objects.
A better approach than using imshow() for the next frame would be to record the handle of the first imshow() and then use the remembered handle and update its CData property with the new frame. Updating CData will not trigger deleting all objects in the axes.
1 个评论
Novel Certad
2019-5-17
Thanks a lot for this answer! I was losing my mind trying to figure it out
类别
在 帮助中心 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!