Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

train-gecb.C File Reference


Detailed Description

Train and classify images using the context-based gist estimator.

Definition in file train-gecb.C.

#include "Neuro/GistEstimatorContextBased.H"
#include "Neuro/StdBrain.H"
#include "Neuro/NeuroOpts.H"
#include "Neuro/NeuroSimEvents.H"
#include "Media/SimFrameSeries.H"
#include "Media/MediaOpts.H"
#include "Simulation/SimEventQueue.H"
#include "Simulation/SimEventQueueConfigurator.H"
#include "Channels/ChannelOpts.H"
#include "Component/ModelManager.H"
#include "Component/ModelOptionDef.H"
#include "Image/MathOps.H"
#include "Image/MatrixOps.H"
#include "Image/Point2D.H"
#include "nub/ref.h"
#include <fstream>
#include <sstream>
#include <ios>
#include <numeric>
#include <algorithm>
#include <functional>
#include <map>
#include <vector>
#include <iterator>
#include <stdexcept>
#include <utility>

Include dependency graph for train-gecb.C:

Go to the source code of this file.

Defines

#define CV_32FC1   0
#define CV_MAT_ELEM(matrix, type, row, col)   (type(0))
#define CV_PCA_DATA_AS_COL   0
#define GECB_NUM_PRINCIPAL_COMPONENTS   80
#define GECB_DEFAULT_TRAINING_VECTORS_FILE   "gecb_training_vectors.txt"
#define GECB_DEFAULT_PCA_MATRIX_FILE   "gecb_pca_matrix.txt"
#define GECB_DEFAULT_IMAGE_NAME   "some_image"
#define GECB_DEFAULT_SEGMENT_NUMBER   "0"
#define GECB_DEFAULT_TRAINING_SET   "gecb_training_set.txt"
#define GECB_DEFAULT_TRAINING_DATABASE   "gecb_training_db.txt"
#define GECB_DEFAULT_CLASSIFICATION_RESULTS_FILE   "gecb_classifications.txt"
#define GECB_ACCUMULATE_CMD   "accumulate"
#define GECB_PCA_CMD   "pca"
#define GECB_TRAIN_CMD   "train"
#define GECB_MEANS_CMD   "means"
#define GECB_CLASSIFY_CMD   "classify"
#define GECB_ACTIONS

Typedefs

typedef Image< double > GistVector
typedef std::map< int, GistVectorTrainingDB
typedef TrainingDB::value_type TrainingDBEntry
typedef std::pair< std::string,
GistVector
InputImageData
typedef std::pair< int, double > SegmentDistance

Functions

CvMat * cvCreateMat (int, int, int)
void cvReleaseMat (CvMat **)
double cvmGet (CvMat *, int, int)
void cvmSet (CvMat *, int, int, double)
void cvmTranspose (const CvMat *, CvMat *)
int CV_MAT_TYPE (int)
void cvCalcPCA (const CvMat *, CvMat *, CvMat *, CvMat *, int)
CvMat * load_training_vectors (const std::string &file_name, int M, int N)
CvMat * pca (const OpenCVMatrix &data, int num_principal_components)
void classify_image (const InputImageData &, const TrainingDB &, const std::string &results_file)
void save (const OpenCVMatrix &, const std::string &file_name)
void append (const Image< double > &, const std::string &file_name, const std::string &image_name=std::string())
Image< double > load_image (const std::string &file_name, int width, int height)
std::ostream & operator<< (std::ostream &, const Image< double > &)
std::istream & operator>> (std::istream &, Image< double > &)
TrainingDB load_training_database (const std::string &file_name)
int count_lines (const std::string &file_name)
template<typename T>
std::string to_string (const T &)
int main ()
CvMat * load_training_vectors (const std::string &file_name, int M, int N)
CvMat * pca (const OpenCVMatrix &data, int D)
bool distance_cmp (const SegmentDistance &L, const SegmentDistance &R)
std::ostream & operator<< (std::ostream &os, const SegmentDistance &D)
void classify_image (const InputImageData &input, const TrainingDB &db, const std::string &results_file)
void save (const OpenCVMatrix &M, const std::string &file_name)
void append (const Image< double > &I, const std::string &file_name, const std::string &image_name)
Image< double > load_image (const std::string &file_name, int width, int height)
std::ostream & operator<< (std::ostream &os, const Image< double > &I)
std::istream & operator>> (std::istream &is, Image< double > &I)
TrainingDB load_training_database (const std::string &file_name)
std::string getline (std::istream &is)
template<typename T>
std::string to_string (const T &t)
int count_lines (const std::string &file_name)

Variables

std::string getline (std::istream &)
const ModelOptionCateg MOC_GECB
const ModelOptionDef OPT_TrainingVectors
const ModelOptionDef OPT_PCAMatrix
const ModelOptionDef OPT_ImageName
const ModelOptionDef OPT_SegmentNumber
const ModelOptionDef OPT_TrainingSet
const ModelOptionDef OPT_TrainingDB
const ModelOptionDef OPT_ResultsFile


Define Documentation

#define GECB_ACTIONS
 

Value:

Definition at line 394 of file train-gecb.C.


Function Documentation

template<typename T>
std::string @1::to_string const T &  t  )  [static]
 

Convenient (but perhaps not the most efficient) helper to convert various data types to strings.

DEVNOTE: Works as long as type T defines an operator << that writes to an ostream.

