Superpixel Benchmark
Superpixel benchmark, tools and algorithms.
Static Public Member Functions | List of all members
IOUtil Class Reference

I/O utilities. More...

#include <io_util.h>

Static Public Member Functions

static int readMat (boost::filesystem::path file, cv::Mat &mat, std::string field="mat")
 Read an OpenCV matrix. More...
 
static int writeMat (boost::filesystem::path file, const cv::Mat &mat, std::string field="mat")
 Write a matrix to the given file. More...
 
template<typename T >
static int writeArrayCSV (boost::filesystem::path file, T **array, int rows, int cols, std::string separator=",", int precision=6)
 Write two dimensional array to CSV file. More...
 
template<typename T >
static int writeMatCSV (boost::filesystem::path file, const cv::Mat &mat, std::string separator=",", int precision=6)
 Write the content of a cv::Mat to a CSV file. More...
 
static int readMatCSVInt (boost::filesystem::path file, cv::Mat &result)
 Read CSV file into matrix. More...
 
static int readMatCSVInt (boost::filesystem::path file, int rows, int cols, cv::Mat &result)
 Read CSV file into matrix. More...
 
static int readMatCSVFloat (boost::filesystem::path file, cv::Mat &result)
 Read CSV file into matrix. More...
 
static int readCSVHeaderString (boost::filesystem::path file, std::vector< std::string > &header)
 Read header of CSV file into string array. More...
 
static int readCSVSummary (boost::filesystem::path file, std::vector< std::string > &row_headers, std::vector< std::string > &col_headers, cv::Mat &data)
 Read a CSV summary file as produced by EvaluationSummary. More...
 
static void listSubdirectories (boost::filesystem::path directory, std::multimap< std::string, boost::filesystem::path > subdirectories)
 Creates an ordered list of all subdirectories. More...
 
static void readDirectory (boost::filesystem::path directory, std::vector< std::string > extensions, std::multimap< std::string, boost::filesystem::path > &files, std::string prefix="", std::string suffix="", std::vector< std::string > exclude=std::vector< std::string >{})
 Creates an ordered multimap of all files in the given directory. More...
 
static void readDirectory (boost::filesystem::path directory, std::multimap< std::string, boost::filesystem::path > &files, std::string prefix="", std::string suffix="")
 Creates an ordered multimap of all files in the given directory. More...
 
static void getImageExtensions (std::vector< std::string > &extensions)
 Gets a vector containing common extensions for images. More...
 
static void getTxtExtensions (std::vector< std::string > &extensions)
 Gets a vector containing common extensions for text files. More...
 
static void getCSVExtensions (std::vector< std::string > &extensions)
 Get a vector of common CSV extensions. More...
 

Detailed Description

I/O utilities.

Author
David Stutz

Member Function Documentation

void IOUtil::getCSVExtensions ( std::vector< std::string > &  extensions)
static

Get a vector of common CSV extensions.

Parameters
[out]extensionscsv exnteions
void IOUtil::getImageExtensions ( std::vector< std::string > &  extensions)
static

Gets a vector containing common extensions for images.

Parameters
[out]extensionsimage extensions
void IOUtil::getTxtExtensions ( std::vector< std::string > &  extensions)
static

Gets a vector containing common extensions for text files.

Parameters
[out]extensionstxt extensions
void IOUtil::listSubdirectories ( boost::filesystem::path  directory,
std::multimap< std::string, boost::filesystem::path >  subdirectories 
)
static

Creates an ordered list of all subdirectories.

Parameters
[in]directorydirectory to find subdirectories in
[out]subdirectoresmultimap of subdirectories found
int IOUtil::readCSVHeaderString ( boost::filesystem::path  file,
std::vector< std::string > &  header 
)
static

Read header of CSV file into string array.

Parameters
[in]filepath to file
[out]headerheader strings as vector
int IOUtil::readCSVSummary ( boost::filesystem::path  file,
std::vector< std::string > &  row_headers,
std::vector< std::string > &  col_headers,
cv::Mat &  data 
)
static

Read a CSV summary file as produced by EvaluationSummary.

Parameters
[in]filepath to summary file
[out]row_headersrow names (i.e. first column)
[out]col_headerscolumn names (i.e. first row)
[out]datadata corresponding to the inner of the CSV file
void IOUtil::readDirectory ( boost::filesystem::path  directory,
std::vector< std::string >  extensions,
std::multimap< std::string, boost::filesystem::path > &  files,
std::string  prefix = "",
std::string  suffix = "",
std::vector< std::string >  exclude = std::vector<std::string>{} 
)
static

Creates an ordered multimap of all files in the given directory.

Files must match one of the given extensions.

Parameters
[in]directorydirectory to read
[in]extensionsextensions to allow
[out]filesfiles found in the directory
[in]prefixprefix to allow for files
[in]suffixsuffix to allow for files
[in]excludefile names to exclude
void IOUtil::readDirectory ( boost::filesystem::path  directory,
std::multimap< std::string, boost::filesystem::path > &  files,
std::string  prefix = "",
std::string  suffix = "" 
)
static

Creates an ordered multimap of all files in the given directory.

Parameters
[in]directorydirectory to read
[out]filesfiles found in the directory
[in]prefixprefix to allow for files
[in]suffixsuffix to allow for files
int IOUtil::readMat ( boost::filesystem::path  file,
cv::Mat &  mat,
std::string  field = "mat" 
)
static

Read an OpenCV matrix.

Parameters
[in]filepath to file to read
[out]matmatrix read
[in]fieldthe field the matrix was saved in, default is "mat"
Returns
number of rows read

Copyright (c) 2016, David Stutz Contact: david.nosp@m..stu.nosp@m.tz@rw.nosp@m.th-a.nosp@m.achen.nosp@m..de, davidstutz.de All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

int IOUtil::readMatCSVFloat ( boost::filesystem::path  file,
cv::Mat &  result 
)
static

Read CSV file into matrix.

Parameters
[in]filepath to file
[out]resultmatrix read
Returns
number of rows read
int IOUtil::readMatCSVInt ( boost::filesystem::path  file,
cv::Mat &  result 
)
static

Read CSV file into matrix.

Parameters
[in]filepath to file
[out]resultmatrix read
Returns
number of rows read
static int IOUtil::readMatCSVInt ( boost::filesystem::path  file,
int  rows,
int  cols,
cv::Mat &  result 
)
static

Read CSV file into matrix.

Parameters
[in]filepath to file
[in]rowsnumber of rows to read
[in]colsnumber of cols to read
[out]resultmatrix read
Returns
number of rows read
template<typename T >
template int IOUtil::writeArrayCSV< unsigned char > ( boost::filesystem::path  file,
T **  array,
int  rows,
int  cols,
std::string  separator = ",",
int  precision = 6 
)
static

Write two dimensional array to CSV file.

Parameters
[in]filepath to file to write
[in]arraytwo-dimenstional array holding the data
[in]rowsnumber of rows
[in]colsnumber of cols
[in]separatorseparator to use for CSV
[in]precision
Returns
number of rows read
int IOUtil::writeMat ( boost::filesystem::path  file,
const cv::Mat &  mat,
std::string  field = "mat" 
)
static

Write a matrix to the given file.

Will overwrite the file if it already exists.

Parameters
[in]filepath to file to (over-) write
[in]matmatrix to write
[in]fieldthe field the matrix was saved in, default is "mat"
Returns
number of rows written
template<typename T >
template int IOUtil::writeMatCSV< unsigned char > ( boost::filesystem::path  file,
const cv::Mat &  mat,
std::string  separator = ",",
int  precision = 6 
)
static

Write the content of a cv::Mat to a CSV file.

Only works for cv::Mats with one channel!

Parameters
[in]filepath to file to write
[in]matmatrix to write
[in]separatorseparator to use for CSV
[in]precision
Returns
number of rows read

The documentation for this class was generated from the following files: