org.cyberlab.support
Class FileStorage

java.lang.Object
  extended by org.cyberlab.support.FileStorage

public class FileStorage
extends java.lang.Object

Class implementing various file storage operations needed by the framework and made available to the framework user.

Author:
Mats-Gøran Karlsen

Constructor Summary
FileStorage()
           
 
Method Summary
static ImageFeatures loadImageFeatures(java.io.File file)
          Loads ImageFeatures from a file.
static LICOVModel loadLICOVmodel(byte[] bytes)
          Load LICOVmodel from byte array
static LICOVModel loadLICOVmodel(java.io.File file)
          Loads LICOmodel from file.
static org.opencv.core.Mat loadMat(java.io.File file)
          Loads Mat object from file
static java.lang.String readTextFile(java.lang.String enc, java.io.File textFile)
          Method for reading text files.
static boolean saveLICOVmodel(java.io.File file, LICOVModel lm)
          Saves LICOmodel to file.
static boolean saveMat(java.io.File file, org.opencv.core.Mat mat)
          Saves a Mat object to file
static boolean saveMat(java.io.File file, org.opencv.core.Mat mat, java.lang.String descriptorType, java.lang.String keypointType)
          Saves an image converted to a Mat object together with a string representation of its descriptor type and keypoint type.
static boolean writeBytesToFile(java.io.File out, byte[] bytes)
          Writes a byte array to file
static boolean writeTextFile(java.io.File textFile, java.lang.String text, java.lang.String enc)
          Writes a string to textfile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileStorage

public FileStorage()
Method Detail

readTextFile

public static java.lang.String readTextFile(java.lang.String enc,
                                            java.io.File textFile)
Method for reading text files.

Parameters:
enc - a string representing the encoding to use when translating this stream to a string.
textFile - a file containing text
Returns:
string representation of file contents. Returns empty string if read fails.

writeBytesToFile

public static boolean writeBytesToFile(java.io.File out,
                                       byte[] bytes)
Writes a byte array to file

Parameters:
out - where the bytes are to be stored
bytes - the bytes
Returns:
true on success

writeTextFile

public static boolean writeTextFile(java.io.File textFile,
                                    java.lang.String text,
                                    java.lang.String enc)
Writes a string to textfile

Parameters:
textFile - where the text are to be stored
text - the text itself
enc - a string representing the encoding to use when translating this stream to a string.
Returns:
true on success

saveMat

public static boolean saveMat(java.io.File file,
                              org.opencv.core.Mat mat)
Saves a Mat object to file

Parameters:
file - legal file
mat - the mat object
Returns:
Throws:
java.lang.IllegalArgumentException - Illegal file extension

loadMat

public static org.opencv.core.Mat loadMat(java.io.File file)
Loads Mat object from file

Parameters:
file - legal file
Returns:
the loaded Mat object
Throws:
java.lang.IllegalArgumentException - Illegal file extension

saveMat

public static boolean saveMat(java.io.File file,
                              org.opencv.core.Mat mat,
                              java.lang.String descriptorType,
                              java.lang.String keypointType)
Saves an image converted to a Mat object together with a string representation of its descriptor type and keypoint type.

Parameters:
file - legal file with .xml of .yml extension
mat - the image as a mat
descriptorType - descriptor type
keypointType - feature type
Returns:
success of save operation
Throws:
java.lang.IllegalArgumentException - Illegal file extension

loadImageFeatures

public static ImageFeatures loadImageFeatures(java.io.File file)
Loads ImageFeatures from a file.

Parameters:
file - legal file with extension .xml or .yml
Returns:
ImageFeatures object
Throws:
java.lang.IllegalArgumentException - Illegal file extension

saveLICOVmodel

public static boolean saveLICOVmodel(java.io.File file,
                                     LICOVModel lm)
Saves LICOmodel to file. Supported formats are XML and YAML.

Parameters:
file - Legal file with extension .xml or .yml
lm - The LICOmodel
Returns:
storage status
Throws:
java.lang.IllegalArgumentException - Illegal file extension

loadLICOVmodel

public static LICOVModel loadLICOVmodel(java.io.File file)
Loads LICOmodel from file. Supported formats are XML and YML.

Parameters:
file - Legal file with extension .xml or .yml
Returns:
the loaded LICOmodel or NULL on load error
Throws:
java.lang.IllegalArgumentException - Illegal file extension

loadLICOVmodel

public static LICOVModel loadLICOVmodel(byte[] bytes)
Load LICOVmodel from byte array

Parameters:
bytes - the byte representation of the LICOVmodel
Returns: