Trying to pass figure handles into a parfor loop - need help

3 views (last 30 days)
Hello all,
I am trying to solve a computer vision problem on short video sequences and am trying to implement a parfor loop to process multiple frames in parallel. I need to pass a figure handle or a cell array of figure handles into the parfor loop so I can project an image onto the figure and then grab that image data with imcapture.m. I am getting a few different errors and have a couple questions regarding this:
1. To avoid all the workers trying to plot to and grab images from the same figure, do I need to provide a different figure handle for each worker and manage which worker uses which figure? If so I have devised a way to do this; I am just wondering if there is an easier way.
2. If I try to pass a cell array of figure handles into to parfor loop, when I try to use the "set" command to set the positions...
set( h, 'Position', [positionData])
i get an error saying there is an invalid or deleted object. As I tried to debug, I found that the figure handles were not being passed into the function within the parfor loop. Does anyone know why this would be or any possible fixed? Thanks
  1 Comment
Matt J
Matt J on 16 Jun 2014
Edited: Matt J on 16 Jun 2014
I don't think it's possible to do any meaningful work with handle graphics on the parallel workers. The workers effectively run in separate MATLAB sessions. For most kinds of handle objects, when sent to a worker the handle will have the data it points to cloned and sent to the workers as well. Handle operations on the workers will act on the cloned local copies of the data.
I'm not sure if this applies to figure data. Even if cloned and sent to the worker, figure data couldn't do anything useful there, because the workers don't have their own displays. I also expect any figure created on the worker would not be broadcast back to the host when parfor ends, for fear of clashing with figures already defined on the host...
The following does nothing for me, for example, except create 4 perpetually empty figures/axes
for i=1:4
figure(i);
h(i)=gca;
end
parfor i=1:4
plot(h(i),1:i);
end

Sign in to comment.

Answers (0)

Categories

Find more on Parallel for-Loops (parfor) 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!