Definition at line 218 of file LoUtils.H.

Referenced by lobot::create_video_recorders().


Variable Documentation

const ModelOptionCateg MOC_GECB [static]
 

Initial value:

 {
   MOC_SORTPRI_3,
   "Options specific to the context-based gist program",
}

Definition at line 210 of file train-gecb.C.

const ModelOptionDef OPT_ImageName [static]
 

Initial value:

 {
   MODOPT_ARG_STRING, "ImageName", & MOC_GECB, OPTEXP_CORE,
   "This option specifies the \"root\" name of an entry in the training\n"
   "set or the results file. The image number will be automatically\n"
   "appended to this \"root\" name. The training database is a plain text\n"
   "file containing one entry per line. The first field specifies the name\n"
   "plus number of the entry (e.g., foo.1, foo.2, bar.1, and so on). The\n"
   "second field is the segment number for this image. The remaining fields\n"
   "are the 80 numbers making up the image's gist vector.\n\n"
   "In classification mode, this option specifies the name of the input\n"
   "image's gist vector that is written to the results file.\n",
   "image-name", '\0', "image-name-root",
   GECB_DEFAULT_IMAGE_NAME,
}

Definition at line 267 of file train-gecb.C.

const ModelOptionDef OPT_PCAMatrix [static]
 

Initial value:

 {
   MODOPT_ARG_STRING, "PCAMatrix", & MOC_GECB, OPTEXP_CORE,
   "This option specifies the name of the file in which the 384x80 PCA\n"
   "transformation matrix is (or will be) stored. \"Raw\" 384-dimensional\n"
   " gist vectors can be reduced to 80 dimensions by muliplying with this\n"
   "matrix. The PCA transformation matrix is stored in a plain text file\n"
   "with each line containing one row of the matrix.\n",
   "pca-matrix", '\0', "pca-matrix-file",
   GECB_DEFAULT_PCA_MATRIX_FILE,
}

Definition at line 242 of file train-gecb.C.

const ModelOptionDef OPT_ResultsFile [static]
 

Initial value:

 {
   MODOPT_ARG_STRING, "ResultsFile", & MOC_GECB, OPTEXP_CORE,
   "This option specifies the name of the classification results file,\n"
   "a plain text file containing one result entry per line. The first\n"
   "field specifies the name plus number of the input image, (e.g., foo.1,\n"
   "foo.2, bar.1, and so on). Then come the numbers of the top five matching\n"
   "segments from the training database.\n",
   "results-file", '\0', "classification-results-file",
   GECB_DEFAULT_CLASSIFICATION_RESULTS_FILE,
}

Definition at line 332 of file train-gecb.C.

const ModelOptionDef OPT_SegmentNumber [static]
 

Initial value:

 {
   MODOPT_ARG_STRING, "SegmentNumber", & MOC_GECB, OPTEXP_CORE,
   "This option specifies the segment number for an image in the training\n"
   "set. The segment number is used in the third phase of training to\n"
   "compute the mean 80-D gist vectors for each segment and during\n"
   "classification to ascertain the segment number for each input image.\n",
   "segment-number", '\0', "image-segment-number",
   GECB_DEFAULT_SEGMENT_NUMBER,
}

Definition at line 282 of file train-gecb.C.

const ModelOptionDef OPT_TrainingDB [static]
 

Initial value:

 {
   MODOPT_ARG_STRING, "TrainingDB", & MOC_GECB, OPTEXP_CORE,
   "This option specifies the name of the training database, a plain text\n"
   "file containing one entry per line. The first field specifies the\n"
   "segment number. And the remaining fields are the 80 numbers that make\n"
   "up the segment's mean gist vector.\n",
   "training-db", '\0', "training-db-file",
   GECB_DEFAULT_TRAINING_DATABASE,
}

Definition at line 316 of file train-gecb.C.

const ModelOptionDef OPT_TrainingSet [static]
 

Initial value:

 {
   MODOPT_ARG_STRING, "TrainingSet", & MOC_GECB, OPTEXP_CORE,
   "This option specifies the name of the training set, a plain text\n"
   "file containing one entry per line. The first field specifies the name\n"
   "plus number of the entry (e.g., foo.1, foo.2, bar.1, and so on). The\n"
   "second field is the segment number for this image. And the remaining\n"
   "fields are the 80 numbers that make up the image's gist vector.\n",
   "training-set", '\0', "training-set-file",
   GECB_DEFAULT_TRAINING_SET,
}

Definition at line 299 of file train-gecb.C.

const ModelOptionDef OPT_TrainingVectors [static]
 

Initial value:

 {
   MODOPT_ARG_STRING, "TrainingVectors", & MOC_GECB, OPTEXP_CORE,
   "This option specifies the name of the file where the training vectors\n"
   "should be accumulated or read from. This is a plain text file containing\n"
   "the training vectors matrix that will be fed into the PCA procedure.\n"
   "Each line of this file will contain a row of \"raw\" (i.e., 384-\n"
   "dimensional) gist vectors. For PCA, these rows will be read in as the\n"
   "columns of the data matrix.\n",
   "training-vectors", '\0', "training-vectors-file",
   GECB_DEFAULT_TRAINING_VECTORS_FILE,
}

Definition at line 222 of file train-gecb.C.


Generated on Sun Nov 22 13:44:00 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4