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