While a video input object is running, you can log image data being acquired to a disk file. Logging image data to disk provides a record of your data.
For the best performance, logging to disk requires a MATLAB®
which is a MATLAB function,
not an Image Acquisition Toolbox™ function. After you create and
VideoWriter object, provide it to the
VideoWriter provides a number of different
profiles that log the data in different formats. The following example
uses the Motion JPEG 2000 profile, which can log single-banded (grayscale)
data as well as multi-byte data. Supported profiles are:
'Motion JPEG 2000' — Compressed
Motion JPEG 2000 file.
'Archival' — Motion JPEG
2000 file with lossless compression.
'Motion JPEG AVI' — Compressed
AVI file using Motion JPEG codec.
'Uncompressed AVI' — Uncompressed
AVI file with
'MPEG-4' — Compressed MPEG-4 file with H.264 encoding (systems with
Windows 7 or macOS 10.7 and later).
'Grayscale AVI' — Uncompressed
AVI file with grayscale video. Only used for monochrome devices.
'Indexed AVI' — Uncompressed
AVI file with indexed video. Only used for monochrome devices.
This example uses a GigE Vision device in a grayscale format
Create a video input object that accesses a GigE Vision image acquisition device and uses grayscale format at 10 bits per pixel.
vidobj = videoinput('gige', 1, 'Mono10');
You can log acquired data to memory, to disk, or both.
By default, data is logged to memory. To change the logging mode to
disk, configure the video input object's
vidobj.LoggingMode = 'disk'
Create a VideoWriter object with the profile set to Motion JPEG 2000.
logfile = VideoWriter('logfile.mj2, 'Motion JPEG 2000')
Configure the video input object to use the
vidobj.DiskLogger = logfile;
Now that the video input object is configured for logging data to a Motion JPEG 2000 file, initiate the acquisition.
Wait for the acquisition to finish.
When logging large amounts of data to disk, disk writing
occasionally lags behind the acquisition. To determine whether all
frames are written to disk, you can optionally use the
while (vidobj.FramesAcquired ~= vidobj.DiskLoggerFrameCount) pause(.1) end
You can verify that the
have identical values by using these commands and comparing the output.
When the video input object is no longer needed, delete it and clear it from the workspace.
delete(vidobj) clear vidobj
Note the following when using VideoWriter.
You should not delete the video input object until
logging has been completed as indicated by the
FramesAcquired property. Doing so
will cause disk logging to stop without all of the data being logged.
If START is called multiple times without supplying a new VideoWriter object, the contents of the previous file will be erased when START is called.
Once the VideoWriter object has been passed to the
you should not modify it.