main content

logging data to disk -凯发k8网页登录

this example shows how to configure logging properties for disk logging and then initiate an acquisition to log.

configuring logging mode

data acquired from an image acquisition device may be logged to memory, to disk, or both. by default, data is logged to memory. to change the logging mode, configure the video input object's loggingmode property.

% access an image acquisition device, using a grayscale video format with
% 10 bits per pixel.
vidobj = videoinput('gige', 1, 'mono10');
% view the default logging mode.
currentloggingmode = vidobj.loggingmode;
currentloggingmode =
memory
% list all possible logging modes.
set(vidobj, 'loggingmode')
[ {memory} | disk | disk&memory ]
% configure the logging mode to disk.
vidobj.loggingmode = 'disk';
% verify the configuration.
currentloggingmode = vidobj.loggingmode;
currentloggingmode =
disk

configuring disk logging properties

logging to disk requires a matlab® videowriter object. videowriter is a matlab function, not a toolbox function. after you create and configure a videowriter object, provide it to the video input object's disklogger property.

videowriter provides a number of different profiles that log the data in different formats. this example uses the motion jpeg 2000 profile which can log single-banded (grayscale) data as well as multi-byte data. the complete list of profiles provided by videowriter can be found in the documentation.

% create a videowriter object.
logfile = videowriter('logfile.mj2', 'motion jpeg 2000')
  videowriter
  general properties:
      filename: 'logfile.mj2'
          path: 'c:\temp'
    fileformat: 'mj2'
      duration: 0
  video properties:
             colorchannels: 
                    height: 
                     width: 
                framecount: 0
                 framerate: 30
         videobitsperpixel: 
               videoformat: 
    videocompressionmethod: 'motion jpeg 2000'
          compressionratio: 10
       losslesscompression: 0
               mj2bitdepth: 
% configure the video input object to use the videowriter object.
vidobj.disklogger = logfile;

initiating the acquisition

now that the video input object is configured for logging data to a motion jpeg 2000 file, initiate the acquisition.

% start the acquisition.
start(vidobj)
% wait for the acquisition to finish.
wait(vidobj, 5)

when logging large amounts of data to disk, disk writing sometimes lags behind the acquisition. to determine whether all frames have been written to disk, use the diskloggerframecount property.

while (vidobj.framesacquired ~= vidobj.diskloggerframecount)
    pause(.1)
end

verify that the framesacquired property and the diskloggerframecount property have the same value.

vidobj.framesacquired
ans =
    10
vidobj.diskloggerframecount
ans =
    10
% when the video input object is no longer needed, delete
% it and clear it from the workspace.
delete(vidobj)
clear vidobj
网站地图