DiskLogger

Specify MATLAB VideoWriter file used to log data

Description

The DiskLogger property specifies the VideoWriter or AVI file object used to log data when the LoggingMode property is set to 'disk' or 'disk&memory'. For the best performance, VideoWriter is the recommended file type.

VideoWriter File

For the best performance, logging to disk requires a MATLAB® VideoWriter object, which is a MATLAB object, not an Image Acquisition Toolbox™ object. After you create and configure a VideoWriter object, you provide it to the DiskLogger property.

A MATLAB VideoWriter object specifies the file name and other characteristics. For example, you can use VideoWriter properties to specify the profile used for data compression and the desired quality of the output. For complete information about the VideoWriter object and its properties, see the VideoWriter documentation.

    Note   Do not use the variable returned by the VideoWriter function to perform any operation on a VideoWriter file while it is being used by a video input object for data logging. For example, do not change any of the VideoWriter file properties, add frames, or close the object. Your changes could conflict with the video input object.

After Logging and Running are off, it is possible that the DiskLogger might still be writing data to disk. When the DiskLogger finishes writing data to disk, the value of the DiskLoggerFrameCount property should equal the value of the FramesAcquired property. Do not close or modify the DiskLogger until this condition is met.

For more information about logging image data using a VideoWriter file, see Logging Image Data to Disk.

AVI File

A MATLAB AVI file object specifies the name and other characteristics of an AVI file. For example, you can use AVI file object properties to specify the codec used for data compression and the desired quality of the output. For complete information about the AVI file object and its properties, see the avifile documentation.

    Note   Do not use the variable returned by the avifile function to perform any operation on an AVI file object while it is being used by a video input object for data logging. For example, do not change any of the AVI file object properties, add frames, or close the object. Your changes could conflict with the video input object.

When the video input object finishes logging data to disk, the AVI file object remains open. The video input object does not open or close an AVI file object used for logging. The video input object, however, does update the Width, Height, and TotalFrames fields in the AVI file object to reflect the current acquisition settings.

After Logging and Running are off, it is possible that the DiskLogger might still be writing data to disk. When the DiskLogger finishes writing data to disk, the value of the DiskLoggerFrameCount property should equal the value of the FramesAcquired property. Do not close or modify the DiskLogger until this condition is met.

    Note:   The peekdata function does not return any data while running if in disk logging mode.

Characteristics

Access

Read only while running

Data type

VideoWriter object or AVI file object

Values

The default value is [].

Examples

Using VideoWriter

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 LoggingMode property.

vidobj.LoggingMode = 'disk'

Create a VideoWriter object with the profile set to Motion JPEG 2000. Motion JPEG 2000 allows writing the full 10 bits per pixel data to the file.

vidobj.DiskLogger = VideoWriter('logfile.mj2', 'Motion JPEG 2000')

Now that the video input object is configured for logging data to a Motion JPEG 2000 file, initiate the acquisition.

start(vidobj)

Wait for the acquisition to finish.

wait(vidobj)

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 DiskLoggerFrameCount property.

while (vidobj.FramesAcquired ~= vidobj.DiskLoggerFrameCount) 
    pause(.1)
end

You can verify that the FramesAcquired and DiskLoggerFrameCount properties have identical values by using these commands and comparing the output.

vidobj.FramesAcquired
vidobj.DiskLoggerFrameCount

When the video input object is no longer needed, delete it and clear it from the workspace.

delete(vidobj)
clear vidobj

Using an AVI File

Create and configure an AVI file object.

file = avifile('logfile.avi');
file.Quality = 50;

Create and configure a video input object.

vid = videoinput('winvideo', 1);
vid.LoggingMode = 'disk&memory';
vid.DiskLogger = file;

Start logging data to disk.

start(vid)

To ensure that the logged data is written to the disk file, close the AVI file. As an argument to the close function, specify the value of the video input object DiskLogger property, vid.DiskLogger, to reference the AVI file object, not the original variable, file, returned by the avifile function.

file = close(vid.DiskLogger);

Delete the image acquisition object from memory when it is no longer needed.

delete(vid)
clear vid
Was this topic helpful?