Batch saves the window screenshot in Task1.in.mat file

1 view (last 30 days)
I have a GUI and when pressed a button, a script is called through batch. The issue is that, the screenshot of GUI is saved in the file Task1.in.mat under the job's folder. This takes about 10 seconds to save (it is a very colorful GUI :)), this is too long for my application and I do not need the screenshot saved. I went in the sourcecode for the batch and found where the screenshot gets saved, but I didn't want to change anything there yet. Is there any easy way to get Matlab not to save the screenshot of the GUI that the batch is called from?
  5 Comments
Walter Roberson
Walter Roberson on 19 Mar 2019
It depends which screenshot you use.
If you use getframe() then it should send a request to the graphics subsystem to read out the screen buffer, which takes a little bit of time to set up but should be fast when it gets around to execution. It is not "free" because the MATLAB level does not know the pixel-level details, as it passes the 3D rendering of object down through the graphics drivers, so it has to ask the lower levels what the result was.
If you use saveas() or print() then the graphics hierarchy has to be reinterpreted in order to save at a (probably) higher resolution or through a different graphics format. That can take a while.
Jan
Jan on 20 Mar 2019
Walter is right: If "screenshot" is not a screenshot, but a saveas, the number of elements matters. So, Deniz, please post the relevant part of the code to reduce the demand for guessing.

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 19 Mar 2019
Provide your own .m function with the same name as the function that is taking the screenshot, but your function should return near empty content. For example
function dummy = getframe(object)
dummy = struct('cdata', zeros(1,1,3,'uint8'), 'colormap', []);
end

Edric Ellis
Edric Ellis on 20 Mar 2019
You haven't really given us enough reproduction steps to see exactly what's going on here, but I'm going to take a wild stab in the dark and guess that your figure handle or something else is being saved into the task when you call the batch funciton to run a script. If that is indeed the problem, you can work around this by specifying the optional 'Workspace' parameter to the batch function, something like this:
job = batch('myscript', 'Workspace', struct())
If you need to pass some variables thorugh to the script, then you can do it like so:
job = batch('myscript', 'Workspace', struct('x', 36, 'y', y))
which sets x to be 36 and y to be whatever value it has in your current workspace.

Categories

Find more on Large Files and Big Data in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!