Two cameras real-time on parallel processor errors

2 次查看(过去 30 天)
I am trying to process two camera images on real-time and parallel. I wanted to start with camera image acquisition on parallel workers and just display the raw images real-time. The last "spmd" block gives the error
"Cell contents reference from a non-cell array object"
apparently I don't do the legal variable assignment in the parallel block. I tried "parfor" in order to make a loop to grab images, but this time I got the error saying:
"It is illegal to use a composite within the body of a parfor loop"
Could you please suggest a legal way of grabbing two camera images at the same time in a loop from two parallel workers?
% this version is dedicated for showing the video real-time
clear all
close all
clc
%% Create a parallel pool with two workers, one per camera
if isempty(gcp('nocreate'))
parpool(2)
end
%% Disconnect from all cameras from main MATLAB process and workers
delete(imaqfind);
spmd(2)
delete(imaqfind);
end
spmd(2)
for idx = 1:2%numlabs
if idx == labindex
imaqreset
% Detect cameras
gigeinfo = imaqhwinfo('gentl');
numCamerasFound = numel(gigeinfo.DeviceIDs);
fprintf('Worker %d detected %d cameras.\n', ...
labindex, numCamerasFound);
end
labBarrier
end
cameraID = labindex;
v = videoinput('gentl', cameraID);
s = v.Source;
end
figure,
spmd(2) %number of cameras
for(j = 1:100) %number of frames
img = getsnapshot(v);
img1 = img{1};
img2 = img{2};
img2 = imresize(img2, size(img1));
frames_12 = cat(2, img1, img2);
imshow(frames_12);
end
end

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by