diff --git a/modules/datasetstools/doc/datasetstools.rst b/modules/datasetstools/doc/datasetstools.rst index 76d27130b..acdc3a560 100644 --- a/modules/datasetstools/doc/datasetstools.rst +++ b/modules/datasetstools/doc/datasetstools.rst @@ -75,9 +75,11 @@ _`"ChaLearn Looking at People"`: http://gesture.chalearn.org/ 1. Follow instruction from site above, download files for dataset "Track 3: Gesture Recognition": Train1.zip-Train5.zip, Validation1.zip-Validation3.zip (Register on site: www.codalab.org and accept the terms and conditions of competition: https://www.codalab.org/competitions/991#learn_the_details There are three mirrors for downloading dataset files. When I downloaded data only mirror: "Universitat Oberta de Catalunya" works). - 2. Unpack train archives Train1.zip-Train5.zip to one folder (currently loading validation files wasn't implemented) + 2. Unpack train archives Train1.zip-Train5.zip to folder Train/, validation archives Validation1.zip-Validation3.zip to folder Validation/ - 3. To load data run: ./opencv/build/bin/example_datasetstools_gr_chalearn -p=/home/user/path_to_unpacked_folder/ + 3. Unpack all archives in Train/ & Validation/ in the folders with the same names, for example: Sample0001.zip to Sample0001/ + + 4. To load data run: ./opencv/build/bin/example_datasetstools_gr_chalearn -p=/home/user/path_to_unpacked_folders/ GR_skig ======= @@ -245,7 +247,7 @@ OR_sun Implements loading dataset: -_`"SUN Database"`: http://sun.cs.princeton.edu/ +_`"SUN Database"`: http://sundatabase.mit.edu/ Currently implemented loading "Scene Recognition Benchmark. SUN397". Planned to implement also "Object Detection Benchmark. SUN2012". diff --git a/modules/datasetstools/include/opencv2/datasetstools/dataset.hpp b/modules/datasetstools/include/opencv2/datasetstools/dataset.hpp index 544719bbf..afac7bc68 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/dataset.hpp +++ b/modules/datasetstools/include/opencv2/datasetstools/dataset.hpp @@ -66,10 +66,12 @@ public: std::vector< Ptr >& getTrain() { return train; } std::vector< Ptr >& getTest() { return test; } + std::vector< Ptr >& getValidation() { return validation; } protected: std::vector< Ptr > train; std::vector< Ptr > test; + std::vector< Ptr > validation; }; } diff --git a/modules/datasetstools/include/opencv2/datasetstools/ir_robot.hpp b/modules/datasetstools/include/opencv2/datasetstools/ir_robot.hpp index efb76ef4f..9d6952204 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/ir_robot.hpp +++ b/modules/datasetstools/include/opencv2/datasetstools/ir_robot.hpp @@ -59,10 +59,15 @@ namespace datasetstools // 0.0000e+00 2.8285e+03 6.1618e+02 // 0.0000e+00 0.0000e+00 1.0000e+00 +struct cameraPos +{ + std::vector images; +}; + struct IR_robotObj : public Object { std::string name; - std::vector images; // TODO: implement more complex structure + std::vector pos; }; class CV_EXPORTS IR_robot : public Dataset diff --git a/modules/datasetstools/include/opencv2/datasetstools/msm_epfl.hpp b/modules/datasetstools/include/opencv2/datasetstools/msm_epfl.hpp index 22633667e..b71c8d8fa 100644 --- a/modules/datasetstools/include/opencv2/datasetstools/msm_epfl.hpp +++ b/modules/datasetstools/include/opencv2/datasetstools/msm_epfl.hpp @@ -54,10 +54,21 @@ namespace cv namespace datasetstools { +struct cameraParam +{ + Matx33d mat1; + double mat2[3]; + Matx33d mat3; + double mat4[3]; + int imageWidth, imageHeight; +}; + struct MSM_epflObj : public Object { std::string imageName; - std::vector bounding, camera, p; // TODO: implement better structures + Matx23d bounding; + Matx34d p; + cameraParam camera; }; class CV_EXPORTS MSM_epfl : public Dataset diff --git a/modules/datasetstools/samples/gr_chalearn.cpp b/modules/datasetstools/samples/gr_chalearn.cpp index e263cb291..fa972667e 100644 --- a/modules/datasetstools/samples/gr_chalearn.cpp +++ b/modules/datasetstools/samples/gr_chalearn.cpp @@ -71,10 +71,11 @@ 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->getTrain().size()); + printf("train size: %u\n", (unsigned int)dataset->getTrain().size()); + printf("validation size: %u\n", (unsigned int)dataset->getValidation().size()); GR_chalearnObj *example = static_cast(dataset->getTrain()[0].get()); 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("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); diff --git a/modules/datasetstools/samples/ir_robot.cpp b/modules/datasetstools/samples/ir_robot.cpp index 69dc75ecf..b06eb327b 100644 --- a/modules/datasetstools/samples/ir_robot.cpp +++ b/modules/datasetstools/samples/ir_robot.cpp @@ -72,11 +72,17 @@ int main(int argc, char *argv[]) // dataset contains object with name and its images. // For example, let output last element and dataset size. IR_robotObj *example = static_cast(dataset->getTrain().back().get()); - printf("last dataset object:\n%s\n", example->name.c_str()); + printf("last dataset object:\n"); + printf("name: %s\n", example->name.c_str()); + printf("number postitions: %u\n", (unsigned int)example->pos.size()); string currPath(path + example->name + "/"); - for (vector::iterator it=example->images.begin(); it!=example->images.end(); ++it) + + for (vector::iterator itP=example->pos.begin(); itP!=example->pos.end(); ++itP) { - printf("%s\n", (currPath+(*it)).c_str()); + for (vector::iterator it=itP->images.begin(); it!=itP->images.end(); ++it) + { + printf("%s\n", (currPath+(*it)).c_str()); + } } printf("dataset size: %u\n", (unsigned int)dataset->getTrain().size()); diff --git a/modules/datasetstools/samples/msm_epfl.cpp b/modules/datasetstools/samples/msm_epfl.cpp index 17394a59d..f80f340b5 100644 --- a/modules/datasetstools/samples/msm_epfl.cpp +++ b/modules/datasetstools/samples/msm_epfl.cpp @@ -75,26 +75,60 @@ int main(int argc, char *argv[]) MSM_epflObj *example = static_cast(dataset->getTrain()[0].get()); printf("first image:\nname: %s\n", example->imageName.c_str()); - printf("bounding:\n"); - for (vector::iterator it=example->bounding.begin(); it!=example->bounding.end(); ++it) + printf("\nbounding:\n"); + for (int i=0; i<2; ++i) { - printf("%f ", *it); + for (int j=0; j<3; ++j) + { + printf("%f ", example->bounding(i, j)); + } + printf("\n"); } - printf("\n"); - printf("camera:\n"); - for (vector::iterator it=example->camera.begin(); it!=example->camera.end(); ++it) + printf("\ncamera:\n"); + for (int i=0; i<3; ++i) { - printf("%f ", *it); + for (int j=0; j<3; ++j) + { + printf("%f ", example->camera.mat1(i, j)); + } + printf("\n"); } printf("\n"); - printf("P:\n"); - for (vector::iterator it=example->p.begin(); it!=example->p.end(); ++it) + for (int i=0; i<3; ++i) + { + printf("%f ", example->camera.mat2[i]); + } + printf("\n\n"); + + for (int i=0; i<3; ++i) { - printf("%f ", *it); + for (int j=0; j<3; ++j) + { + printf("%f ", example->camera.mat3(i, j)); + } + printf("\n"); } printf("\n"); + for (int i=0; i<3; ++i) + { + printf("%f ", example->camera.mat4[i]); + } + printf("\n\n"); + + printf("image width: %u, height: %u\n", example->camera.imageWidth, example->camera.imageHeight); + + printf("\nP:\n"); + for (int i=0; i<3; ++i) + { + for (int j=0; j<4; ++j) + { + printf("%f ", example->p(i, j)); + } + printf("\n"); + } + return 0; } diff --git a/modules/datasetstools/samples/slam_tumindoor.cpp b/modules/datasetstools/samples/slam_tumindoor.cpp index af20372b7..2ba504b66 100644 --- a/modules/datasetstools/samples/slam_tumindoor.cpp +++ b/modules/datasetstools/samples/slam_tumindoor.cpp @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) } printf("file name: %s\n", (imagePath + example->name).c_str()); - printf("transformation matrix:\n"); + printf("\ntransformation matrix:\n"); for (unsigned int i=0; i<4; ++i) { for (unsigned int j=0; j<4; ++j) diff --git a/modules/datasetstools/samples/tr_chars.cpp b/modules/datasetstools/samples/tr_chars.cpp index d78f84620..499d831a1 100644 --- a/modules/datasetstools/samples/tr_chars.cpp +++ b/modules/datasetstools/samples/tr_chars.cpp @@ -85,15 +85,20 @@ int main(int argc, char *argv[]) vector< Ptr > &currTrain = dataset.back()->getTrain(); vector< Ptr > &currTest = dataset.back()->getTest(); + vector< Ptr > &currValidation = dataset.back()->getValidation(); printf("train size: %u\n", (unsigned int)currTrain.size()); printf("test size: %u\n", (unsigned int)currTest.size()); + printf("validation size: %u\n", (unsigned int)currValidation.size()); - TR_charsObj *example1 = static_cast(currTrain[0].get()); - TR_charsObj *example2 = static_cast(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); + TR_charsObj *exampleTrain = static_cast(currTrain[0].get()); + TR_charsObj *exampleTest = static_cast(currTest[0].get()); + TR_charsObj *exampleValidation = static_cast(currValidation[0].get()); + printf("first train element:\nname: %s\n", exampleTrain->imgName.c_str()); + printf("label: %u\n", exampleTrain->label); + printf("first test element:\nname: %s\n", exampleTest->imgName.c_str()); + printf("label: %u\n", exampleTest->label); + printf("first validation element:\nname: %s\n", exampleValidation->imgName.c_str()); + printf("label: %u\n", exampleValidation->label); return 0; } diff --git a/modules/datasetstools/src/gr_chalearn.cpp b/modules/datasetstools/src/gr_chalearn.cpp index 483e9e3bf..a27d16f9b 100644 --- a/modules/datasetstools/src/gr_chalearn.cpp +++ b/modules/datasetstools/src/gr_chalearn.cpp @@ -60,6 +60,8 @@ public: private: void loadDataset(const std::string &path); + + void loadDatasetPart(const std::string &path, std::vector< Ptr > &dataset_, bool loadLabels); }; /*GR_chalearnImp::GR_chalearnImp(const string &path) @@ -77,7 +79,7 @@ void GR_chalearnImp::load(const string &path, int number) loadDataset(path); } -void GR_chalearnImp::loadDataset(const string &path) +void GR_chalearnImp::loadDatasetPart(const string &path, vector< Ptr > &dataset_, bool loadLabels) { vector fileNames; getDirList(path, fileNames); @@ -101,19 +103,22 @@ void GR_chalearnImp::loadDataset(const string &path) curr->depth = atoi(elems[2].c_str()); // loading ground truth - string fileGroundTruth(path + curr->name + "/" + curr->name + "_labels.csv"); - ifstream infileGroundTruth(fileGroundTruth.c_str()); - while (getline(infileGroundTruth, line)) + if (loadLabels) { - vector elems2; - split(line, elems2, ','); + string fileGroundTruth(path + curr->name + "/" + curr->name + "_labels.csv"); + ifstream infileGroundTruth(fileGroundTruth.c_str()); + while (getline(infileGroundTruth, line)) + { + vector elems2; + split(line, elems2, ','); - groundTruth currGroundTruth; - currGroundTruth.gestureID = atoi(elems2[0].c_str()); - currGroundTruth.initialFrame = atoi(elems2[1].c_str()); - currGroundTruth.lastFrame = atoi(elems2[2].c_str()); + groundTruth currGroundTruth; + currGroundTruth.gestureID = atoi(elems2[0].c_str()); + 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 @@ -142,10 +147,20 @@ void GR_chalearnImp::loadDataset(const string &path) curr->skeletons.push_back(currSkeleton); } - train.push_back(curr); + dataset_.push_back(curr); } } +void GR_chalearnImp::loadDataset(const string &path) +{ + string pathTrain(path + "Train/"); + loadDatasetPart(pathTrain, train, true); + + // freely available validation set doesn't have labels + string pathValidation(path + "Validation/"); + loadDatasetPart(pathValidation, validation, false); +} + Ptr GR_chalearn::create() { return Ptr(new GR_chalearnImp); diff --git a/modules/datasetstools/src/gr_skig.cpp b/modules/datasetstools/src/gr_skig.cpp index 193717366..aeecba7b6 100644 --- a/modules/datasetstools/src/gr_skig.cpp +++ b/modules/datasetstools/src/gr_skig.cpp @@ -100,18 +100,28 @@ void GR_skigImp::loadDataset(const string &path) 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() ); - pos = file.find("backgroud_"); - 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() ); - pos = file.find("pose_"); - 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() ); - - train.push_back(curr); + size_t posPerson = file.find("person_"); + size_t posBackground = file.find("backgroud_"); + size_t posIllumination = file.find("illumination_"); + size_t posPose = file.find("pose_"); + size_t posType = file.find("actionType_"); + if (string::npos != posPerson && + string::npos != posBackground && + string::npos != posIllumination && + string::npos != posPose && + string::npos != posType) + { + curr->person = (unsigned char)atoi( file.substr(posPerson + strlen("person_"), 1).c_str() ); + curr->background = (backgroundType)atoi( file.substr(posBackground + strlen("backgroud_"), 1).c_str() ); + curr->illumination = (illuminationType)atoi( file.substr(posIllumination + strlen("illumination_"), 1).c_str() ); + curr->pose = (poseType)atoi( file.substr(posPose + strlen("pose_"), 1).c_str() ); + curr->type = (actionType)atoi( file.substr(posType + strlen("actionType_"), 2).c_str() ); + + train.push_back(curr); + } else + { + printf("incorrect file name: %s", file.c_str()); + } } } } diff --git a/modules/datasetstools/src/ir_robot.cpp b/modules/datasetstools/src/ir_robot.cpp index a2a523b98..71b0c33ff 100644 --- a/modules/datasetstools/src/ir_robot.cpp +++ b/modules/datasetstools/src/ir_robot.cpp @@ -89,9 +89,20 @@ void IR_robotImp::loadDataset(const string &path) string pathScene(path + curr->name + "/"); vector sceneNames; getDirList(pathScene, sceneNames); + int currImageNum = 0; for (vector::iterator itScene=sceneNames.begin(); itScene!=sceneNames.end(); ++itScene) { - curr->images.push_back(*itScene); + string &fileName = *itScene; + + int imageNum = atoi( fileName.substr(3, 3).c_str() ); + int pos = atoi( fileName.substr(6, 2).c_str() ); + if (imageNum != currImageNum) + { + curr->pos.push_back(cameraPos()); + currImageNum = imageNum; + } + + curr->pos.back().images.push_back(fileName); } train.push_back(curr); diff --git a/modules/datasetstools/src/msm_epfl.cpp b/modules/datasetstools/src/msm_epfl.cpp index 1e64f3df1..798b5f97e 100644 --- a/modules/datasetstools/src/msm_epfl.cpp +++ b/modules/datasetstools/src/msm_epfl.cpp @@ -60,20 +60,8 @@ public: private: void loadDataset(const std::string &path); - - void readFileDouble(const std::string &fileName, std::vector &out); }; -void MSM_epflImp::readFileDouble(const string &fileName, vector &out) -{ - ifstream infile(fileName.c_str()); - double val; - while (infile >> val) - { - out.push_back(val); - } -} - /*MSM_epflImp::MSM_epflImp(const string &path) { loadDataset(path); @@ -103,9 +91,58 @@ void MSM_epflImp::loadDataset(const string &path) Ptr curr(new MSM_epflObj); 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); + // load boundary + string fileBounding(pathBounding + curr->imageName + ".bounding"); + ifstream infile(fileBounding.c_str()); + for (int k=0; k<2; ++k) + { + for (int j=0; j<3; ++j) + { + infile >> curr->bounding(k, j); + } + } + + // load camera parameters + string fileCamera(pathCamera + curr->imageName + ".camera"); + ifstream infileCamera(fileCamera.c_str()); + for (int i=0; i<3; ++i) + { + for (int j=0; j<3; ++j) + { + infileCamera >> curr->camera.mat1(i, j); + } + } + + for (int i=0; i<3; ++i) + { + infileCamera >> curr->camera.mat2[i]; + } + + for (int i=0; i<3; ++i) + { + for (int j=0; j<3; ++j) + { + infileCamera >> curr->camera.mat3(i, j); + } + } + + for (int i=0; i<3; ++i) + { + infileCamera >> curr->camera.mat4[i]; + } + + infileCamera >> curr->camera.imageWidth >> curr->camera.imageHeight; + + // load P + string fileP(pathP + curr->imageName + ".P"); + ifstream infileP(fileP.c_str()); + for (int k=0; k<3; ++k) + { + for (int j=0; j<4; ++j) + { + infileP >> curr->p(k, j); + } + } train.push_back(curr); } diff --git a/modules/datasetstools/src/slam_tumindoor.cpp b/modules/datasetstools/src/slam_tumindoor.cpp index 5b689aab3..85dbc5635 100644 --- a/modules/datasetstools/src/slam_tumindoor.cpp +++ b/modules/datasetstools/src/slam_tumindoor.cpp @@ -81,8 +81,34 @@ void SLAM_tumindoorImp::load(const string &path, int number) void SLAM_tumindoorImp::loadDataset(const string &path) { - string infoPath(path + "info/2011-12-17_15.02.56-info.csv"); // TODO - ifstream infile(infoPath.c_str()); + string infoPath(path + "info/"); + + // get info map name, .csv should be only one such file in folder + string csvName; + vector infoNames; + getDirList(infoPath, infoNames); + for (vector::iterator it=infoNames.begin(); it!=infoNames.end(); ++it) + { + string &name = *it; + if (name.length()>3 && name.substr( name.length()-4, 4 )==".csv") + { + if (csvName.length()==0) + { + csvName = name; + } else + { + printf("more than one .csv file in info folder\n"); + return; + } + } + } + if (csvName.length()==0) + { + printf("didn't find .csv file in info folder\n"); + return; + } + + ifstream infile((infoPath + csvName).c_str()); string line; while (getline(infile, line)) { diff --git a/modules/datasetstools/src/tr_chars.cpp b/modules/datasetstools/src/tr_chars.cpp index 2066e1b2c..b157e9207 100644 --- a/modules/datasetstools/src/tr_chars.cpp +++ b/modules/datasetstools/src/tr_chars.cpp @@ -53,15 +53,19 @@ class CV_EXPORTS TR_charsImp : public TR_chars { public: TR_charsImp() {} - //TR_charsImp(const std::string &path, int number = 0); + //TR_charsImp(const string &path, int number = 0); virtual ~TR_charsImp() {} - virtual void load(const std::string &path, int number = 0); + virtual void load(const string &path, int number = 0); private: - void loadDataset(const std::string &path, int number = 0); + void loadDataset(const string &path, int number = 0); - void parseLine(const std::string &line, std::vector &currSet, int number); + void parseLine(const string &line, vector &currSet, int number); + + inline void convert(vector &from, vector< Ptr > &to, vector &allLabels, vector &allNames); + + inline void parseSet(const string &line, const string &pattern, bool &flag, vector &set, int number); }; void TR_charsImp::parseLine(const string &line, vector &currSet, int number) @@ -80,6 +84,38 @@ void TR_charsImp::parseLine(const string &line, vector &currSet, int number } } +inline void TR_charsImp::convert(vector &from, std::vector< Ptr > &to, vector &allLabels, vector &allNames) +{ + for (vector::iterator it=from.begin(); it!=from.end(); ++it) + { + if (*it>=(int)allNames.size() || *it>=(int)allLabels.size()) + { + printf("incorrect index: %u\n", *it); + continue; + } + + Ptr curr(new TR_charsObj); + curr->imgName = allNames[*it]; + curr->label = allLabels[*it]; + to.push_back(curr); + } +} + +inline void TR_charsImp::parseSet(const string &line, const string &pattern, bool &flag, vector &set, int number) +{ + size_t pos = line.find(pattern); + if (string::npos != pos) + { + flag = true; + string s(line.substr(pos + pattern.length())); + parseLine(s, set, number); + } else + if (flag) + { + parseLine(line, set, number); + } +} + /*TR_charsImp::TR_charsImp(const string &path, int number) { loadDataset(path, number); @@ -92,21 +128,22 @@ void TR_charsImp::load(const string &path, int number) void TR_charsImp::loadDataset(const string &path, int number) { - vector allLabels, trainSet, testSet; + vector allLabels, trainSet, testSet, validationSet; vector allNames; ifstream infile((path + "list_English_Img.m").c_str()); string line; - bool labels = false, names = false, isTrain = false, isTest = false; + bool labels = false, names = false, isTrain = false, isTest = false, isValidation = false; while (getline(infile, line)) { size_t pos = line.find("];"); - if (string::npos!=pos) + if (string::npos != pos) { labels = false; names = false; isTrain = false; isTest = false; + isValidation = false; } string slabels("list.ALLlabels = ["); @@ -124,7 +161,7 @@ void TR_charsImp::loadDataset(const string &path, int number) string snames("list.ALLnames = ["); pos = line.find(snames); - if (string::npos!=pos) + if (string::npos != pos) { names = true; size_t start = pos+snames.length(); @@ -137,66 +174,24 @@ void TR_charsImp::loadDataset(const string &path, int number) allNames.push_back(s); } - string strain("list.TRNind = ["); - pos = line.find(strain); - if (string::npos!=pos) - { - isTrain = true; - string s(line.substr(pos+strain.length())); - parseLine(s, trainSet, number); - } else - if (isTrain) - { - parseLine(line, trainSet, number); - } + string trainStr("list.TRNind = ["); + parseSet(line, trainStr, isTrain, trainSet, number); - string stest("list.TSTind = ["); - pos = line.find(stest); - if (string::npos!=pos) - { - isTest = true; - string s(line.substr(pos+stest.length())); - parseLine(s, testSet, number); - } else - if (isTest) - { - parseLine(line, testSet, number); - } + string testStr("list.TSTind = ["); + parseSet(line, testStr, isTest, testSet, number); + + string validationStr("list.VALind = ["); + parseSet(line, validationStr, isValidation, validationSet, number); /*"list.classlabels = [" "list.classnames = [" "list.NUMclasses = 62;" - "list.VALind = [" // TODO: load validation "list.TXNind = ["*/ } - for (vector::iterator it=trainSet.begin(); it!=trainSet.end(); ++it) - { - if (*it>=(int)allNames.size() || *it>=(int)allLabels.size()) - { - printf("incorrect train index: %u\n", *it); - continue; - } - - Ptr curr(new TR_charsObj); - curr->imgName = allNames[*it]; - curr->label = allLabels[*it]; - train.push_back(curr); - } - - for (vector::iterator it=testSet.begin(); it!=testSet.end(); ++it) - { - if (*it>=(int)allNames.size() || *it>=(int)allLabels.size()) - { - printf("incorrect test index: %u\n", *it); - continue; - } - - Ptr curr(new TR_charsObj); - curr->imgName = allNames[*it]; - curr->label = allLabels[*it]; - test.push_back(curr); - } + convert(trainSet, train, allLabels, allNames); + convert(testSet, test, allLabels, allNames); + convert(validationSet, validation, allLabels, allNames); } Ptr TR_chars::create()