-
Notifications
You must be signed in to change notification settings - Fork 3
MatLab Class
ganterd edited this page Apr 29, 2013
·
3 revisions
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.
The KTMMatlabRead class has the following properties:
-
hasDepthis a boolean representing the existence of a depth stream in the file. -
depthWidthis an integer defining the width of the depth stream frame. -
depthHeightis an integer defining the height of the depth stream frame. -
hasRGBis a boolean representing the existence of an RGB stream in the file. -
RGBWidthis an integer defining the width of the RGB stream frame. -
RGBHeightis an integer defining the height of the RGB stream frame. -
framesis 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.
-
EOFdefines if the end of the file is reached. -
currentFramedefines 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 byfilePath. 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 timeoutFrameTimeis in ms, the depth frameoutDepthFrameis adepthHeightxdepthWidthmatrix ofint16and the RGB frame is aRGBHeightxRGBWidthx3(RGB not BGR) matrix. -
[positionSet] = seekFrame(frameNumber)Sets the frame position in the file, settingpositionSetto 1 if theframeNumberis between 1 andframesand 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