imrect objects are being deleted in successive frames
Mostra commenti meno recenti
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 Commento
Gert
il 26 Ott 2015
Hey Jeff, I am having the exact same problem. Did you figure this out in the meanwhile?
Risposte (1)
Walter Roberson
il 26 Ott 2015
3 voti
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 Commento
Novel Certad
il 17 Mag 2019
Thanks a lot for this answer! I was losing my mind trying to figure it out
Categorie
Scopri di più su Image Arithmetic in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!