Using Image Acquisition Toolbox and Parallel processing Toolbox to display and Record a video.
6 views (last 30 days)
Show older comments
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 Comments
Raymond Norris
on 13 Dec 2021
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.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!