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

조회 수: 1 (최근 30일)
Deniz
Deniz 2019년 3월 19일
댓글: Jan 2019년 3월 20일
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
Walter Roberson
Walter Roberson 2019년 3월 19일
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 2019년 3월 20일
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.

댓글을 달려면 로그인하십시오.

답변 (2개)

Walter Roberson
Walter Roberson 2019년 3월 19일
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 2019년 3월 20일
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.

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by