Using Image Acquisition Toolbox and Parallel processing Toolbox to display and Record a video.

5 次查看(过去 30 天)
I am trying to use the image acquistion toolbox and the parallel processing toolbox to display and record a video.
Basically, I have a big while loop that is reading a serial port and performing lots of computations. When a keyword comes across the port, this starts the video recording and another ends it.
I would basically like to use the parallel processing toolbox so that the displayed image is less framey (the recorded image is actually perfect for non-parallel).
I don't have much experience with these toolbox's as its on the work license, not my personal license.
I have attached a small example of how I thought this would work. The recorded video is there in its entirety but I can't get the preview to display. Is there a technique that I am unaware of or is it fundamentally not possible?
objects = imaqfind;
delete(objects);
imaqreset;
deviceInfo = imaqhwinfo('winvideo');
poolobj = parpool(1);
spmd(1)
vid = videoinput('winvideo', 1, 'MJPG_640x480');
vid.ReturnedColorspace = 'rgb';
triggerconfig(vid, 'immediate');
src = getselectedsource(vid);
frameRatesAvailable = set(src, 'FrameRate');
vid.FramesPerTrigger = Inf;
vid.TriggerRepeat = Inf;
vid.LoggingMode = 'disk';
VideoDir = ""; % Directory of interest
diskLogger = VideoWriter(VideoDir + "\TEST" + ".avi", 'Motion JPEG AVI');
diskLogger.FrameRate = 30; % Webcam is locked at 30 fps it appears - see variable frameRatesAvailable
vid.DiskLogger = diskLogger;
end
% While Loop Begins
TriggerWord = "preview"; % Serial Read
pause(2)
if TriggerWord == "preview"
spmd(1)
disp("Preview Run")
preview(vid);
end
end
pause(2);
TriggerWord = "start";% Serial Read
if TriggerWord == "start"
spmd(1)
disp("Start Run")
start(vid);
end
end
pause(2);
TriggerWord = "stop";% Serial Read
if TriggerWord == "stop"
spmd(1)
disp("Stop Run")
stop(vid);
end
end
pause(2);
TriggerWord = "closepreview";% Serial Read
if TriggerWord == "closepreview"
spmd(1)
disp("Close Preview Run")
closepreview(vid);
end
end
% While Loop Ends
delete(poolobj)
  2 个评论
Raymond Norris
Raymond Norris 2021-12-13
This issue is that the preview is running on a "headless" worker (within the spmd block), without access to a display. Perhaps you could queue data to the client to display, but I can't imagine you'd get the refresh updates that you'd want.
Cillian Hayde
Cillian Hayde 2021-12-14
@Raymond Norris, Thank you for your reply and introducing me to the concept of a headless worker!
It appears I can't mark your comment as resolving my issue even though I feel it has (The forum doesn't allow it).
Thank you for your time!

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by