Using Image Acquisition Toolbox and Parallel processing Toolbox to display and Record a video.
4 views (last 30 days)
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;
deviceInfo = imaqhwinfo('winvideo');
poolobj = parpool(1);
vid = videoinput('winvideo', 1, 'MJPG_640x480');
vid.ReturnedColorspace = 'rgb';
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;
% While Loop Begins
TriggerWord = "preview"; % Serial Read
if TriggerWord == "preview"
TriggerWord = "start";% Serial Read
if TriggerWord == "start"
TriggerWord = "stop";% Serial Read
if TriggerWord == "stop"
TriggerWord = "closepreview";% Serial Read
if TriggerWord == "closepreview"
disp("Close Preview Run")
% While Loop Ends