Commit 2916f89d authored by dmitriy.anisimov's avatar dmitriy.anisimov

enhanced base class: created hierarchy for objects in train\test and moved train\test to base class

parent 5e647ff0
......@@ -54,7 +54,7 @@ namespace cv
namespace datasetstools
{
struct action
struct action : public object
{
std::string name;
std::vector<std::string> videoNames;
......@@ -69,9 +69,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<action> train;
std::vector<action> test;
private:
void loadDataset(const std::string &path, int number = 0);
......
......@@ -54,7 +54,7 @@ namespace cv
namespace datasetstools
{
struct element
struct element : public object
{
std::string videoUrl;
std::vector<int> labels;
......@@ -69,13 +69,10 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<element> train;
std::vector<element> test;
private:
void loadDataset(const std::string &path);
void loadDatasetPart(const std::string &fileName, std::vector<element> &dataset_);
void loadDatasetPart(const std::string &fileName, std::vector< Ptr<object> > &dataset_);
};
}
......
......@@ -43,6 +43,7 @@
#define OPENCV_DATASETSTOOLS_DATASET_HPP
#include <string>
#include <vector>
#include <opencv2/core.hpp>
......@@ -51,13 +52,28 @@ namespace cv
namespace datasetstools
{
struct object
{
};
enum datasetType
{
AR_HMDB,
AR_SPORTS
};
class CV_EXPORTS Dataset
{
public:
Dataset() {}
virtual ~Dataset() {}
virtual ~Dataset() {train.clear(); test.clear();}
virtual void load(const std::string &path, int number = 0) = 0;
std::vector< Ptr<object> > train;
std::vector< Ptr<object> > test;
static Ptr<Dataset> create(datasetType type);
};
}
......
......@@ -54,7 +54,7 @@ namespace cv
namespace datasetstools
{
struct face
struct face : public object
{
std::string name;
std::vector<std::string> images;
......@@ -69,7 +69,7 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<face> train;
//std::vector<face> train;
private:
void loadDataset(const std::string &path);
......
......@@ -69,7 +69,7 @@ struct skeleton
join s[20];
};
struct gesture
struct gesture : public object
{
std::string name, nameColor, nameDepth, nameUser;
int numFrames, fps, depth;
......@@ -86,8 +86,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<gesture> train;
private:
void loadDataset(const std::string &path);
};
......
......@@ -88,7 +88,7 @@ enum backgroundType
paperWithCharacters
};
struct gestureSkig
struct gestureSkig : public object
{
std::string rgb;
std::string dep;
......@@ -108,8 +108,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<gestureSkig> train;
private:
void loadDataset(const std::string &path);
};
......
......@@ -54,6 +54,11 @@ namespace cv
namespace datasetstools
{
struct objectParse : public object
{
std::string name;
};
class CV_EXPORTS HPE_parse : public Dataset
{
public:
......@@ -63,9 +68,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<std::string> train;
std::vector<std::string> test;
private:
void loadDataset(const std::string &path);
};
......
......@@ -55,7 +55,7 @@ namespace cv
namespace datasetstools
{
struct imageParams
struct imageParams : public object
{
std::string imageName;
Matx33d mat;
......@@ -70,8 +70,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<imageParams> train;
private:
void loadDataset(const std::string &path);
};
......
......@@ -59,7 +59,7 @@ namespace datasetstools
// 0.0000e+00 2.8285e+03 6.1618e+02
// 0.0000e+00 0.0000e+00 1.0000e+00
struct scene
struct scene : public object
{
std::string name;
std::vector<std::string> images; // TODO: implement more complex structure
......@@ -74,8 +74,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<scene> train;
private:
void loadDataset(const std::string &path);
};
......
......@@ -54,6 +54,11 @@ namespace cv
namespace datasetstools
{
struct objectBsds : public object
{
std::string name;
};
class CV_EXPORTS IS_bsds : public Dataset
{
public:
......@@ -63,13 +68,10 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<std::string> train;
std::vector<std::string> test;
private:
void loadDataset(const std::string &path);
void loadDatasetPart(const std::string &fileName, std::vector<std::string> &dataset_);
void loadDatasetPart(const std::string &fileName, std::vector< Ptr<object> > &dataset_);
};
}
......
......@@ -54,7 +54,7 @@ namespace cv
namespace datasetstools
{
struct object
struct objectWeizmann : public object
{
std::string imageName;
std::string srcBw;
......@@ -71,8 +71,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<object> train;
private:
void loadDataset(const std::string &path);
};
......
......@@ -54,7 +54,7 @@ namespace cv
namespace datasetstools
{
struct objectEpfl
struct objectEpfl : public object
{
std::string imageName;
std::vector<double> bounding, camera, p; // TODO: implement better structures
......@@ -69,8 +69,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<objectEpfl> train;
private:
void loadDataset(const std::string &path);
......
......@@ -54,7 +54,7 @@ namespace cv
namespace datasetstools
{
struct cameraParam
struct cameraParam : public object
{
std::string imageName;
double k[3][3];
......@@ -71,8 +71,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<cameraParam> train;
private:
void loadDataset(const std::string &path);
};
......
......@@ -55,7 +55,7 @@ namespace cv
namespace datasetstools
{
struct objectImagenet
struct objectImagenet : public object
{
std::string wnid;
int id2;
......@@ -71,7 +71,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<objectImagenet> train;
std::set<std::string> wnids;
private:
......
......@@ -54,7 +54,7 @@ namespace cv
namespace datasetstools
{
struct objectSun
struct objectSun : public object
{
std::string name;
std::vector<std::string> imageNames;
......@@ -69,8 +69,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<objectSun> train;
private:
void loadDataset(const std::string &path);
};
......
......@@ -59,7 +59,7 @@ struct pose
double elem[12];
};
struct sequence
struct sequence : public object
{
std::string name;
std::vector<std::string> images[4];
......@@ -77,8 +77,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<sequence> train;
private:
void loadDataset(const std::string &path);
};
......
......@@ -61,7 +61,7 @@ enum imageType
LADYBUG
};
struct imageInfo
struct imageInfo : public object
{
std::string name;
double transformMat[4][4];
......@@ -77,8 +77,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<imageInfo> train;
private:
void loadDataset(const std::string &path);
};
......
......@@ -54,7 +54,7 @@ namespace cv
namespace datasetstools
{
struct character
struct character : public object
{
std::string imgName;
int label;
......@@ -69,9 +69,6 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<character> train;
std::vector<character> test;
private:
void loadDataset(const std::string &path, int number = 0);
......
......@@ -60,7 +60,7 @@ struct tag
int height, width, x, y;
};
struct image
struct image : public object
{
std::string fileName;
std::vector<std::string> lex;
......@@ -76,13 +76,10 @@ public:
virtual void load(const std::string &path, int number = 0);
std::vector<image> train;
std::vector<image> test;
private:
void loadDataset(const std::string &path);
void xmlParse(const std::string &set, std::vector<image> &out);
void xmlParse(const std::string &set, std::vector< Ptr<object> > &out);
};
}
......
......@@ -74,9 +74,11 @@ int main(int argc, char *argv[])
// ***************
// 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.
action &example = dataset[1].train[0];
printf("name: %s\n", example.name.c_str());
vector<string> &videoNames = example.videoNames;
// And its size.
action *example = static_cast<action *>(dataset[1].train[0].get());
printf("name: %s\n", example->name.c_str());
vector<string> &videoNames = example->videoNames;
printf("size: %u\n", (unsigned int)videoNames.size());
for (vector<string>::iterator it=videoNames.begin(); it!=videoNames.end(); ++it)
{
printf("%s\n", (*it).c_str());
......
......@@ -75,10 +75,10 @@ int main(int argc, char *argv[])
printf("train size: %u\n", (unsigned int)dataset.train.size());
printf("test size: %u\n", (unsigned int)dataset.test.size());
element &first = dataset.test[0];
printf("url: %s\n", first.videoUrl.c_str());
element *example = static_cast<element *>(dataset.test[0].get());
printf("url: %s\n", example->videoUrl.c_str());
printf("labels: ");
vector<int> &labels = first.labels;
vector<int> &labels = example->labels;
for (vector<int>::iterator it=labels.begin(); it!=labels.end(); ++it)
{
printf("%u ", *it);
......
......@@ -71,10 +71,10 @@ int main(int argc, char *argv[])
// dataset contains object with name and its images.
// For example, let output dataset size and sixth element.
printf("dataset size: %u\n", (unsigned int)dataset.train.size());
face &example = dataset.train[5];
printf("sixth dataset object:\n%s\n", example.name.c_str());
string currPath(path + example.name + "/");
for (vector<string>::iterator it=example.images.begin(); it!=example.images.end(); ++it)
face *example = static_cast<face *>(dataset.train[5].get());
printf("sixth dataset object:\n%s\n", example->name.c_str());
string currPath(path + example->name + "/");
for (vector<string>::iterator it=example->images.begin(); it!=example->images.end(); ++it)
{
printf("%s\n", (currPath+(*it)).c_str());
}
......
......@@ -71,18 +71,18 @@ int main(int argc, char *argv[])
// dataset contains information for each sample.
// For example, let output dataset size and first element.
printf("dataset size: %u\n", (unsigned int)dataset.train.size());
gesture &example = dataset.train[0];
printf("first dataset sample:\n%s\n", example.name.c_str());
printf("color video:\n%s\n", example.nameColor .c_str());
printf("depth video:\n%s\n", example.nameDepth.c_str());
printf("user video:\n%s\n", example.nameUser.c_str());
printf("video:\nnumber of frames: %u\nfps: %u\nmaximum depth: %u\n", example.numFrames, example.fps, example.depth);
for (vector<groundTruth>::iterator it=example.groundTruths.begin(); it!=example.groundTruths.end(); ++it)
gesture *example = static_cast<gesture *>(dataset.train[0].get());
printf("first dataset sample:\n%s\n", example->name.c_str());
printf("color video:\n%s\n", example->nameColor .c_str());
printf("depth video:\n%s\n", example->nameDepth.c_str());
printf("user video:\n%s\n", example->nameUser.c_str());
printf("video:\nnumber of frames: %u\nfps: %u\nmaximum depth: %u\n", example->numFrames, example->fps, example->depth);
for (vector<groundTruth>::iterator it=example->groundTruths.begin(); it!=example->groundTruths.end(); ++it)
{
printf("gestureID: %u, initial frame: %u, last frame: %u\n", (*it).gestureID, (*it).initialFrame, (*it).lastFrame);
}
printf("skeletons number: %u\n", (unsigned int)example.skeletons.size());
skeleton &last = example.skeletons.back();
printf("skeletons number: %u\n", (unsigned int)example->skeletons.size());
skeleton &last = example->skeletons.back();
printf("last skeleton:\n");
for (unsigned int i=0; i<20; ++i)
{
......
......@@ -71,11 +71,11 @@ int main(int argc, char *argv[])
// ***************
// dataset contains pair of rgb\dep images
// For example, let output train size and second element.
gestureSkig &example = dataset.train[1];
gestureSkig *example = static_cast<gestureSkig *>(dataset.train[1].get());
printf("train size: %u\n", (unsigned int)dataset.train.size());
printf("second train image:\nrgb: %s\ndep: %s\n", example.rgb.c_str(), example.dep.c_str());
printf("second train image:\nrgb: %s\ndep: %s\n", example->rgb.c_str(), example->dep.c_str());
printf("person: %u, backgroud: %u, illumination: %u, pose: %u, actionType: %u\n",
example.person, example.background, example.illumination, example.pose, example.type);
example->person, example->background, example->illumination, example->pose, example->type);
return 0;
}
......@@ -72,8 +72,10 @@ int main(int argc, char *argv[])
// For example, let output their sizes and first elements.
printf("train size: %u\n", (unsigned int)dataset.train.size());
printf("test size: %u\n", (unsigned int)dataset.test.size());
printf("first train image: %s\n", dataset.train[0].c_str());
printf("first test image: %s\n", dataset.test[0].c_str());
objectParse *example1 = static_cast<objectParse *>(dataset.train[0].get());
objectParse *example2 = static_cast<objectParse *>(dataset.test[0].get());
printf("first train image: %s\n", example1->name.c_str());
printf("first test image: %s\n", example2->name.c_str());
return 0;
}
......@@ -75,14 +75,14 @@ int main(int argc, char *argv[])
// And dataset size.
printf("size: %u\n", (unsigned int)dataset.train.size());
imageParams &example = dataset.train.back();
printf("image name: %s\n", example.imageName.c_str());
imageParams *example = static_cast<imageParams *>(dataset.train.back().get());
printf("image name: %s\n", example->imageName.c_str());
printf("matrix:\n");
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
printf("%f ", example.mat(i, j));
printf("%f ", example->mat(i, j));
}
printf("\n");
}
......
......@@ -70,10 +70,10 @@ int main(int argc, char *argv[])
// ***************
// dataset contains object with name and its images.
// For example, let output last element and dataset size.
scene &example = dataset.train.back();
printf("last dataset object:\n%s\n", example.name.c_str());
string currPath(path + example.name + "/");
for (vector<string>::iterator it=example.images.begin(); it!=example.images.end(); ++it)
scene *example = static_cast<scene *>(dataset.train.back().get());
printf("last dataset object:\n%s\n", example->name.c_str());
string currPath(path + example->name + "/");
for (vector<string>::iterator it=example->images.begin(); it!=example->images.end(); ++it)
{
printf("%s\n", (currPath+(*it)).c_str());
}
......
......@@ -75,9 +75,12 @@ int main(int argc, char *argv[])
// And sets size.
printf("train size: %u\n", (unsigned int)dataset.train.size());
printf("test size: %u\n", (unsigned int)dataset.test.size());
string fullPath(path + "images/train/" + dataset.train[0] + ".jpg");
objectBsds *example1 = static_cast<objectBsds *>(dataset.train[0].get());
string fullPath(path + "images/train/" + example1->name + ".jpg");
printf("first train image: %s\n", fullPath.c_str());
fullPath = path + "images/test/" + dataset.test[0] + ".jpg";
objectBsds *example2 = static_cast<objectBsds *>(dataset.test[0].get());
fullPath = path + "images/test/" + example2->name + ".jpg";
printf("first test image: %s\n", fullPath.c_str());
return 0;
......
......@@ -71,9 +71,9 @@ int main(int argc, char *argv[])
// dataset contains all information for each image.
// For example, let output dataset size and first object.
printf("dataset size: %u\n", (unsigned int)dataset.train.size());
object &example = dataset.train[0];
printf("first image:\nname: %s\n", example.imageName.c_str());
printf("src bw: %s\nsrc color: %s\n", example.srcBw.c_str(), example.srcColor.c_str());
objectWeizmann *example = static_cast<objectWeizmann *>(dataset.train[0].get());
printf("first image:\nname: %s\n", example->imageName.c_str());
printf("src bw: %s\nsrc color: %s\n", example->srcBw.c_str(), example->srcColor.c_str());
return 0;
}
......@@ -71,25 +71,25 @@ int main(int argc, char *argv[])
// dataset contains all information for each image.
// For example, let output dataset size and first object.
printf("dataset size: %u\n", (unsigned int)dataset.train.size());
objectEpfl &example = dataset.train[0];
printf("first image:\nname: %s\n", example.imageName.c_str());
objectEpfl *example = static_cast<objectEpfl *>(dataset.train[0].get());
printf("first image:\nname: %s\n", example->imageName.c_str());
printf("bounding:\n");
for (vector<double>::iterator it=example.bounding.begin(); it!=example.bounding.end(); ++it)
for (vector<double>::iterator it=example->bounding.begin(); it!=example->bounding.end(); ++it)
{
printf("%f ", *it);
}
printf("\n");
printf("camera:\n");
for (vector<double>::iterator it=example.camera.begin(); it!=example.camera.end(); ++it)
for (vector<double>::iterator it=example->camera.begin(); it!=example->camera.end(); ++it)
{
printf("%f ", *it);
}
printf("\n");
printf("P:\n");
for (vector<double>::iterator it=example.p.begin(); it!=example.p.end(); ++it)
for (vector<double>::iterator it=example->p.begin(); it!=example->p.end(); ++it)
{
printf("%f ", *it);
}
......
......@@ -71,14 +71,14 @@ int main(int argc, char *argv[])
// dataset contains camera parameters for each image.
// For example, let output number of elements and last element.
printf("images number: %u\n", (unsigned int)dataset.train.size());
cameraParam &example = dataset.train.back();
printf("last image name: %s\n", (path + example.imageName).c_str());
cameraParam *example = static_cast<cameraParam *>(dataset.train.back().get());
printf("last image name: %s\n", (path + example->imageName).c_str());
printf("K:\n");
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
printf("%f ", example.k[i][j]);
printf("%f ", example->k[i][j]);
}
printf("\n");
}
......@@ -87,14 +87,14 @@ int main(int argc, char *argv[])
{
for (int j=0; j<3; ++j)
{
printf("%f ", example.r[i][j]);
printf("%f ", example->r[i][j]);
}
printf("\n");
}
printf("t:\n");
for (int i=0; i<3; ++i)
{
printf("%f ", example.t[i]);
printf("%f ", example->t[i]);
}
printf("\n");
......
......@@ -74,10 +74,10 @@ int main(int argc, char *argv[])
// For example, let output dataset size and first object.
printf("dataset size: %u\n", (unsigned int)dataset.train.size());
printf("wnids number: %u\n", (unsigned int)dataset.wnids.size());
objectImagenet &example = dataset.train[0];
printf("first object url: %s\n", example.imageUrl.c_str());
printf("first object wnid: %s\n", example.wnid.c_str());
printf("first object id2: %u\n", example.id2);
objectImagenet *example = static_cast<objectImagenet *>(dataset.train[0].get());
printf("first object url: %s\n", example->imageUrl.c_str());
printf("first object wnid: %s\n", example->wnid.c_str());
printf("first object id2: %u\n", example->id2);
return 0;
}
......@@ -71,10 +71,10 @@ int main(int argc, char *argv[])
// dataset contains for each object its images.
// For example, let output dataset size and last object.
printf("dataset size: %u\n", (unsigned int)dataset.train.size());
objectSun &example = dataset.train.back();
printf("last object name: %s\n", example.name.c_str());
printf("last object images number: %u\n", (unsigned int)example.imageNames.size());
vector<string> &imageNames = example.imageNames;
objectSun *example = static_cast<objectSun *>(dataset.train.back().get());
printf("last object name: %s\n", example->name.c_str());
printf("last object images number: %u\n", (unsigned int)example->imageNames.size());
vector<string> &imageNames = example->imageNames;
for (vector<string>::iterator it=imageNames.begin(); it!=imageNames.end(); ++it)
{
printf("%s\n", (*it).c_str());
......
......@@ -72,39 +72,39 @@ int main(int argc, char *argv[])
// For example, let output first sequence and dataset size.
printf("dataset size: %u\n", (unsigned int)dataset.train.size());
sequence &example = dataset.train[0];
printf("first dataset sequence:\n%s\n", example.name.c_str());
sequence *example = static_cast<sequence *>(dataset.train[0].get());
printf("first dataset sequence:\n%s\n", example->name.c_str());
/*string pathVelodyne(path + "sequences/" + example.name + "/velodyne/");
for (vector<string>::iterator it=example.velodyne.begin(); it!=example.velodyne.end(); ++it)
/*string pathVelodyne(path + "sequences/" + example->name + "/velodyne/");
for (vector<string>::iterator it=example->velodyne.begin(); it!=example->velodyne.end(); ++it)
{
printf("%s\n", (pathVelodyne + (*it)).c_str());
}*/
printf("number of velodyne images: %u\n", (unsigned int)example.velodyne.size());
printf("number of velodyne images: %u\n", (unsigned int)example->velodyne.size());
for (unsigned int i=0; i<=3; ++i)
{
/*char tmp[2];
sprintf(tmp, "%u", i);
// 0,1 - gray, 2,3 - color
string currPath(path + "sequences/" + example.name + "/image_" + tmp + "/");
for (vector<string>::iterator it=example.images[i].begin(); it!=example.images[i].end(); ++it)
string currPath(path + "sequences/" + example->name + "/image_" + tmp + "/");
for (vector<string>::iterator it=example->images[i].begin(); it!=example->images[i].end(); ++it)
{
printf("%s\n", (currPath + (*it)).c_str());
}*/
printf("number of images %u: %u\n", i, (unsigned int)example.images[i].size());
printf("number of images %u: %u\n", i, (unsigned int)example->images[i].size());
}
/*printf("times:\n");
for (vector<double>::iterator it=example.times.begin(); it!=example.times.end(); ++it)
for (vector<double>::iterator it=example->times.begin(); it!=example->times.end(); ++it)
{
printf("%f ", *it);
}
printf("\n");*/
printf("number of times: %u\n", (unsigned int)example.times.size());
printf("number of times: %u\n", (unsigned int)example->times.size());
/*printf("poses:\n");
for (vector<pose>::iterator it=example.posesArray.begin(); it!=example.posesArray.end(); ++it)
for (vector<pose>::iterator it=example->posesArray.begin(); it!=example->posesArray.end(); ++it)
{
for (unsigned int i=0; i<12; ++i)
{
......@@ -112,12 +112,12 @@ int main(int argc, char *argv[])
}
printf("\n");
}*/
printf("number of poses: %u\n", (unsigned int)example.posesArray.size());
printf("number of poses: %u\n", (unsigned int)example->posesArray.size());
for (unsigned int i=0; i<4; ++i)
{
printf("calibration %u:\n", i);
for (vector<double>::iterator it=example.p[i].begin(); it!=example.p[i].end(); ++it)
for (vector<double>::iterator it=example->p[i].begin(); it!=example->p[i].end(); ++it)
{
printf("%f ", *it);
}
......
......@@ -72,25 +72,25 @@ int main(int argc, char *argv[])
// For example, let output first image information and dataset size.
printf("dataset size: %u\n", (unsigned int)dataset.train.size());
imageInfo &example = dataset.train[0];
printf("first image:\ntype: %u\n", example.type);
imageInfo *example = static_cast<imageInfo *>(dataset.train[0].get());
printf("first image:\ntype: %u\n", example->type);
string imagePath(path);
if (LADYBUG == example.type)
if (LADYBUG == example->type)
{
imagePath += "ladybug/";
} else
{
imagePath += "dslr/";
}
printf("file name: %s\n", (imagePath + example.name).c_str());
printf("file name: %s\n", (imagePath + example->name).c_str());
printf("transformation matrix:\n");
for (unsigned int i=0; i<4; ++i)
{
for (unsigned int j=0; j<4; ++j)
{
printf("%f ", example.transformMat[i][j]);
printf("%f ", example->transformMat[i][j]);
}
printf("\n");
}
......
......@@ -83,17 +83,17 @@ int main(int argc, char *argv[])
// And number of splits.
printf("splits number: %u\n", (unsigned int)dataset.size());
vector<character> &currTrain = dataset.back().train;
vector<character> &currTest = dataset.back().test;
vector< Ptr<object> > &currTrain = dataset.back().train;
vector< Ptr<object> > &currTest = dataset.back().test;
printf("train size: %u\n", (unsigned int)currTrain.size());
printf("test size: %u\n", (unsigned int)currTest.size());
character &currTrainCh = currTrain[0];
character &currTestCh = currTest[0];
printf("first train element:\nname: %s\n", currTrainCh.imgName.c_str());
printf("label: %u\n", currTrainCh.label);
printf("first test element:\nname: %s\n", currTestCh.imgName.c_str());
printf("label: %u\n", currTestCh.label);
character *example1 = static_cast<character *>(currTrain[0].get());
character *example2 = static_cast<character *>(currTest[0].get());
printf("first train element:\nname: %s\n", example1->imgName.c_str());
printf("label: %u\n", example1->label);
printf("first test element:\nname: %s\n", example2->imgName.c_str());
printf("label: %u\n", example2->label);
return 0;
}
......@@ -76,15 +76,15 @@ int main(int argc, char *argv[])
printf("train size: %u\n", (unsigned int)dataset.train.size());
printf("test size: %u\n", (unsigned int)dataset.test.size());
image &example = dataset.train.back();
printf("last element:\nfile name: %s", example.fileName.c_str());
image *example = static_cast<image *>(dataset.train.back().get());
printf("last element:\nfile name: %s", example->fileName.c_str());
printf("\nlex: ");
for (vector<string>::iterator it=example.lex.begin(); it!=example.lex.end(); ++it)
for (vector<string>::iterator it=example->lex.begin(); it!=example->lex.end(); ++it)
{
printf("%s,", (*it).c_str());
}
printf("\ntags:\n");
for (vector<tag>::iterator it=example.tags.begin(); it!=example.tags.end(); ++it)
for (vector<tag>::iterator it=example->tags.begin(); it!=example->tags.end(); ++it)
{
tag &t = (*it);
printf("%s\nheight: %u, width: %u, x: %u, y: %u\n",
......
......@@ -91,16 +91,18 @@ void AR_hmdb::loadDataset(const string &path, int number)
getDirList(pathDataset, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
action curr;
curr.name = *it;
Ptr<action> currTrain(new action);
Ptr<action> currTest(new action);
currTrain->name = *it;
currTest->name = *it;
train.push_back(curr);
test.push_back(curr);
train.push_back(currTrain);
test.push_back(currTest);
char tmp[2];
sprintf(tmp, "%u", number+1);
string fileName(pathSplit + curr.name + "_test_split" + tmp + ".txt");
loadAction(fileName, train.back().videoNames, test.back().videoNames);
string fileName(pathSplit + currTrain->name + "_test_split" + tmp + ".txt");
loadAction(fileName, currTrain->videoNames, currTest->videoNames);
}
}
......
......@@ -49,20 +49,20 @@ namespace datasetstools
using namespace std;
void AR_sports::loadDatasetPart(const string &fileName, vector<element> &dataset_)
void AR_sports::loadDatasetPart(const string &fileName, vector< Ptr<object> > &dataset_)
{
ifstream infile(fileName.c_str());
string videoUrl, labels;
while (infile >> videoUrl >> labels)
{
element curr;
curr.videoUrl = videoUrl;
Ptr<element> curr(new element);
curr->videoUrl = videoUrl;
vector<string> elems;
split(labels, elems, ',');
for (vector<string>::iterator it=elems.begin(); it!=elems.end(); ++it)
{
curr.labels.push_back(atoi((*it).c_str()));
curr->labels.push_back(atoi((*it).c_str()));
}
dataset_.push_back(curr);
......
......@@ -70,15 +70,15 @@ void FR_lfw::loadDataset(const string &path)
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
face curr;
curr.name = *it;
Ptr<face> curr(new face);
curr->name = *it;
string pathFace(path + curr.name + "/");
string pathFace(path + curr->name + "/");
vector<string> faceNames;
getDirList(pathFace, faceNames);
for (vector<string>::iterator itFace=faceNames.begin(); itFace!=faceNames.end(); ++itFace)
{
curr.images.push_back(*itFace);
curr->images.push_back(*itFace);
}
train.push_back(curr);
......
......@@ -70,25 +70,25 @@ void GR_chalearn::loadDataset(const string &path)
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
gesture curr;
curr.name = *it;
curr.nameColor = curr.name + "/" + curr.name + "_color.mp4";
curr.nameDepth = curr.name + "/" + curr.name + "_depth.mp4";
curr.nameUser = curr.name + "/" + curr.name + "_user.mp4";
Ptr<gesture> curr(new gesture);
curr->name = *it;
curr->nameColor = curr->name + "/" + curr->name + "_color.mp4";
curr->nameDepth = curr->name + "/" + curr->name + "_depth.mp4";
curr->nameUser = curr->name + "/" + curr->name + "_user.mp4";
// loading video info
string fileVideoInfo(path + curr.name + "/" + curr.name + "_data.csv");
string fileVideoInfo(path + curr->name + "/" + curr->name + "_data.csv");
ifstream infile(fileVideoInfo.c_str());
string line;
getline(infile, line);
vector<string> elems;
split(line, elems, ',');
curr.numFrames = atoi(elems[0].c_str());
curr.fps = atoi(elems[1].c_str());
curr.depth = atoi(elems[2].c_str());
curr->numFrames = atoi(elems[0].c_str());
curr->fps = atoi(elems[1].c_str());
curr->depth = atoi(elems[2].c_str());
// loading ground truth
string fileGroundTruth(path + curr.name + "/" + curr.name + "_labels.csv");
string fileGroundTruth(path + curr->name + "/" + curr->name + "_labels.csv");
ifstream infileGroundTruth(fileGroundTruth.c_str());
while (getline(infileGroundTruth, line))
{
......@@ -100,11 +100,11 @@ void GR_chalearn::loadDataset(const string &path)
currGroundTruth.initialFrame = atoi(elems2[1].c_str());
currGroundTruth.lastFrame = atoi(elems2[2].c_str());
curr.groundTruths.push_back(currGroundTruth);
curr->groundTruths.push_back(currGroundTruth);
}
// loading skeleton
string fileSkeleton(path + curr.name + "/" + curr.name + "_skeleton.csv");
string fileSkeleton(path + curr->name + "/" + curr->name + "_skeleton.csv");
ifstream infileSkeleton(fileSkeleton.c_str());
while (getline(infileSkeleton, line))
{
......@@ -126,7 +126,7 @@ void GR_chalearn::loadDataset(const string &path)
currSkeleton.s[numJoin].Py = atof(elems2[i+8].c_str());
}
curr.skeletons.push_back(currSkeleton);
curr->skeletons.push_back(currSkeleton);
}
train.push_back(curr);
......
......@@ -81,22 +81,22 @@ void GR_skig::loadDataset(const string &path)
{
string &file = *it;
gestureSkig curr;
curr.rgb = pathDatasetRgb + file;
curr.dep = file;
curr.dep[0] = 'K';
curr.dep = pathDatasetDep + curr.dep;
Ptr<gestureSkig> curr(new gestureSkig);
curr->rgb = pathDatasetRgb + file;
curr->dep = file;
curr->dep[0] = 'K';
curr->dep = pathDatasetDep + curr->dep;
size_t pos = file.find("person_"); // TODO: check ::npos
curr.person = (unsigned char)atoi( file.substr(pos+strlen("person_"), 1).c_str() );
curr->person = (unsigned char)atoi( file.substr(pos+strlen("person_"), 1).c_str() );
pos = file.find("backgroud_");
curr.background = (backgroundType)atoi( file.substr(pos+strlen("backgroud_"), 1).c_str() );
curr->background = (backgroundType)atoi( file.substr(pos+strlen("backgroud_"), 1).c_str() );
pos = file.find("illumination_");
curr.illumination = (illuminationType)atoi( file.substr(pos+strlen("illumination_"), 1).c_str() );
curr->illumination = (illuminationType)atoi( file.substr(pos+strlen("illumination_"), 1).c_str() );
pos = file.find("pose_");
curr.pose = (poseType)atoi( file.substr(pos+strlen("pose_"), 1).c_str() );
curr->pose = (poseType)atoi( file.substr(pos+strlen("pose_"), 1).c_str() );
pos = file.find("actionType_");
curr.type = (actionType)atoi( file.substr(pos+strlen("actionType_"), 2).c_str() );
curr->type = (actionType)atoi( file.substr(pos+strlen("actionType_"), 2).c_str() );
train.push_back(curr);
}
......
......@@ -79,12 +79,15 @@ void HPE_parse::loadDataset(const string &path)
}
if (ext==".jpg")
{
Ptr<objectParse> curr(new objectParse);
curr->name = file;
if (i<100)
{
train.push_back(file);
train.push_back(curr);
} else
{
test.push_back(file);
test.push_back(curr);
}
++i;
}
......
......@@ -68,11 +68,11 @@ void IR_affine::loadDataset(const string &path)
{
for (unsigned int i=1; i<=6; ++i)
{
imageParams curr;
Ptr<imageParams> curr(new imageParams);
char tmp[2];
sprintf(tmp, "%u", i);
curr.imageName = path + "img" + tmp + ".ppm";
curr->imageName = path + "img" + tmp + ".ppm";
if (i>1)
{
......@@ -82,7 +82,7 @@ void IR_affine::loadDataset(const string &path)
{
for (int j=0; j<3; ++j)
{
infile >> curr.mat(k, j);
infile >> curr->mat(k, j);
}
}
}
......
......@@ -70,15 +70,15 @@ void IR_robot::loadDataset(const string &path)
getDirList(path, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
scene curr;
curr.name = *it;
Ptr<scene> curr(new scene);
curr->name = *it;
string pathScene(path + curr.name + "/");
string pathScene(path + curr->name + "/");
vector<string> sceneNames;
getDirList(pathScene, sceneNames);
for (vector<string>::iterator itScene=sceneNames.begin(); itScene!=sceneNames.end(); ++itScene)
{
curr.images.push_back(*itScene);
curr->images.push_back(*itScene);
}
train.push_back(curr);
......
......@@ -49,13 +49,15 @@ namespace datasetstools
using namespace std;
void IS_bsds::loadDatasetPart(const string &fileName, vector<string> &dataset_)
void IS_bsds::loadDatasetPart(const string &fileName, vector< Ptr<object> > &dataset_)
{
ifstream infile(fileName.c_str());
string imageName;
while (infile >> imageName)
{
dataset_.push_back(imageName);
Ptr<objectBsds> curr(new objectBsds);
curr->name = imageName;
dataset_.push_back(curr);
}
}
......
......@@ -73,12 +73,12 @@ void IS_weizmann::loadDataset(const string &path)
string &imageName = *it;
if (imageName.find('.') == string::npos) // only folders, discard .mat
{
object curr;
curr.imageName = imageName;
curr.srcBw = imageName + "/src_bw/" + imageName + ".png";
curr.srcColor = imageName + "/src_color/" + imageName + ".png";
Ptr<objectWeizmann> curr(new objectWeizmann);
curr->imageName = imageName;
curr->srcBw = imageName + "/src_bw/" + imageName + ".png";
curr->srcColor = imageName + "/src_color/" + imageName + ".png";
curr.humanSeg = imageName + "human_seg/";
curr->humanSeg = imageName + "human_seg/";
train.push_back(curr);
}
......
......@@ -85,12 +85,12 @@ void MSM_epfl::loadDataset(const string &path)
getDirList(pathPng, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
objectEpfl curr;
curr.imageName = *it;
Ptr<objectEpfl> curr(new objectEpfl);
curr->imageName = *it;
readFileDouble(string(pathBounding + curr.imageName + ".bounding"), curr.bounding);
readFileDouble(string(pathCamera + curr.imageName + ".camera"), curr.camera);
readFileDouble(string(pathP + curr.imageName + ".P"), curr.p);
readFileDouble(string(pathBounding + curr->imageName + ".bounding"), curr->bounding);
readFileDouble(string(pathCamera + curr->imageName + ".camera"), curr->camera);
readFileDouble(string(pathP + curr->imageName + ".P"), curr->p);
train.push_back(curr);
}
......
......@@ -78,26 +78,26 @@ void MSM_middlebury::loadDataset(const string &path)
infile >> imageName; // skip header
while (infile >> imageName)
{
cameraParam curr;
curr.imageName = imageName;
Ptr<cameraParam> curr(new cameraParam);
curr->imageName = imageName;
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
infile >> curr.k[i][j];
infile >> curr->k[i][j];
}
}
for (int i=0; i<3; ++i)
{
for (int j=0; j<3; ++j)
{
infile >> curr.r[i][j];
infile >> curr->r[i][j];
}
}
for (int i=0; i<3; ++i)
{
infile >> curr.t[i];
infile >> curr->t[i];
}
train.push_back(curr);
......
......@@ -73,17 +73,17 @@ void OR_imagenet::loadDataset(const string &path)
vector<string> elems;
split(line, elems, '\t');
objectImagenet curr;
curr.imageUrl = elems[1];
Ptr<objectImagenet> curr(new objectImagenet);
curr->imageUrl = elems[1];
string id(elems[0]);
elems.clear();
split(id, elems, '_');
curr.wnid = elems[0];
curr.id2 = atoi(elems[1].c_str());
curr->wnid = elems[0];
curr->id2 = atoi(elems[1].c_str());
wnids.insert(curr.wnid);
wnids.insert(curr->wnid);
train.push_back(curr);
}
......
......@@ -71,15 +71,15 @@ void OR_sun::loadDataset(const string &path)
string line;
while (getline(infile, line))
{
objectSun curr;
curr.name = line;
Ptr<objectSun> curr(new objectSun);
curr->name = line;
string currPath(path + curr.name);
string currPath(path + curr->name);
vector<string> fileNames;
getDirList(currPath, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
curr.imageNames.push_back(*it);
curr->imageNames.push_back(*it);
}
train.push_back(curr);
......
......@@ -71,10 +71,10 @@ void SLAM_kitti::loadDataset(const string &path)
getDirList(pathSequence, fileNames);
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
{
sequence curr;
curr.name = *it;
Ptr<sequence> curr(new sequence);
curr->name = *it;
string currPath(pathSequence + curr.name);
string currPath(pathSequence + curr->name);
// loading velodyne
string pathVelodyne(currPath + "/velodyne/");
......@@ -82,7 +82,7 @@ void SLAM_kitti::loadDataset(const string &path)
getDirList(pathVelodyne, velodyneNames);
for (vector<string>::iterator itV=velodyneNames.begin(); itV!=velodyneNames.end(); ++itV)
{
curr.velodyne.push_back(*itV);
curr->velodyne.push_back(*itV);
}
// loading gray & color images
......@@ -95,7 +95,7 @@ void SLAM_kitti::loadDataset(const string &path)
getDirList(pathImage, imageNames);
for (vector<string>::iterator itImage=imageNames.begin(); itImage!=imageNames.end(); ++itImage)
{
curr.images[i].push_back(*itImage);
curr->images[i].push_back(*itImage);
}
}
......@@ -104,7 +104,7 @@ void SLAM_kitti::loadDataset(const string &path)
string line;
while (getline(infile, line))
{
curr.times.push_back(atof(line.c_str()));
curr->times.push_back(atof(line.c_str()));
}
// loading calibration
......@@ -117,12 +117,12 @@ void SLAM_kitti::loadDataset(const string &path)
vector<string>::iterator itE=elems.begin();
for (++itE; itE!=elems.end(); ++itE)
{
curr.p[i].push_back(atof((*itE).c_str()));
curr->p[i].push_back(atof((*itE).c_str()));
}
}
// loading poses
ifstream infile3((path + "poses/" + curr.name + ".txt").c_str());
ifstream infile3((path + "poses/" + curr->name + ".txt").c_str());
while (getline(infile3, line))
{
pose p;
......@@ -139,7 +139,7 @@ void SLAM_kitti::loadDataset(const string &path)
p.elem[i] = atof((*itE).c_str());
}
curr.posesArray.push_back(p);
curr->posesArray.push_back(p);
}
train.push_back(curr);
......
......@@ -76,26 +76,26 @@ void SLAM_tumindoor::loadDataset(const string &path)
vector<string> elems;
split(line, elems, ';');
imageInfo curr;
Ptr<imageInfo> curr(new imageInfo);
curr.name = elems[0];
if (curr.name.substr(0, strlen("dslr_left")) == "dslr_left")
curr->name = elems[0];
if (curr->name.substr(0, strlen("dslr_left")) == "dslr_left")
{
curr.type = LEFT;
curr->type = LEFT;
} else
if (curr.name.substr(0, strlen("dslr_right")) == "dslr_right")
if (curr->name.substr(0, strlen("dslr_right")) == "dslr_right")
{
curr.type = RIGHT;
curr->type = RIGHT;
} else
{
curr.type = LADYBUG;
curr->type = LADYBUG;
}
for (unsigned int i=0; i<4; ++i)
{
for (unsigned int j=0; j<4; ++j)
{
curr.transformMat[i][j] = atof(elems[1 + j + i*4].c_str());
curr->transformMat[i][j] = atof(elems[1 + j + i*4].c_str());
}
}
......
......@@ -163,9 +163,9 @@ void TR_chars::loadDataset(const string &path, int number)
continue;
}
character curr;
curr.imgName = allNames[*it];
curr.label = allLabels[*it];
Ptr<character> curr(new character);
curr->imgName = allNames[*it];
curr->label = allLabels[*it];
train.push_back(curr);
}
......@@ -177,9 +177,9 @@ void TR_chars::loadDataset(const string &path, int number)
continue;
}
character curr;
curr.imgName = allNames[*it];
curr.label = allLabels[*it];
Ptr<character> curr(new character);
curr->imgName = allNames[*it];
curr->label = allLabels[*it];
test.push_back(curr);
}
}
......
......@@ -52,7 +52,7 @@ namespace datasetstools
using namespace std;
using namespace tinyxml2;
void TR_svt::xmlParse(const string &set, vector<image> &out)
void TR_svt::xmlParse(const string &set, vector< Ptr<object> > &out)
{
XMLDocument doc;
doc.LoadFile(set.c_str());
......@@ -67,9 +67,9 @@ void TR_svt::xmlParse(const string &set, vector<image> &out)
string imageName = child->FirstChildElement("imageName")->GetText();
string lex = child->FirstChildElement("lex")->GetText();
image img;
img.fileName = imageName;
split(lex, img.lex, ',');
Ptr<image> curr(new image);
curr->fileName = imageName;
split(lex, curr->lex, ',');
XMLElement *childTaggeds = child->FirstChildElement("taggedRectangles");
if (childTaggeds)
......@@ -84,13 +84,13 @@ void TR_svt::xmlParse(const string &set, vector<image> &out)
t.width = atoi(childTagged->Attribute("width"));
t.x = atoi(childTagged->Attribute("x"));
t.y = atoi(childTagged->Attribute("y"));
img.tags.push_back(t);
curr->tags.push_back(t);
childTagged = childTagged->NextSiblingElement(strTagged.c_str());
}
}
out.push_back(img);
out.push_back(curr);
child = child->NextSiblingElement(strImage.c_str());
}
......
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