io
Class FrameReader

java.lang.Object
  extended by io.FrameReader
All Implemented Interfaces:
FrameSource

public class FrameReader
extends java.lang.Object
implements FrameSource

Read frames from a file or stdin (unlabeled feature data), first int (4byte) is the frame size.

Author:
sikoried

Constructor Summary
FrameReader()
           
FrameReader(java.lang.String fileName)
           
FrameReader(java.lang.String fileName, boolean ufv, int fs)
           
 
Method Summary
 void close()
          Close the FrameReader's input file
 int getFrameSize()
          Return the size of the output frames
static void main(java.lang.String[] args)
           
 boolean read(double[] buf)
          Read the next frame, convert the raw data to doubles
static boolean readDoubleArray(java.io.InputStream is, double[] buf)
          Read a double array from the given input stream (expects raw doubles...)
static boolean readUFVArray(java.io.InputStream is, double[] buf)
           
 java.lang.String toString()
          Return a String representation of the FrameSource
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FrameReader

public FrameReader()
            throws java.io.IOException
Throws:
java.io.IOException

FrameReader

public FrameReader(java.lang.String fileName)
            throws java.io.IOException
Throws:
java.io.IOException

FrameReader

public FrameReader(java.lang.String fileName,
                   boolean ufv,
                   int fs)
            throws java.io.IOException
Throws:
java.io.IOException
Method Detail

close

public void close()
           throws java.io.IOException
Close the FrameReader's input file

Throws:
java.io.IOException

getFrameSize

public int getFrameSize()
Return the size of the output frames

Specified by:
getFrameSize in interface FrameSource

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Throws:
java.io.IOException

read

public boolean read(double[] buf)
             throws java.io.IOException
Read the next frame, convert the raw data to doubles

Specified by:
read in interface FrameSource
Parameters:
buf - buffer to save the frame; implementing objects may depend on a constant dimensionduring subsequent calls
Returns:
true on success, false if the stream terminated before the window was filled
Throws:
java.io.IOException

readDoubleArray

public static boolean readDoubleArray(java.io.InputStream is,
                                      double[] buf)
                               throws java.io.IOException
Read a double array from the given input stream (expects raw doubles...)

Parameters:
is - InputStream to use
buf - Buffer to save values to
Returns:
true on success
Throws:
java.io.IOException

readUFVArray

public static boolean readUFVArray(java.io.InputStream is,
                                   double[] buf)
                            throws java.io.IOException
Throws:
java.io.IOException

toString

public java.lang.String toString()
Description copied from interface: FrameSource
Return a String representation of the FrameSource

Specified by:
toString in interface FrameSource
Overrides:
toString in class java.lang.Object