Commit ad14f83b authored by dmitriy.anisimov's avatar dmitriy.anisimov

last planned large refactoring

parent 444480df
......@@ -63,7 +63,7 @@ struct AR_hmdbObj : public Object
class CV_EXPORTS AR_hmdb : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<AR_hmdb> create();
};
......
......@@ -63,7 +63,7 @@ struct AR_sportsObj : public Object
class CV_EXPORTS AR_sports : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<AR_sports> create();
};
......
......@@ -62,16 +62,18 @@ public:
Dataset() {}
virtual ~Dataset() {}
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
std::vector< Ptr<Object> >& getTrain() { return train; }
std::vector< Ptr<Object> >& getTest() { return test; }
std::vector< Ptr<Object> >& getValidation() { return validation; }
std::vector< Ptr<Object> >& getTrain(int splitNum = 0) { return train[splitNum]; }
std::vector< Ptr<Object> >& getTest(int splitNum = 0) { return test[splitNum]; }
std::vector< Ptr<Object> >& getValidation(int splitNum = 0) { return validation[splitNum]; }
int getNumSplits() const { return train.size(); }
protected:
std::vector< Ptr<Object> > train;
std::vector< Ptr<Object> > test;
std::vector< Ptr<Object> > validation;
std::vector< std::vector< Ptr<Object> > > train;
std::vector< std::vector< Ptr<Object> > > test;
std::vector< std::vector< Ptr<Object> > > validation;
};
}
......
......@@ -63,7 +63,7 @@ struct FR_lfwObj : public Object
class CV_EXPORTS FR_lfw : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<FR_lfw> create();
};
......
......@@ -80,7 +80,7 @@ struct GR_chalearnObj : public Object
class CV_EXPORTS GR_chalearn : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<GR_chalearn> create();
};
......
......@@ -102,7 +102,7 @@ struct GR_skigObj : public Object
class CV_EXPORTS GR_skig : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<GR_skig> create();
};
......
......@@ -62,7 +62,7 @@ struct HPE_parseObj : public Object
class CV_EXPORTS HPE_parse : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<HPE_parse> create();
};
......
......@@ -64,7 +64,7 @@ struct IR_affineObj : public Object
class CV_EXPORTS IR_affine : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<IR_affine> create();
};
......
......@@ -73,7 +73,7 @@ struct IR_robotObj : public Object
class CV_EXPORTS IR_robot : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<IR_robot> create();
};
......
......@@ -62,7 +62,7 @@ struct IS_bsdsObj : public Object
class CV_EXPORTS IS_bsds : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<IS_bsds> create();
};
......
......@@ -65,7 +65,7 @@ struct IS_weizmannObj : public Object
class CV_EXPORTS IS_weizmann : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<IS_weizmann> create();
};
......
......@@ -74,7 +74,7 @@ struct MSM_epflObj : public Object
class CV_EXPORTS MSM_epfl : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<MSM_epfl> create();
};
......
......@@ -65,7 +65,7 @@ struct MSM_middleburyObj : public Object
class CV_EXPORTS MSM_middlebury : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<MSM_middlebury> create();
};
......
......@@ -64,7 +64,7 @@ struct OR_imagenetObj : public Object
class CV_EXPORTS OR_imagenet : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<OR_imagenet> create();
};
......
......@@ -63,7 +63,7 @@ struct OR_sunObj : public Object
class CV_EXPORTS OR_sun : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<OR_sun> create();
};
......
......@@ -71,7 +71,7 @@ struct SLAM_kittiObj : public Object
class CV_EXPORTS SLAM_kitti : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<SLAM_kitti> create();
};
......
......@@ -71,7 +71,7 @@ struct SLAM_tumindoorObj : public Object
class CV_EXPORTS SLAM_tumindoor : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<SLAM_tumindoor> create();
};
......
......@@ -63,7 +63,7 @@ struct TR_charsObj : public Object
class CV_EXPORTS TR_chars : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<TR_chars> create();
};
......
......@@ -70,7 +70,7 @@ struct TR_svtObj : public Object
class CV_EXPORTS TR_svt : public Dataset
{
public:
virtual void load(const std::string &path, int number = 0) = 0;
virtual void load(const std::string &path) = 0;
static Ptr<TR_svt> create();
};
......
......@@ -65,18 +65,14 @@ int main(int argc, char *argv[])
return -1;
}
Ptr<AR_hmdb> dataset[3];
for (int i=0; i<3; ++i)
{
dataset[i] = AR_hmdb::create();
dataset[i]->load(path, i);
}
Ptr<AR_hmdb> dataset = AR_hmdb::create();
dataset->load(path);
// ***************
// dataset contains for each split: a set of video file names for each action.
// For example, let output all training video file names for second split and first action.
// And its size.
AR_hmdbObj *example = static_cast<AR_hmdbObj *>(dataset[1]->getTrain()[0].get());
AR_hmdbObj *example = static_cast<AR_hmdbObj *>(dataset->getTrain()[0].get());
printf("name: %s\n", example->name.c_str());
vector<string> &videoNames = example->videoNames;
printf("size: %u\n", (unsigned int)videoNames.size());
......
......@@ -66,26 +66,19 @@ int main(int argc, char *argv[])
return -1;
}
vector< Ptr<TR_chars> > dataset;
do
{
Ptr<TR_chars> curr = TR_chars::create();
dataset.push_back(curr);
int number = (int)dataset.size()-1;
dataset.back()->load(path, number);
} while (dataset.back()->getTrain().size()>0);
dataset.pop_back(); // remove last empty split
Ptr<TR_chars> dataset = TR_chars::create();
dataset->load(path);
// ***************
// dataset. train, test contain information about each element of appropriate sets and splits.
// For example, let output first elements of these vectors and their sizes for last split.
// And number of splits.
printf("splits number: %u\n", (unsigned int)dataset.size());
int numSplits = dataset->getNumSplits();
printf("splits number: %u\n", numSplits);
vector< Ptr<Object> > &currTrain = dataset.back()->getTrain();
vector< Ptr<Object> > &currTest = dataset.back()->getTest();
vector< Ptr<Object> > &currValidation = dataset.back()->getValidation();
vector< Ptr<Object> > &currTrain = dataset->getTrain(numSplits-1);
vector< Ptr<Object> > &currTest = dataset->getTest(numSplits-1);
vector< Ptr<Object> > &currValidation = dataset->getValidation(numSplits-1);
printf("train size: %u\n", (unsigned int)currTrain.size());
printf("test size: %u\n", (unsigned int)currTest.size());
printf("validation size: %u\n", (unsigned int)currValidation.size());
......
......@@ -53,15 +53,17 @@ class CV_EXPORTS AR_hmdbImp : public AR_hmdb
{
public:
AR_hmdbImp() {}
//AR_hmdbImp(const std::string &path, int number = 0);
//AR_hmdbImp(const string &path, int number = 0);
virtual ~AR_hmdbImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path, int number = 0);
void loadDatasetSplit(const string &path, int number = 0);
void loadAction(const std::string &fileName, std::vector<std::string> &train_, std::vector<std::string> &test_);
void loadDataset(const string &path);
void loadAction(const string &fileName, vector<string> &train_, vector<string> &test_);
};
void AR_hmdbImp::loadAction(const string &fileName, vector<string> &train_, vector<string> &test_)
......@@ -86,12 +88,20 @@ void AR_hmdbImp::loadAction(const string &fileName, vector<string> &train_, vect
loadDataset(path, number);
}*/
void AR_hmdbImp::load(const string &path, int number)
void AR_hmdbImp::load(const string &path)
{
loadDataset(path, number);
loadDataset(path);
}
void AR_hmdbImp::loadDataset(const string &path)
{
for (int i=0; i<3; ++i)
{
loadDatasetSplit(path, i);
}
}
void AR_hmdbImp::loadDataset(const string &path, int number)
void AR_hmdbImp::loadDatasetSplit(const string &path, int number)
{
// valid number [0,1,2]
if (number<0 || number>2)
......@@ -99,6 +109,10 @@ void AR_hmdbImp::loadDataset(const string &path, int number)
return;
}
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string pathDataset(path + "hmdb51_org/");
string pathSplit(path + "testTrainMulti_7030_splits/");
......@@ -111,8 +125,8 @@ void AR_hmdbImp::loadDataset(const string &path, int number)
currTrain->name = *it;
currTest->name = *it;
train.push_back(currTrain);
test.push_back(currTest);
train.back().push_back(currTrain);
test.back().push_back(currTest);
char tmp[2];
sprintf(tmp, "%u", number+1);
......
......@@ -53,15 +53,15 @@ class CV_EXPORTS AR_sportsImp : public AR_sports
{
public:
AR_sportsImp() {}
//AR_sportsImp(const std::string &path);
//AR_sportsImp(const string &path);
virtual ~AR_sportsImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
void loadDatasetPart(const std::string &fileName, std::vector< Ptr<Object> > &dataset_);
void loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_);
};
void AR_sportsImp::loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_)
......@@ -89,26 +89,25 @@ void AR_sportsImp::loadDatasetPart(const string &fileName, vector< Ptr<Object> >
loadDataset(path);
}*/
void AR_sportsImp::load(const string &path, int number)
void AR_sportsImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void AR_sportsImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string trainPath(path + "original/train_partition.txt");
string testPath(path + "original/test_partition.txt");
// loading train video urls & labels
loadDatasetPart(trainPath, train);
loadDatasetPart(trainPath, train.back());
// loading test video urls & labels
loadDatasetPart(testPath, test);
loadDatasetPart(testPath, test.back());
}
Ptr<AR_sports> AR_sports::create()
......
......@@ -53,13 +53,13 @@ class CV_EXPORTS FR_lfwImp : public FR_lfw
{
public:
FR_lfwImp() {}
//FR_lfwImp(const std::string &path);
//FR_lfwImp(const string &path);
virtual ~FR_lfwImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*FR_lfwImp::FR_lfwImp(const string &path)
......@@ -67,18 +67,17 @@ private:
loadDataset(path);
}*/
void FR_lfwImp::load(const string &path, int number)
void FR_lfwImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void FR_lfwImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
......@@ -94,7 +93,7 @@ void FR_lfwImp::loadDataset(const string &path)
curr->images.push_back(*itFace);
}
train.push_back(curr);
train.back().push_back(curr);
}
}
......
......@@ -53,15 +53,15 @@ class CV_EXPORTS GR_chalearnImp : public GR_chalearn
{
public:
GR_chalearnImp() {}
//GR_chalearnImp(const std::string &path);
//GR_chalearnImp(const string &path);
virtual ~GR_chalearnImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
void loadDatasetPart(const std::string &path, std::vector< Ptr<Object> > &dataset_, bool loadLabels);
void loadDatasetPart(const string &path, vector< Ptr<Object> > &dataset_, bool loadLabels);
};
/*GR_chalearnImp::GR_chalearnImp(const string &path)
......@@ -69,13 +69,8 @@ private:
loadDataset(path);
}*/
void GR_chalearnImp::load(const string &path, int number)
void GR_chalearnImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
......@@ -153,12 +148,16 @@ void GR_chalearnImp::loadDatasetPart(const string &path, vector< Ptr<Object> > &
void GR_chalearnImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string pathTrain(path + "Train/");
loadDatasetPart(pathTrain, train, true);
loadDatasetPart(pathTrain, train.back(), true);
// freely available validation set doesn't have labels
string pathValidation(path + "Validation/");
loadDatasetPart(pathValidation, validation, false);
loadDatasetPart(pathValidation, validation.back(), false);
}
Ptr<GR_chalearn> GR_chalearn::create()
......
......@@ -55,13 +55,13 @@ class CV_EXPORTS GR_skigImp : public GR_skig
{
public:
GR_skigImp() {}
//GR_skigImp(const std::string &path);
//GR_skigImp(const string &path);
virtual ~GR_skigImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*GR_skigImp::GR_skigImp(const string &path)
......@@ -69,18 +69,17 @@ private:
loadDataset(path);
}*/
void GR_skigImp::load(const string &path, int number)
void GR_skigImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void GR_skigImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
for (unsigned int i=1; i<=6; ++i)
{
char number[2];
......@@ -117,7 +116,7 @@ void GR_skigImp::loadDataset(const string &path)
curr->pose = (poseType)atoi( file.substr(posPose + strlen("pose_"), 1).c_str() );
curr->type = (actionType)atoi( file.substr(posType + strlen("actionType_"), 2).c_str() );
train.push_back(curr);
train.back().push_back(curr);
} else
{
printf("incorrect file name: %s", file.c_str());
......
......@@ -53,13 +53,13 @@ class CV_EXPORTS HPE_parseImp : public HPE_parse
{
public:
HPE_parseImp() {}
//HPE_parseImp(const std::string &path);
//HPE_parseImp(const string &path);
virtual ~HPE_parseImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*HPE_parseImp::HPE_parseImp(const string &path)
......@@ -67,18 +67,17 @@ private:
loadDataset(path);
}*/
void HPE_parseImp::load(const string &path, int number)
void HPE_parseImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void HPE_parseImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
unsigned int i=0;
vector<string> fileNames;
getDirList(path, fileNames);
......@@ -97,10 +96,10 @@ void HPE_parseImp::loadDataset(const string &path)
if (i<100)
{
train.push_back(curr);
train.back().push_back(curr);
} else
{
test.push_back(curr);
test.back().push_back(curr);
}
++i;
}
......
......@@ -53,13 +53,13 @@ class CV_EXPORTS IR_affineImp : public IR_affine
{
public:
IR_affineImp() {}
//IR_affineImp(const std::string &path);
//IR_affineImp(const string &path);
virtual ~IR_affineImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*IR_affineImp::IR_affineImp(const string &path)
......@@ -67,18 +67,17 @@ private:
loadDataset(path);
}*/
void IR_affineImp::load(const string &path, int number)
void IR_affineImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void IR_affineImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
for (unsigned int i=1; i<=6; ++i)
{
Ptr<IR_affineObj> curr(new IR_affineObj);
......@@ -100,7 +99,7 @@ void IR_affineImp::loadDataset(const string &path)
}
}
train.push_back(curr);
train.back().push_back(curr);
}
}
......
......@@ -53,13 +53,13 @@ class CV_EXPORTS IR_robotImp : public IR_robot
{
public:
IR_robotImp() {}
//IR_robotImp(const std::string &path);
//IR_robotImp(const string &path);
virtual ~IR_robotImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*IR_robotImp::IR_robotImp(const string &path)
......@@ -67,18 +67,17 @@ private:
loadDataset(path);
}*/
void IR_robotImp::load(const string &path, int number)
void IR_robotImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void IR_robotImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
......@@ -95,7 +94,7 @@ void IR_robotImp::loadDataset(const string &path)
string &fileName = *itScene;
int imageNum = atoi( fileName.substr(3, 3).c_str() );
int pos = atoi( fileName.substr(6, 2).c_str() );
//int pos = atoi( fileName.substr(6, 2).c_str() );
if (imageNum != currImageNum)
{
curr->pos.push_back(cameraPos());
......@@ -105,7 +104,7 @@ void IR_robotImp::loadDataset(const string &path)
curr->pos.back().images.push_back(fileName);
}
train.push_back(curr);
train.back().push_back(curr);
}
}
......
......@@ -53,15 +53,15 @@ class CV_EXPORTS IS_bsdsImp : public IS_bsds
{
public:
IS_bsdsImp() {}
//IS_bsdsImp(const std::string &path);
//IS_bsdsImp(const string &path);
virtual ~IS_bsdsImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
void loadDatasetPart(const std::string &fileName, std::vector< Ptr<Object> > &dataset_);
void loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_);
};
void IS_bsdsImp::loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_)
......@@ -81,26 +81,25 @@ void IS_bsdsImp::loadDatasetPart(const string &fileName, vector< Ptr<Object> > &
loadDataset(path);
}*/
void IS_bsdsImp::load(const string &path, int number)
void IS_bsdsImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void IS_bsdsImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string trainName(path + "iids_train.txt");
string testName(path + "iids_test.txt");
// loading train
loadDatasetPart(trainName, train);
loadDatasetPart(trainName, train.back());
// loading test
loadDatasetPart(testName, test);
loadDatasetPart(testName, test.back());
}
Ptr<IS_bsds> IS_bsds::create()
......
......@@ -53,13 +53,13 @@ class CV_EXPORTS IS_weizmannImp : public IS_weizmann
{
public:
IS_weizmannImp() {}
//IS_weizmannImp(const std::string &path);
//IS_weizmannImp(const string &path);
virtual ~IS_weizmannImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*IS_weizmannImp::IS_weizmannImp(const string &path)
......@@ -67,18 +67,17 @@ private:
loadDataset(path);
}*/
void IS_weizmannImp::load(const string &path, int number)
void IS_weizmannImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void IS_weizmannImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
vector<string> fileNames;
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
......@@ -93,7 +92,7 @@ void IS_weizmannImp::loadDataset(const string &path)
curr->humanSeg = imageName + "human_seg/";
train.push_back(curr);
train.back().push_back(curr);
}
}
}
......
......@@ -53,13 +53,13 @@ class CV_EXPORTS MSM_epflImp : public MSM_epfl
{
public:
MSM_epflImp() {}
//MSM_epflImp(const std::string &path);
//MSM_epflImp(const string &path);
virtual ~MSM_epflImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*MSM_epflImp::MSM_epflImp(const string &path)
......@@ -67,18 +67,17 @@ private:
loadDataset(path);
}*/
void MSM_epflImp::load(const string &path, int number)
void MSM_epflImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void MSM_epflImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string pathBounding(path + "bounding/");
string pathCamera(path + "camera/");
string pathP(path + "P/");
......@@ -144,7 +143,7 @@ void MSM_epflImp::loadDataset(const string &path)
}
}
train.push_back(curr);
train.back().push_back(curr);
}
}
......
......@@ -53,13 +53,13 @@ class CV_EXPORTS MSM_middleburyImp : public MSM_middlebury
{
public:
MSM_middleburyImp() {}
//MSM_middleburyImp(const std::string &path);
//MSM_middleburyImp(const string &path);
virtual ~MSM_middleburyImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*MSM_middleburyImp::MSM_middleburyImp(const string &path)
......@@ -67,18 +67,17 @@ private:
loadDataset(path);
}*/
void MSM_middleburyImp::load(const string &path, int number)
void MSM_middleburyImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void MSM_middleburyImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string name(path.substr(0, path.length()-1));
size_t start = name.rfind('/');
name = name.substr(start+1, name.length()-start);
......@@ -113,7 +112,7 @@ void MSM_middleburyImp::loadDataset(const string &path)
infile >> curr->t[i];
}
train.push_back(curr);
train.back().push_back(curr);
}
}
......
......@@ -53,13 +53,13 @@ class CV_EXPORTS OR_imagenetImp : public OR_imagenet
{
public:
OR_imagenetImp() {}
//OR_imagenetImp(const std::string &path);
//OR_imagenetImp(const string &path);
virtual ~OR_imagenetImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*OR_imagenetImp::OR_imagenetImp(const string &path)
......@@ -67,18 +67,17 @@ private:
loadDataset(path);
}*/
void OR_imagenetImp::load(const string &path, int number)
void OR_imagenetImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void OR_imagenetImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
ifstream infile((path + "fall11_urls.txt").c_str());
string line;
while (getline(infile, line))
......@@ -96,7 +95,7 @@ void OR_imagenetImp::loadDataset(const string &path)
curr->wnid = elems[0];
curr->id2 = atoi(elems[1].c_str());
train.push_back(curr);
train.back().push_back(curr);
}
}
......
......@@ -53,13 +53,13 @@ class CV_EXPORTS OR_sunImp : public OR_sun
{
public:
OR_sunImp() {}
//OR_sunImp(const std::string &path);
//OR_sunImp(const string &path);
virtual ~OR_sunImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*OR_sunImp::OR_sunImp(const string &path)
......@@ -67,18 +67,17 @@ private:
loadDataset(path);
}*/
void OR_sunImp::load(const string &path, int number)
void OR_sunImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void OR_sunImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string classNameFile(path + "ClassName.txt");
ifstream infile(classNameFile.c_str());
string line;
......@@ -95,7 +94,7 @@ void OR_sunImp::loadDataset(const string &path)
curr->imageNames.push_back(*it);
}
train.push_back(curr);
train.back().push_back(curr);
}
}
......
......@@ -53,13 +53,13 @@ class CV_EXPORTS SLAM_kittiImp : public SLAM_kitti
{
public:
SLAM_kittiImp() {}
//SLAM_kittiImp(const std::string &path);
//SLAM_kittiImp(const string &path);
virtual ~SLAM_kittiImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*SLAM_kittiImp::SLAM_kittiImp(const string &path)
......@@ -67,18 +67,17 @@ private:
loadDataset(path);
}*/
void SLAM_kittiImp::load(const string &path, int number)
void SLAM_kittiImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void SLAM_kittiImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string pathSequence(path + "sequences/");
vector<string> fileNames;
getDirList(pathSequence, fileNames);
......@@ -155,7 +154,7 @@ void SLAM_kittiImp::loadDataset(const string &path)
curr->posesArray.push_back(p);
}
train.push_back(curr);
train.back().push_back(curr);
}
}
......
......@@ -55,13 +55,13 @@ class CV_EXPORTS SLAM_tumindoorImp : public SLAM_tumindoor
{
public:
SLAM_tumindoorImp() {}
//SLAM_tumindoorImp(const std::string &path);
//SLAM_tumindoorImp(const string &path);
virtual ~SLAM_tumindoorImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
};
/*SLAM_tumindoorImp::SLAM_tumindoorImp(const string &path)
......@@ -69,18 +69,17 @@ private:
loadDataset(path);
}*/
void SLAM_tumindoorImp::load(const string &path, int number)
void SLAM_tumindoorImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void SLAM_tumindoorImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string infoPath(path + "info/");
// get info map name, .csv should be only one such file in folder
......@@ -138,7 +137,7 @@ void SLAM_tumindoorImp::loadDataset(const string &path)
}
}
train.push_back(curr);
train.back().push_back(curr);
}
}
......
......@@ -56,10 +56,12 @@ public:
//TR_charsImp(const string &path, int number = 0);
virtual ~TR_charsImp() {}
virtual void load(const string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const string &path, int number = 0);
void loadDatasetSplit(const string &path, int number);
void loadDataset(const string &path);
void parseLine(const string &line, vector<int> &currSet, int number);
......@@ -84,7 +86,7 @@ void TR_charsImp::parseLine(const string &line, vector<int> &currSet, int number
}
}
inline void TR_charsImp::convert(vector<int> &from, std::vector< Ptr<Object> > &to, vector<int> &allLabels, vector<string> &allNames)
inline void TR_charsImp::convert(vector<int> &from, vector< Ptr<Object> > &to, vector<int> &allLabels, vector<string> &allNames)
{
for (vector<int>::iterator it=from.begin(); it!=from.end(); ++it)
{
......@@ -121,13 +123,31 @@ inline void TR_charsImp::parseSet(const string &line, const string &pattern, boo
loadDataset(path, number);
}*/
void TR_charsImp::load(const string &path, int number)
void TR_charsImp::load(const string &path)
{
loadDataset(path, number);
loadDataset(path);
}
void TR_charsImp::loadDataset(const string &path)
{
int number = 0;
do
{
loadDatasetSplit(path, number);
number++;
} while (train.back().size()>0);
train.pop_back(); // remove last empty split
test.pop_back(); // remove last empty split
validation.pop_back(); // remove last empty split
}
void TR_charsImp::loadDataset(const string &path, int number)
void TR_charsImp::loadDatasetSplit(const string &path, int number)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
vector<int> allLabels, trainSet, testSet, validationSet;
vector<string> allNames;
......@@ -189,9 +209,9 @@ void TR_charsImp::loadDataset(const string &path, int number)
"list.TXNind = ["*/
}
convert(trainSet, train, allLabels, allNames);
convert(testSet, test, allLabels, allNames);
convert(validationSet, validation, allLabels, allNames);
convert(trainSet, train.back(), allLabels, allNames);
convert(testSet, test.back(), allLabels, allNames);
convert(validationSet, validation.back(), allLabels, allNames);
}
Ptr<TR_chars> TR_chars::create()
......
......@@ -56,15 +56,15 @@ class CV_EXPORTS TR_svtImp : public TR_svt
{
public:
TR_svtImp() {}
//TR_svtImp(const std::string &path);
//TR_svtImp(const string &path);
virtual ~TR_svtImp() {}
virtual void load(const std::string &path, int number = 0);
virtual void load(const string &path);
private:
void loadDataset(const std::string &path);
void loadDataset(const string &path);
void xmlParse(const std::string &set, std::vector< Ptr<Object> > &out);
void xmlParse(const string &set, vector< Ptr<Object> > &out);
};
void TR_svtImp::xmlParse(const string &set, vector< Ptr<Object> > &out)
......@@ -117,26 +117,25 @@ void TR_svtImp::xmlParse(const string &set, vector< Ptr<Object> > &out)
loadDataset(path);
}*/
void TR_svtImp::load(const string &path, int number)
void TR_svtImp::load(const string &path)
{
if (number!=0)
{
return;
}
loadDataset(path);
}
void TR_svtImp::loadDataset(const string &path)
{
train.push_back(vector< Ptr<Object> >());
test.push_back(vector< Ptr<Object> >());
validation.push_back(vector< Ptr<Object> >());
string trainXml(path + "train.xml");
string testXml(path + "test.xml");
// loading train images description
xmlParse(trainXml, train);
xmlParse(trainXml, train.back());
// loading test images description
xmlParse(testXml, test);
xmlParse(testXml, test.back());
}
Ptr<TR_svt> TR_svt::create()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment