Saving Live video input to avi file
Afficher commentaires plus anciens
I'm having trouble recording frames from a live video and saving each frame to a playable avi file. I get the error "Operands to the || and && operators must be convertible to logical scalar values."
I'm using Matlab 2018a version, and the video input is using a frame grabber device with serial and cameralink connection.
% Specifies the Range of Interest
if exist('ROI','var') % Becomes True if the ROI variable was assigned in the function
CurROI = vid.ROIPosition; % Specifies Region of Interest(ROI) window
vid.ROIPosition = [max(0,ROI(1)),max(0,ROI(2)),min(ROI(3),CurROI(3)),min(ROI(4),CurROI(4))]; % Creates boundaries for ROI window
end
% Creates a video file from an array or file of images
diskLogger = VideoWriter(FileNameVideo,'Uncompressed AVI'); % VideoReader
diskLogger.FrameRate = 10; % Sets the framerate of the recorded and saved avi video file
set(vid,'Timeout',50);
% Starts the video
open(diskLogger);
preview(vid);
start(vid); % Triggers the acquisition of the live video
data = getdata(vid,vid.FramesAvailable,'uint8');
writeVideo(diskLogger,data)
implay(data);
%Close, stop, and end the video
close(diskLogger); % Closes the file the video was saved to
stop(vid); % Stops the triggering of the live camera feed
stoppreview(vid)
I had an earlier version that showed the same error.
for ii = 1:numFrames % Loops through each frame of the live camera feed saved
writeVideo(diskLogger, data(:,:,:,ii)); % writes each frame of the live feed to a video file
end
This replaced the writevideo line. IF there is any solution to this, I need it as soon as possible. Any ideas?
7 commentaires
Walter Roberson
le 5 Juin 2019
I do not see anything obviously wrong. Please post the complete error message showing the traceback.
Cordelia David
le 5 Juin 2019
Modifié(e) : Cordelia David
le 5 Juin 2019
Walter Roberson
le 5 Juin 2019
You using the default frames per trigger count of 1, and by default triggers are configured to go immediately when you start(). But you are not delaying to give time to acquire, so the frames available could be 0, and that triggered frame might not arrive until after you tell it to read all 0 of the available frames.
Cordelia David
le 5 Juin 2019
Cordelia David
le 6 Juin 2019
Cordelia David
le 6 Juin 2019
Modifié(e) : Cordelia David
le 6 Juin 2019
Réponses (0)
Catégories
En savoir plus sur National Instruments Frame Grabbers dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!