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 で Image Arithmetic についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!