Real-Time Video and Parallel Computing Toolbox

3 visualizzazioni (ultimi 30 giorni)
Suppose I am getting images a frame at a time from a camera. Psuedo-code for what that might look like is:
while (camera_status == ON)
% Get next frame
img = getFrame();
% Process frame
imgData = process_img(img);
% Plot results
update_plot(img, imgData);
end
Now suppose I'd like to try to separate the first task (getting next frame) from the next two (processing and plotting), and I tried using the Parallel Computing Toolbox with code like:
parpool(2);
img = getFrame();
while (camera_status == ON)
% Use parfeval to get next frame
next_img = parfeval(@getFrame, 1);
% Process previous frame
imgData = process_img(img);
% Plot previous results
update_plot(img, imgData);
% Transfer in next frame
img = fetchOutputs(next_img);
end
This sort of procedure seems to have very slow data transfer from the worker to the main code. The images are, say, 1920x1080. I know there is some baseline overhead to the parallel workers, but if I just transfer a scalar (calling parfeval on a function that just returns 1, say), the added processing time is minor, whereas it gets really bogged down transferring these ~2 million element arrays.
Do you have suggestions on different ways to structure this code or different ways to use the Parallel Computing Toolbox that might help the loop execution speed and actually take advantage of the parallel capabilities of MATLAB?

Risposte (0)

Categorie

Scopri di più su Parallel for-Loops (parfor) in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by