Updating variables in a "real-time" GUI

12 visualizaciones (últimos 30 días)
MechtEngineer
MechtEngineer el 24 de Mzo. de 2011
I am making my first Matlab GUI, so please excuse my ignorance. I have done a few very simple practice GUIs to get myself started.
I want to make a Matlab GUI using GUIDE that has a central window running some image processing filters on a stream of sequential pictures I have stored on my computer. As the pictures are being filtered, I want to have numerical input boxes to the side that I can manipulate. As soon as I change a value in one of these input boxes, I will use the entered number to adjust the filters, and then the subsequent images processed should use the updated filter.
So in essence, what I want is a real-time image processing GUI with adjustable filter parameters.
Constructing the GUI is fine. I cannot foresee any major problems there. My question is, if I input a number to adjust my filters in some way, how do I get the images to use this updated filter?
I have thought of a number of leads that may or may not be useful: 1. Are there interrupt priority levels that I can assign to a change in a variable or an input box being used? 2. Would making the filter variables global mean that I can adjust them from the input box and the image processing algorithm would use the updated variable on the next image?
I am much obliged for any help received - even if it is 'lookup the words "Callback" and investigate "Matlab interrupt tables"' for example.
Mark

Respuesta aceptada

Matt Fig
Matt Fig el 24 de Mzo. de 2011
Have the image processing loop check retrieve the string property from each editbox at the beginning of the loop. You may need to convert the string to a number, depending on what your image processing uses. For example:
N = str2double(get(ediboxhandle,'string'));
You will have to stick a DRAWNOW at the top of the loop before you check for the updated values.
  2 comentarios
MechtEngineer
MechtEngineer el 24 de Mzo. de 2011
According to Matlab, drawnow causes figure windows and their children to update, and flushes the system event queue. Any callbacks generated by incoming events (e.g., mouse or key events) are dispatched before drawnow returns.
Does this mean my changes to pushbuttons and input textboxes are deleted if they are done before or while drawnow is being executed?
Walter Roberson
Walter Roberson el 24 de Mzo. de 2011
Changes to your pushbuttons and input text boxes are handled by Java, which queues them up until Matlab is ready to read them and respond to them. Any changes you make before drawnow() is called will be handled before drawnow() returns. It is not really documented about what happens if you do something in the UI _while_ a drawnow() call is in the middle of executing: either drawnow() will continuing processing until the queue is empty or else the events will stay queued until the next drawnow() [or other call that examines the event queue.]

Iniciar sesión para comentar.

Más respuestas (1)

Walter Roberson
Walter Roberson el 24 de Mzo. de 2011
For greater certainty with respec to Matt's answer:
- No, there are no interrupt priority levels, and user interface routines have interaction queued (or discarded) if there is a running routine, until the running routine uses one of about 5 different function calls that specifically allow interrupts. The most straightforward of those calls is drawnow() which will allow the UI to run pending callbacks before returning to the routine in progress.
- Yes, using globals would have that effect. However, unless one has a lot of self-discipline about how globals are used, there is a fair chance that at some point you will change one global and forget about the interaction between it and another value. It isn't certain death of your program by any means, but as the scope of the program expands, the chance of an accidental and difficult to find conflict rises exponentially.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by