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