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

Tool to guide parameter optimization using grid search. More...

#include <parameter_optimization_tool.h>

Public Member Functions

 ParameterOptimizationTool (boost::filesystem::path img_directory, boost::filesystem::path gt_directory, boost::filesystem::path base_directory, std::string command_line, std::string command_line_parameters)
 Constructor. More...
 
void addPostProcessingCommandLine (std::string command_line)
 Add post-processing script (e.g. boundaries to segmentation conversion) which is applied on the CSV segmentation output of the algorithms. More...
 
void addSuperpixelTolerance (int superpixels, int tolerance)
 Some algorithms do not allow to control superpixels, therefore, optimization may aim for a specific range of superpixel numbers. More...
 
void addFloatParameter (std::string name, std::string parameter, std::vector< float > values)
 Add float parameter to optimize. More...
 
void addIntegerParameter (std::string name, std::string parameter, std::vector< int > values)
 Add integer parameter to optimize. More...
 
void useDepth (boost::filesystem::path depth_directory)
 Use depth as additional cue. More...
 
void useIntrinsics (boost::filesystem::path intrinsics_directory)
 Use intrinsic parameters from given directory for depth. More...
 
void setVerbose (std::ostream &stream=std::cout)
 Set parameter optimization verbose. Per default output is written to std::cout. More...
 
int numCombinations ()
 Count parameter combinations. More...
 
void optimize (float weigh=0.5, float weight_ue=0.33, float weight_co=0.33)
 Jointly optimize for Boundary Recall and Undersegmentation Error. More...
 

Static Public Attributes

static const int FLOAT_PARAMETER = 1
 Constant to indicate a float parameter. More...
 
static const int INTEGER_PARAMETER = 2
 Constant to indicate an integer parameter. More...
 

Protected Member Functions

void cleanUp (const boost::filesystem::path &sp_directory)
 Removes all unnecessary CSV files in base folder. More...
 

Protected Attributes

std::string command_line
 The command used to runt he algorithm. More...
 
std::string command_line_parameters
 Command line parameters always to append. More...
 
std::string post_processing_command_line
 Command to use for post-processing. More...
 
boost::filesystem::path img_directory
 Directory containing the images. More...
 
boost::filesystem::path gt_directory
 Directory containing the ground truth segmentations. More...
 
boost::filesystem::path depth_directory
 Directory containing the depth images. More...
 
boost::filesystem::path intrinsics_directory
 Directory containing the intrinsic parameters for each image. More...
 
boost::filesystem::path base_directory
 Base directory to optimize parameters in and put temporary files. More...
 
EvaluationSummary::EvaluationMetrics evaluation_metrics
 Evaluation metrics to use. More...
 
EvaluationSummary::EvaluationStatistics evaluation_statistics
 Evaluation statistics to use. More...
 
std::vector< std::tuple< std::string, std::string, int, int > > parameters
 The parameters, with name, command line parameter, type and index in the respective vector. More...
 
std::vector< std::tuple< std::vector< int >, int, int, int > > integer_parameters
 Vector containing all integer parameters. More...
 
std::vector< std::tuple< std::vector< float >, int, float, float > > float_parameters
 Vector containing all float parameters. More...
 
int superpixels_min
 Minimum number of superpixels. More...
 
int superpixels_max
 

Detailed Description

Tool to guide parameter optimization using grid search.

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.

Author
David Stutz

Constructor & Destructor Documentation

ParameterOptimizationTool::ParameterOptimizationTool ( boost::filesystem::path  img_directory,
boost::filesystem::path  gt_directory,
boost::filesystem::path  base_directory,
std::string  command_line,
std::string  command_line_parameters 
)

Constructor.

The command line tool to use has to provide several options, including -i to specify the input directory, -o to specify the CV output directory, -d for depth directory. See README.md for details.

Parameters
[in]img_directorydirectory containing the images
[in]gt_directorydirectories containing the ground truth segmentations
[in]base_directorybase directory to operate in, i.e. save superpixel labels and summaries
[in]command_linecommand to use to run the algorithm to optimize prameters for
[in]command_line_parameterscommand line parameters to use with each run.

Member Function Documentation

void ParameterOptimizationTool::addFloatParameter ( std::string  name,
std::string  parameter,
std::vector< float >  values 
)

Add float parameter to optimize.

Parameters
[in]namename of the parameter
[in]parameterparameter for the command line
[in]valuesvector of values to consider
void ParameterOptimizationTool::addIntegerParameter ( std::string  name,
std::string  parameter,
std::vector< int >  values 
)

Add integer parameter to optimize.

Parameters
[in]namename of the parameter
[in]parameterparameter for the command line
[in]valuesvector of values to consider
void ParameterOptimizationTool::addPostProcessingCommandLine ( std::string  command_line)

Add post-processing script (e.g. boundaries to segmentation conversion) which is applied on the CSV segmentation output of the algorithms.

Parameters
[in]command_linecommand used for post processing, it is called with -i for the superpixel labels directory and -m for the image directory
void ParameterOptimizationTool::addSuperpixelTolerance ( int  superpixels,
int  tolerance 
)

Some algorithms do not allow to control superpixels, therefore, optimization may aim for a specific range of superpixel numbers.

Parameters
[in]superpixelsdesired number of superpixels
[in]tolerancenumber of superpixels we allow to deviate from the desired number
void ParameterOptimizationTool::cleanUp ( const boost::filesystem::path &  sp_directory)
protected

Removes all unnecessary CSV files in base folder.

Parameters
[in]so_directoryclean up the directory containing the superpixel labels
int ParameterOptimizationTool::numCombinations ( )

Count parameter combinations.

Returns
the number of combinations of all parameter values
void ParameterOptimizationTool::optimize ( float  weigh = 0.5,
float  weight_ue = 0.33,
float  weight_co = 0.33 
)

Jointly optimize for Boundary Recall and Undersegmentation Error.

Parameters
[in]weightweight between boundary recall and undersegmentation error
[in]weight_uealternative (secondary) optimization weight for undersegmentation error
[in]weight_coalternative (secondary) optimization weight for compactness
void ParameterOptimizationTool::setVerbose ( std::ostream &  stream = std::cout)

Set parameter optimization verbose. Per default output is written to std::cout.

Parameters
[in]streamstream to output to
void ParameterOptimizationTool::useDepth ( boost::filesystem::path  depth_directory)

Use depth as additional cue.

Parameters
[in]depth_directorydirectory containing depth files
void ParameterOptimizationTool::useIntrinsics ( boost::filesystem::path  intrinsics_directory)

Use intrinsic parameters from given directory for depth.

Parameters
[in]intrinsics_directorydirectory containing the intrinsic parameters of each image

Member Data Documentation

boost::filesystem::path ParameterOptimizationTool::base_directory
protected

Base directory to optimize parameters in and put temporary files.

std::string ParameterOptimizationTool::command_line
protected

The command used to runt he algorithm.

std::string ParameterOptimizationTool::command_line_parameters
protected

Command line parameters always to append.

boost::filesystem::path ParameterOptimizationTool::depth_directory
protected

Directory containing the depth images.

EvaluationSummary::EvaluationMetrics ParameterOptimizationTool::evaluation_metrics
protected

Evaluation metrics to use.

EvaluationSummary::EvaluationStatistics ParameterOptimizationTool::evaluation_statistics
protected

Evaluation statistics to use.

const int ParameterOptimizationTool::FLOAT_PARAMETER = 1
static

Constant to indicate a float parameter.

std::vector< std::tuple<std::vector<float>, int, float, float> > ParameterOptimizationTool::float_parameters
protected

Vector containing all float parameters.

boost::filesystem::path ParameterOptimizationTool::gt_directory
protected

Directory containing the ground truth segmentations.

boost::filesystem::path ParameterOptimizationTool::img_directory
protected

Directory containing the images.

const int ParameterOptimizationTool::INTEGER_PARAMETER = 2
static

Constant to indicate an integer parameter.

std::vector< std::tuple<std::vector<int>, int, int, int> > ParameterOptimizationTool::integer_parameters
protected

Vector containing all integer parameters.

boost::filesystem::path ParameterOptimizationTool::intrinsics_directory
protected

Directory containing the intrinsic parameters for each image.

std::vector< std::tuple<std::string, std::string, int, int> > ParameterOptimizationTool::parameters
protected

The parameters, with name, command line parameter, type and index in the respective vector.

std::string ParameterOptimizationTool::post_processing_command_line
protected

Command to use for post-processing.

int ParameterOptimizationTool::superpixels_max
protected

brief Maximum number of superpixels.

int ParameterOptimizationTool::superpixels_min
protected

Minimum number of superpixels.


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