Public Member Functions | Static Public Member Functions | Friends

PatchDataset Class Reference
[Auxilliary Tools]

Auxilliary Tool: A tool for managing the data used in training GentleBoost classifiers. More...

#include <PatchDataset.h>

Collaboration diagram for PatchDataset:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PatchDataset (cv::Size patchsize, const std::string &positiveImageListFilename="", const std::string &positiveImageLabelsFilename="", const std::string &negativeImageListFilename="", int posExamplePatchRadius=0, int posExampleScaleRadius=0, int numPosPatches=-1, int numNegPatches=-1, double scale=1)
 Constructor.
 ~PatchDataset ()
 Destructor.
std::vector< ImagePatch * > getPatches ()
 Get all patches in the dataset.
std::vector< ImagePatch * > getPosPatches ()
 Get the positive patches in the dataset.
std::vector< ImagePatch * > getNegPatches ()
 Get the negative patches in the dataset.
void getLabels (cv::Mat &dest)
 Get the labels for all patches.
cv::Size getPatchSize ()
 Get the size of the patches in the dataset.
void writeToFile (const std::string &filename)
 Save the dataset in a compact, binary format for later use.
ImageDataSetgetNegImagesDataset ()
 Reconstruct the ImageDataSet object (used by other Machine Perception Primitives in NMPT) used to create the negative examples in this PatchDataset.
ImageDataSetgetPosImagesDataset ()
 Reconstruct the ImageDataSet object (used by other Machine Perception Primitives in NMPT) used to create the positive examples in this PatchDataset.
std::string getNegImagesFileName ()
 Query the name of the source file that was used to locate files containing the negative patches in this dataset.
std::string getPosImagesFileName ()
 Query the name of the source file that was used to locate files containing the positive examples in this dataset.
std::string getPosLabelsFileName ()
 Query the name of the source file that was used to locate the positive examples in their source images for this dataset.

Static Public Member Functions

static PatchDatasetreadFromFile (const std::string &filename)
 Load the dataset from a compact, binary format saved earlier.

Friends

std::istream & operator>> (std::istream &ifs, PatchDataset *dataset)
 Load from a file in a verbose, text based format.
std::ostream & operator<< (std::ostream &ifs, PatchDataset *dataset)
 Write to a file in a verbose, text based format.

Detailed Description

Auxilliary Tool: A tool for managing the data used in training GentleBoost classifiers.

The primary purpose of this class is to quickly save and load collections of pathches for training and testing classifiers. However, it is also useful for remembering the disk location of the dataset files used to construct a dataset.

Author:
Nicholas Butko
Date:
2010
Version:
0.4

Constructor & Destructor Documentation

PatchDataset::PatchDataset ( cv::Size  patchsize,
const std::string &  positiveImageListFilename = "",
const std::string &  positiveImageLabelsFilename = "",
const std::string &  negativeImageListFilename = "",
int  posExamplePatchRadius = 0,
int  posExampleScaleRadius = 0,
int  numPosPatches = -1,
int  numNegPatches = -1,
double  scale = 1 
)

Constructor.

Parameters:
patchsizeBasic size of patches to use for training. When constructing a PatchDataset, this must be specified. When reading a PatchDataset from an istream, any size may be initially specified, which will be subsequently overwritten.
positiveImageListFilenamePath to a file containing a list of files, one per line, that contain the object you're trying to learn to detect. If the same file contains more than one of the object, it can appear on more than one line.
positiveImageLabelsFilenamePath to a file containing the same number of lines as imageListFile, and on each line should be one label for that image. Each label consists of three doubles describing the location of an object in the respective image from positiveImageListFilename: [center-x] [center-y] [object-width].
negativeImageListFilenamePath to a file containing a list of files, one per line, of images that are known to not contain the object of interest.
posExamplePatchRadiusTake positive examples that are slightly left/right/up/down from the labeled example. This can help get a wider variety of positive examples, at the expense of memory and making the classifier harder to train. Note that a radius of 1 gives 9x the training examples, and a radius of 2 gives 25x.
posExampleScaleRadiusTake positive examples that are slightly larger or smaller than the labeled object. This size is radius is in terms of search scale, not pixels. This can help get a wider variety of positive examples, at the expense of memory and making the classifier harder to train. Note that a radius of 1 gives 3x the training examples, and a radius of 2 gives 5x.
numPosPatchesNumber of positive patches to include in the dataset. If this is less than 0 or greater than the total number of available patches, the total number of available patches is used.
numNegPatchesNumber of negative patches to include in the dataset. If this is less than 0, then a balanced dataset is created, where there are as many negative patches as positive patches.
scaleTunes the size of the object window, making it narrower or wider than indicated in the dataset by a factor of [scale]. A scale less than 1 will crop the patches smaller around the center of the object, will greater than 1 will include more of a border around the object.

Member Function Documentation

void PatchDataset::getLabels ( cv::Mat &  dest )

Get the labels for all patches.

Returns:
A vector of labels, of size Nx1, where N is the total number of patches returned by getPatches(), and the order of labels is respective to the patches returned by getPatches().
vector< ImagePatch * > PatchDataset::getNegPatches (  )

Get the negative patches in the dataset.

Returns:
The negative patches in the dataset.
vector< ImagePatch * > PatchDataset::getPatches (  )

Get all patches in the dataset.

Returns:
All patches in the dataset.
Size PatchDataset::getPatchSize (  )

Get the size of the patches in the dataset.

Returns:
The size of the image patches in the dataset.
vector< ImagePatch * > PatchDataset::getPosPatches (  )

Get the positive patches in the dataset.

Returns:
The positive in the dataset.
static PatchDataset* PatchDataset::readFromFile ( const std::string &  filename ) [static]

Load the dataset from a compact, binary format saved earlier.

Parameters:
filenamePath to the file being loaded.
Returns:
A new dataset object.
void PatchDataset::writeToFile ( const std::string &  filename )

Save the dataset in a compact, binary format for later use.

Parameters:
filenamePath to the file being saved.

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