주요 콘텐츠

이 페이지는 기계 번역을 사용하여 번역되었습니다. 최신 내용을 영문으로 보려면 여기를 클릭하십시오.

디스크에 데이터 기록

이 예제에서는 디스크 기록에 대한 기록 속성을 구성한 다음 기록에 대한 수집을 시작하는 방법을 보여줍니다.

기록 모드 구성

이미지 수집 장치에서 수집된 데이터는 메모리, 디스크 또는 둘 다에 기록될 수 있습니다. 기본적으로 데이터는 메모리에 기록됩니다. 기록 모드를 변경하려면 비디오 입력 객체의 LoggingMode 속성을 구성합니다.

% 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

디스크 기록 속성 구성

디스크에 기록하려면 MATLAB® VideoWriter 객체가 필요합니다. VideoWriter는 툴박스 함수가 아닌 MATLAB 함수입니다. VideoWriter 객체를 만들고 구성한 후 비디오 입력 객체의 DiskLogger 속성에 제공합니다.

VideoWriter는 다양한 형식으로 데이터를 기록하는 여러 가지 프로필을 제공합니다. 이 예제에서는 단일 대역(회색조) 데이터뿐 아니라 다중 바이트 데이터도 기록할 수 있는 Motion JPEG 2000 프로파일을 사용합니다. VideoWriter에서 제공하는 프로필의 전체 목록은 설명서에서 확인할 수 있습니다.

% 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;

수집 시작

이제 비디오 입력 객체가 Motion JPEG 2000 파일에 데이터를 기록하도록 구성되었으므로 수집을 시작합니다.

% Start the acquisition.
start(vidobj)

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

대량의 데이터를 디스크에 기록할 때 디스크 쓰기가 데이터 수집보다 늦어지는 경우가 있습니다. 모든 프레임이 디스크에 기록되었는지 확인하려면 DiskLoggerFrameCount 속성을 사용하세요.

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

FramesAcquired 속성과 DiskLoggerFrameCount 속성이 같은 값을 가지는지 확인하세요.

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