Skip to content

MatLab Class

ganterd edited this page Apr 29, 2013 · 3 revisions

KTMMatlabRead

This MatLab class provides a method for reading in the files created by the recorder in a simple fashion. The class provides simple functionality to read frames from the file, provide information about the file and set the position in terms of frames in the file.


Properties

The KTMMatlabRead class has the following properties:

  • hasDepth is a boolean representing the existence of a depth stream in the file.
  • depthWidth is an integer defining the width of the depth stream frame.
  • depthHeight is an integer defining the height of the depth stream frame.
  • hasRGB is a boolean representing the existence of an RGB stream in the file.
  • RGBWidth is an integer defining the width of the RGB stream frame.
  • RGBHeight is an integer defining the height of the RGB stream frame.
  • frames is an integer defining the number of frames in the file.

The above properties are set to 0 in a new instance of the class, and are set appropriately when a file is loaded.

  • EOF defines if the end of the file is reached.
  • currentFrame defines the current frame in the file.

The above properties are set to 1 in a new instance of the class and are set appropriately during the use of a file.


###Functions

  • openFile(filePath) This function is used to open a file defined by filePath. This does not return anything, but sets the appropriate properties to reflect the read in file.
  • [outFrameTime,outDepthFrame,outRGBFrame] = nextFrame() Returns the frame time since the start of recording, the depth frame and the RGB frame. The frame time outFrameTime is in ms, the depth frame outDepthFrame is a depthHeight x depthWidth matrix of int16 and the RGB frame is a RGBHeight x RGBWidth x 3 (RGB not BGR) matrix.
  • [positionSet] = seekFrame(frameNumber) Sets the frame position in the file, setting positionSet to 1 if the frameNumber is between 1 and frames and 0 if otherwise.

###Example Usage

% Instantiate the class
reader = KTMMatLabRead;

% Open file and read frame from file
reader = reader.openFile('FILE_PATH');
[reader, frameTime, depthFrame, RGBFrame] = reader.nextFrame();

% Show RGB Frame
image(RGBFrame);

% Jump to and get last frame
[reader,positionSet] = seekFrame(reader.frames);
[reader, frameTime, depthFrame, RGBFrame] = reader.nextFrame();

% Do other operations

Clone this wiki locally