vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/ar_hmdb.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class AR_hmdbImp : public AR_hmdb
|
||||
{
|
||||
public:
|
||||
AR_hmdbImp() {}
|
||||
//AR_hmdbImp(const string &path, int number = 0);
|
||||
virtual ~AR_hmdbImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDatasetSplit(const string &path, int number = 0);
|
||||
|
||||
void loadDataset(const string &path);
|
||||
|
||||
map<string, int> actionsId;
|
||||
};
|
||||
|
||||
/*AR_hmdbImp::AR_hmdbImp(const string &path, int number)
|
||||
{
|
||||
loadDataset(path, number);
|
||||
}*/
|
||||
|
||||
void AR_hmdbImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void AR_hmdbImp::loadDataset(const string &path)
|
||||
{
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
loadDatasetSplit(path, i);
|
||||
}
|
||||
}
|
||||
|
||||
void AR_hmdbImp::loadDatasetSplit(const string &path, int number)
|
||||
{
|
||||
// valid number [0,1,2]
|
||||
if (number<0 || number>2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string pathDataset(path + "hmdb51_org/");
|
||||
string pathSplit(path + "testTrainMulti_7030_splits/");
|
||||
|
||||
vector<string> fileNames;
|
||||
getDirList(pathDataset, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &action = *it;
|
||||
map<string, int>::iterator itId = actionsId.find(action);
|
||||
int id;
|
||||
if (itId == actionsId.end())
|
||||
{
|
||||
actionsId.insert(make_pair(action, actionsId.size()));
|
||||
id = (int)actionsId.size();
|
||||
} else
|
||||
{
|
||||
id = (*itId).second;
|
||||
}
|
||||
|
||||
char tmp[2];
|
||||
sprintf(tmp, "%u", number+1);
|
||||
string fileName(pathSplit + action + "_test_split" + tmp + ".txt");
|
||||
|
||||
ifstream infile(fileName.c_str());
|
||||
string video, label;
|
||||
while (infile >> video >> label)
|
||||
{
|
||||
Ptr<AR_hmdbObj> curr(new AR_hmdbObj);
|
||||
curr->id = id;
|
||||
curr->name = action;
|
||||
curr->videoName = video;
|
||||
|
||||
if ("1"==label)
|
||||
{
|
||||
train.back().push_back(curr);
|
||||
} else
|
||||
if ("2"==label)
|
||||
{
|
||||
test.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<AR_hmdb> AR_hmdb::create()
|
||||
{
|
||||
return Ptr<AR_hmdbImp>(new AR_hmdbImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/ar_sports.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class AR_sportsImp : public AR_sports
|
||||
{
|
||||
public:
|
||||
AR_sportsImp() {}
|
||||
//AR_sportsImp(const string &path);
|
||||
virtual ~AR_sportsImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_);
|
||||
};
|
||||
|
||||
void AR_sportsImp::loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_)
|
||||
{
|
||||
ifstream infile(fileName.c_str());
|
||||
string videoUrl, labels;
|
||||
while (infile >> videoUrl >> labels)
|
||||
{
|
||||
Ptr<AR_sportsObj> curr(new AR_sportsObj);
|
||||
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()));
|
||||
}
|
||||
|
||||
dataset_.push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/*AR_sportsImp::AR_sportsImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void AR_sportsImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void AR_sportsImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string trainPath(path + "original/train_partition.txt");
|
||||
string testPath(path + "original/test_partition.txt");
|
||||
|
||||
// loading train video urls & labels
|
||||
loadDatasetPart(trainPath, train.back());
|
||||
|
||||
// loading test video urls & labels
|
||||
loadDatasetPart(testPath, test.back());
|
||||
}
|
||||
|
||||
Ptr<AR_sports> AR_sports::create()
|
||||
{
|
||||
return Ptr<AR_sportsImp>(new AR_sportsImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/dataset.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
vector< Ptr<Object> >& Dataset::getTrain(int splitNum)
|
||||
{
|
||||
if (splitNum >= (int)train.size())
|
||||
{
|
||||
return empty;
|
||||
}
|
||||
|
||||
return train[splitNum];
|
||||
}
|
||||
|
||||
vector< Ptr<Object> >& Dataset::getTest(int splitNum)
|
||||
{
|
||||
if (splitNum >= (int)test.size())
|
||||
{
|
||||
return empty;
|
||||
}
|
||||
|
||||
return test[splitNum];
|
||||
}
|
||||
|
||||
vector< Ptr<Object> >& Dataset::getValidation(int splitNum)
|
||||
{
|
||||
if (splitNum >= (int)validation.size())
|
||||
{
|
||||
return empty;
|
||||
}
|
||||
|
||||
return validation[splitNum];
|
||||
}
|
||||
|
||||
int Dataset::getNumSplits() const
|
||||
{
|
||||
return (int)train.size();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,227 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/fr_adience.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class FR_adienceImp CV_FINAL : public FR_adience
|
||||
{
|
||||
public:
|
||||
FR_adienceImp() {}
|
||||
//FR_adienceImp(const string &path);
|
||||
virtual ~FR_adienceImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void loadFile(const string &filename, vector< Ptr<FR_adienceObj> > &out);
|
||||
void cv5ToSplits(vector< Ptr<FR_adienceObj> > fileList[5]);
|
||||
|
||||
map< string, vector<string> > realNames;
|
||||
set<string> missing;
|
||||
};
|
||||
|
||||
/*FR_adienceImp::FR_adienceImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void FR_adienceImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void FR_adienceImp::loadFile(const string &filename, vector< Ptr<FR_adienceObj> > &out)
|
||||
{
|
||||
string line;
|
||||
ifstream infile(filename.c_str());
|
||||
getline(infile, line); // skip header
|
||||
while (getline(infile, line))
|
||||
{
|
||||
vector<string> elems;
|
||||
split(line, elems, ',');
|
||||
|
||||
string user_id = elems[0];
|
||||
string original_image = elems[1];
|
||||
|
||||
// convert original_image to real image name
|
||||
bool isChanged = false;
|
||||
vector<string> &currImgs = realNames[user_id];
|
||||
for (vector<string>::iterator it=currImgs.begin(); it!=currImgs.end(); ++it)
|
||||
{
|
||||
string &name = *it;
|
||||
size_t origImgLen = original_image.length();
|
||||
if (name.length()>origImgLen && name.substr(name.length()-origImgLen) == original_image)
|
||||
{
|
||||
original_image = name;
|
||||
isChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isChanged)
|
||||
{
|
||||
missing.insert(user_id+"/"+original_image);
|
||||
continue;
|
||||
}
|
||||
|
||||
Ptr<FR_adienceObj> curr(new FR_adienceObj);
|
||||
curr->user_id = user_id;
|
||||
curr->original_image = original_image;
|
||||
curr->face_id = atoi(elems[2].c_str());
|
||||
curr->age = elems[3];
|
||||
if (elems[4]=="m")
|
||||
{
|
||||
curr->gender = male;
|
||||
} else
|
||||
if (elems[4]=="f")
|
||||
{
|
||||
curr->gender = female;
|
||||
} else
|
||||
{
|
||||
curr->gender = none;
|
||||
}
|
||||
curr->x = atoi(elems[5].c_str());
|
||||
curr->y = atoi(elems[6].c_str());
|
||||
curr->dx = atoi(elems[7].c_str());
|
||||
curr->dy = atoi(elems[8].c_str());
|
||||
curr->tilt_ang = atoi(elems[9].c_str());
|
||||
curr->fiducial_yaw_angle = atoi(elems[10].c_str());
|
||||
curr->fiducial_score = atoi(elems[11].c_str());
|
||||
|
||||
out.push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
void FR_adienceImp::cv5ToSplits(vector< Ptr<FR_adienceObj> > fileList[5])
|
||||
{
|
||||
for (unsigned int i=0; i<5; ++i)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
for (unsigned int j=0; j<5; ++j)
|
||||
{
|
||||
vector< Ptr<FR_adienceObj> > &currlist = fileList[j];
|
||||
if (i!=j)
|
||||
{
|
||||
for (vector< Ptr<FR_adienceObj> >::iterator it=currlist.begin(); it!=currlist.end(); ++it)
|
||||
{
|
||||
train.back().push_back(*it);
|
||||
}
|
||||
} else
|
||||
{
|
||||
for (vector< Ptr<FR_adienceObj> >::iterator it=currlist.begin(); it!=currlist.end(); ++it)
|
||||
{
|
||||
test.back().push_back(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FR_adienceImp::loadDataset(const string &path)
|
||||
{
|
||||
// collect real image names
|
||||
vector<string> userNames;
|
||||
getDirList(path+"faces/", userNames);
|
||||
for (vector<string>::iterator itU=userNames.begin(); itU!=userNames.end(); ++itU)
|
||||
{
|
||||
vector<string> fileNames;
|
||||
getDirList(path+"faces/"+*itU+"/", fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &name = *it;
|
||||
if (name.length()>3 && name.substr(name.length()-4) == ".jpg")
|
||||
{
|
||||
realNames[*itU].push_back(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector< Ptr<FR_adienceObj> > fileList[5];
|
||||
for (unsigned int i=0; i<5; ++i)
|
||||
{
|
||||
char tmp[3];
|
||||
sprintf(tmp, "%u", i);
|
||||
string filename(path+"fold_"+string(tmp)+"_data.txt");
|
||||
|
||||
loadFile(filename, fileList[i]);
|
||||
}
|
||||
cv5ToSplits(fileList);
|
||||
|
||||
for (unsigned int i=0; i<5; ++i)
|
||||
{
|
||||
char tmp[3];
|
||||
sprintf(tmp, "%u", i);
|
||||
string filename(path+"fold_frontal_"+string(tmp)+"_data.txt");
|
||||
|
||||
fileList[i].clear();
|
||||
loadFile(filename, fileList[i]);
|
||||
}
|
||||
cv5ToSplits(fileList);
|
||||
|
||||
/*for (set<string>::iterator it=missing.begin(); it!=missing.end(); ++it)
|
||||
{
|
||||
printf("missing image: %s\n", (*it).c_str());
|
||||
}*/
|
||||
realNames.clear();
|
||||
missing.clear();
|
||||
}
|
||||
|
||||
Ptr<FR_adience> FR_adience::create()
|
||||
{
|
||||
return Ptr<FR_adienceImp>(new FR_adienceImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,222 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/fr_lfw.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class FR_lfwImp CV_FINAL : public FR_lfw
|
||||
{
|
||||
public:
|
||||
FR_lfwImp() {}
|
||||
//FR_lfwImp(const string &path);
|
||||
virtual ~FR_lfwImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
map< string, vector<string> > faces;
|
||||
};
|
||||
|
||||
/*FR_lfwImp::FR_lfwImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void FR_lfwImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void FR_lfwImp::loadDataset(const string &path)
|
||||
{
|
||||
vector<string> fileNames;
|
||||
getDirList(path, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &name = *it;
|
||||
|
||||
if (name.length()>3 && name.substr(name.length()-4) == ".txt")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
vector<string> images;
|
||||
|
||||
string pathFace(path + name + "/");
|
||||
vector<string> faceNames;
|
||||
getDirList(pathFace, faceNames);
|
||||
for (vector<string>::iterator itFace=faceNames.begin(); itFace!=faceNames.end(); ++itFace)
|
||||
{
|
||||
images.push_back(*itFace);
|
||||
}
|
||||
|
||||
faces.insert(make_pair(name, images));
|
||||
}
|
||||
|
||||
// test loading
|
||||
ifstream infile((path + "pairs.txt").c_str());
|
||||
string line;
|
||||
getline(infile, line); // should be 10 300
|
||||
CV_Assert(line=="10\t300");
|
||||
unsigned int num = 0;
|
||||
while (getline(infile, line))
|
||||
{
|
||||
if (0 == (num % 600))
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
}
|
||||
|
||||
vector<string> elems;
|
||||
split(line, elems, '\t');
|
||||
|
||||
Ptr<FR_lfwObj> curr(new FR_lfwObj);
|
||||
string &person1 = elems[0];
|
||||
unsigned int imageNumber1 = atoi(elems[1].c_str())-1;
|
||||
curr->image1 = person1 + "/" + faces[person1][imageNumber1];
|
||||
|
||||
string person2;
|
||||
unsigned int imageNumber2;
|
||||
if (3 == elems.size())
|
||||
{
|
||||
person2 = elems[0];
|
||||
imageNumber2 = atoi(elems[2].c_str())-1;
|
||||
curr->same = true;
|
||||
} else
|
||||
{
|
||||
person2 = elems[2];
|
||||
imageNumber2 = atoi(elems[3].c_str())-1;
|
||||
curr->same = false;
|
||||
}
|
||||
curr->image2 = person2 + "/" + faces[person2][imageNumber2];
|
||||
|
||||
test.back().push_back(curr);
|
||||
|
||||
num++;
|
||||
}
|
||||
infile.close();
|
||||
|
||||
// dev train loading to train[0]
|
||||
ifstream infile2((path + "pairsDevTrain.txt").c_str());
|
||||
getline(infile2, line); // should 1100
|
||||
CV_Assert(line=="1100");
|
||||
while (getline(infile2, line))
|
||||
{
|
||||
vector<string> elems;
|
||||
split(line, elems, '\t');
|
||||
|
||||
Ptr<FR_lfwObj> curr(new FR_lfwObj);
|
||||
string &person1 = elems[0];
|
||||
unsigned int imageNumber1 = atoi(elems[1].c_str())-1;
|
||||
curr->image1 = person1 + "/" + faces[person1][imageNumber1];
|
||||
|
||||
string person2;
|
||||
unsigned int imageNumber2;
|
||||
if (3 == elems.size())
|
||||
{
|
||||
person2 = elems[0];
|
||||
imageNumber2 = atoi(elems[2].c_str())-1;
|
||||
curr->same = true;
|
||||
} else
|
||||
{
|
||||
person2 = elems[2];
|
||||
imageNumber2 = atoi(elems[3].c_str())-1;
|
||||
curr->same = false;
|
||||
}
|
||||
curr->image2 = person2 + "/" + faces[person2][imageNumber2];
|
||||
|
||||
train[0].push_back(curr);
|
||||
}
|
||||
infile2.close();
|
||||
|
||||
// dev train loading to validation[0]
|
||||
ifstream infile3((path + "pairsDevTest.txt").c_str());
|
||||
getline(infile3, line); // should 500
|
||||
CV_Assert(line=="500");
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
while (getline(infile3, line))
|
||||
{
|
||||
vector<string> elems;
|
||||
split(line, elems, '\t');
|
||||
|
||||
Ptr<FR_lfwObj> curr(new FR_lfwObj);
|
||||
string &person1 = elems[0];
|
||||
unsigned int imageNumber1 = atoi(elems[1].c_str())-1;
|
||||
curr->image1 = person1 + "/" + faces[person1][imageNumber1];
|
||||
|
||||
string person2;
|
||||
unsigned int imageNumber2;
|
||||
if (3 == elems.size())
|
||||
{
|
||||
person2 = elems[0];
|
||||
imageNumber2 = atoi(elems[2].c_str())-1;
|
||||
curr->same = true;
|
||||
} else
|
||||
{
|
||||
person2 = elems[2];
|
||||
imageNumber2 = atoi(elems[3].c_str())-1;
|
||||
curr->same = false;
|
||||
}
|
||||
curr->image2 = person2 + "/" + faces[person2][imageNumber2];
|
||||
|
||||
validation[0].push_back(curr);
|
||||
}
|
||||
infile3.close();
|
||||
}
|
||||
|
||||
Ptr<FR_lfw> FR_lfw::create()
|
||||
{
|
||||
return Ptr<FR_lfwImp>(new FR_lfwImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/gr_chalearn.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class GR_chalearnImp CV_FINAL : public GR_chalearn
|
||||
{
|
||||
public:
|
||||
GR_chalearnImp() {}
|
||||
//GR_chalearnImp(const string &path);
|
||||
virtual ~GR_chalearnImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void loadDatasetPart(const string &path, vector< Ptr<Object> > &dataset_, bool loadLabels);
|
||||
};
|
||||
|
||||
/*GR_chalearnImp::GR_chalearnImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void GR_chalearnImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void GR_chalearnImp::loadDatasetPart(const string &path, vector< Ptr<Object> > &dataset_, bool loadLabels)
|
||||
{
|
||||
vector<string> fileNames;
|
||||
getDirList(path, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
Ptr<GR_chalearnObj> curr(new GR_chalearnObj);
|
||||
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");
|
||||
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());
|
||||
|
||||
// loading ground truth
|
||||
if (loadLabels)
|
||||
{
|
||||
string fileGroundTruth(path + curr->name + "/" + curr->name + "_labels.csv");
|
||||
ifstream infileGroundTruth(fileGroundTruth.c_str());
|
||||
while (getline(infileGroundTruth, line))
|
||||
{
|
||||
vector<string> 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());
|
||||
|
||||
curr->groundTruths.push_back(currGroundTruth);
|
||||
}
|
||||
}
|
||||
|
||||
// loading skeleton
|
||||
string fileSkeleton(path + curr->name + "/" + curr->name + "_skeleton.csv");
|
||||
ifstream infileSkeleton(fileSkeleton.c_str());
|
||||
while (getline(infileSkeleton, line))
|
||||
{
|
||||
skeleton currSkeleton;
|
||||
|
||||
vector<string> elems2;
|
||||
split(line, elems2, ',');
|
||||
|
||||
for (unsigned int i=0, numJoin=0; i<elems2.size(); i+=9, ++numJoin)
|
||||
{
|
||||
currSkeleton.s[numJoin].Wx = atof(elems2[i+0].c_str());
|
||||
currSkeleton.s[numJoin].Wy = atof(elems2[i+1].c_str());
|
||||
currSkeleton.s[numJoin].Wz = atof(elems2[i+2].c_str());
|
||||
currSkeleton.s[numJoin].Rx = atof(elems2[i+3].c_str());
|
||||
currSkeleton.s[numJoin].Ry = atof(elems2[i+4].c_str());
|
||||
currSkeleton.s[numJoin].Rz = atof(elems2[i+5].c_str());
|
||||
currSkeleton.s[numJoin].Rw = atof(elems2[i+6].c_str());
|
||||
currSkeleton.s[numJoin].Px = atof(elems2[i+7].c_str());
|
||||
currSkeleton.s[numJoin].Py = atof(elems2[i+8].c_str());
|
||||
}
|
||||
|
||||
curr->skeletons.push_back(currSkeleton);
|
||||
}
|
||||
|
||||
dataset_.push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
void GR_chalearnImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string pathTrain(path + "Train/");
|
||||
loadDatasetPart(pathTrain, train.back(), true);
|
||||
|
||||
// freely available validation set doesn't have labels
|
||||
string pathValidation(path + "Validation/");
|
||||
loadDatasetPart(pathValidation, validation.back(), false);
|
||||
}
|
||||
|
||||
Ptr<GR_chalearn> GR_chalearn::create()
|
||||
{
|
||||
return Ptr<GR_chalearnImp>(new GR_chalearnImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/gr_skig.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class GR_skigImp CV_FINAL : public GR_skig
|
||||
{
|
||||
public:
|
||||
GR_skigImp() {}
|
||||
//GR_skigImp(const string &path);
|
||||
virtual ~GR_skigImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*GR_skigImp::GR_skigImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void GR_skigImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void GR_skigImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
for (unsigned int i=1; i<=6; ++i)
|
||||
{
|
||||
char number[2];
|
||||
sprintf(number, "%u", i);
|
||||
string pathDatasetRgb(path + "subject" + number + "_rgb/");
|
||||
string pathDatasetDep(path + "subject" + number + "_dep/");
|
||||
|
||||
vector<string> fileNames;
|
||||
getDirList(pathDatasetRgb, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &file = *it;
|
||||
|
||||
Ptr<GR_skigObj> curr(new GR_skigObj);
|
||||
curr->rgb = pathDatasetRgb + file;
|
||||
curr->dep = file;
|
||||
curr->dep[0] = 'K';
|
||||
curr->dep = pathDatasetDep + curr->dep;
|
||||
|
||||
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.back().push_back(curr);
|
||||
} else
|
||||
{
|
||||
printf("incorrect file name: %s", file.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<GR_skig> GR_skig::create()
|
||||
{
|
||||
return Ptr<GR_skigImp>(new GR_skigImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/hpe_humaneva.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class HPE_humanevaImp CV_FINAL : public HPE_humaneva
|
||||
{
|
||||
public:
|
||||
HPE_humanevaImp() {}
|
||||
//HPE_humanevaImp(const string &path);
|
||||
virtual ~HPE_humanevaImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*HPE_humanevaImp::HPE_humanevaImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void HPE_humanevaImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void HPE_humanevaImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
for (unsigned int i=1; i<=4; ++i)
|
||||
{
|
||||
char number[2];
|
||||
sprintf(number, "%u", i);
|
||||
string pathDatasetI(path + "S" + number + "/Image_Data/");
|
||||
string pathDatasetS(path + "S" + number + "/Sync_Data/");
|
||||
|
||||
vector<string> fileNames;
|
||||
getDirList(pathDatasetI, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &file = *it;
|
||||
|
||||
vector<string> elems;
|
||||
split(file, elems, '_');
|
||||
if (elems.size() != 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Ptr<HPE_humanevaObj> curr(new HPE_humanevaObj);
|
||||
curr->person = (char)i;
|
||||
curr->action = elems[0];
|
||||
curr->type1 = atoi(elems[1].c_str());
|
||||
curr->fileName = pathDatasetI+file;
|
||||
|
||||
unsigned int type2End = 2;
|
||||
if (elems[2][type2End+1] != ')')
|
||||
{
|
||||
type2End = 3;
|
||||
}
|
||||
curr->type2 = elems[2].substr(1, type2End);
|
||||
|
||||
file = file.substr(0, file.length()-3) + "ofs";
|
||||
ifstream infileOFS((pathDatasetS + file).c_str());
|
||||
string line;
|
||||
unsigned int j = 0;
|
||||
while (getline(infileOFS, line))
|
||||
{
|
||||
curr->ofs(0, j) = atof(line.c_str());
|
||||
++j;
|
||||
}
|
||||
|
||||
train.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// HumanEva II
|
||||
//
|
||||
class HPE_humanevaImpII : public HPE_humaneva
|
||||
{
|
||||
public:
|
||||
HPE_humanevaImpII() {}
|
||||
//HPE_humanevaImpII(const string &path);
|
||||
virtual ~HPE_humanevaImpII() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*HPE_humanevaImpII::HPE_humanevaImpII(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void HPE_humanevaImpII::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void HPE_humanevaImpII::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
for (unsigned int i=1; i<=2; ++i)
|
||||
{
|
||||
char number[2];
|
||||
sprintf(number, "%u", i*2); // 2 & 4
|
||||
string pathDatasetI(path + "S" + number + "/Image_Data/");
|
||||
string pathDatasetS(path + "S" + number + "/Sync_Data/");
|
||||
|
||||
vector<string> fileNames;
|
||||
getDirList(pathDatasetI, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &file = *it;
|
||||
|
||||
vector<string> elems;
|
||||
split(file, elems, '_');
|
||||
if (elems.size() != 3)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Ptr<HPE_humanevaObj> curr(new HPE_humanevaObj);
|
||||
curr->person = (char)i;
|
||||
curr->action = elems[0];
|
||||
curr->type1 = atoi(elems[1].c_str());
|
||||
curr->fileName = pathDatasetI+file;
|
||||
|
||||
unsigned int type2End = 2;
|
||||
if (elems[2][type2End+1] != ')')
|
||||
{
|
||||
type2End = 3;
|
||||
}
|
||||
curr->type2 = elems[2].substr(1, type2End);
|
||||
|
||||
vector<string> imageNames;
|
||||
getDirList(curr->fileName, imageNames);
|
||||
for (vector<string>::iterator itI=imageNames.begin(); itI!=imageNames.end(); ++itI)
|
||||
{
|
||||
string &image = *itI;
|
||||
if (image.substr(image.length()-3) == "png")
|
||||
{
|
||||
curr->imageNames.push_back(image);
|
||||
}
|
||||
}
|
||||
|
||||
file = file.substr(0, file.length()) + ".ofs";
|
||||
ifstream infileOFS((pathDatasetS + file).c_str());
|
||||
string line;
|
||||
unsigned int j = 0;
|
||||
while (getline(infileOFS, line))
|
||||
{
|
||||
curr->ofs(0, j) = atof(line.c_str());
|
||||
++j;
|
||||
}
|
||||
|
||||
train.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<HPE_humaneva> HPE_humaneva::create(int num)
|
||||
{
|
||||
if (humaneva_2==num)
|
||||
{
|
||||
return Ptr<HPE_humanevaImpII>(new HPE_humanevaImpII);
|
||||
}
|
||||
return Ptr<HPE_humanevaImp>(new HPE_humanevaImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/hpe_parse.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class HPE_parseImp CV_FINAL : public HPE_parse
|
||||
{
|
||||
public:
|
||||
HPE_parseImp() {}
|
||||
//HPE_parseImp(const string &path);
|
||||
virtual ~HPE_parseImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*HPE_parseImp::HPE_parseImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void HPE_parseImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void HPE_parseImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
unsigned int i=0;
|
||||
vector<string> fileNames;
|
||||
getDirList(path, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &file = *it, ext;
|
||||
size_t len = file.length();
|
||||
if (len>4)
|
||||
{
|
||||
ext = file.substr(len-4, 4);
|
||||
}
|
||||
if (ext==".jpg")
|
||||
{
|
||||
Ptr<HPE_parseObj> curr(new HPE_parseObj);
|
||||
curr->name = file;
|
||||
|
||||
if (i<100)
|
||||
{
|
||||
train.back().push_back(curr);
|
||||
} else
|
||||
{
|
||||
test.back().push_back(curr);
|
||||
}
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<HPE_parse> HPE_parse::create()
|
||||
{
|
||||
return Ptr<HPE_parseImp>(new HPE_parseImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/ir_affine.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class IR_affineImp CV_FINAL : public IR_affine
|
||||
{
|
||||
public:
|
||||
IR_affineImp() {}
|
||||
//IR_affineImp(const string &path);
|
||||
virtual ~IR_affineImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*IR_affineImp::IR_affineImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void IR_affineImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void IR_affineImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
// detect image extension
|
||||
string ext;
|
||||
vector<string> fileNames;
|
||||
getDirList(path, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &name = *it;
|
||||
if (name.length()>=8 && name.substr(0, 3)=="img")
|
||||
{
|
||||
ext = name.substr(name.length()-4, 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i=1; i<=6; ++i)
|
||||
{
|
||||
Ptr<IR_affineObj> curr(new IR_affineObj);
|
||||
|
||||
char tmp[2];
|
||||
sprintf(tmp, "%u", i);
|
||||
curr->imageName = path + "img" + tmp + ext;
|
||||
|
||||
if (i>1)
|
||||
{
|
||||
string matName(path + "H1to" + tmp + "p");
|
||||
ifstream infile(matName.c_str());
|
||||
for (int k=0; k<3; ++k)
|
||||
{
|
||||
for (int j=0; j<3; ++j)
|
||||
{
|
||||
infile >> curr->mat(k, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
train.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<IR_affine> IR_affine::create()
|
||||
{
|
||||
return Ptr<IR_affineImp>(new IR_affineImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/ir_robot.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class IR_robotImp CV_FINAL : public IR_robot
|
||||
{
|
||||
public:
|
||||
IR_robotImp() {}
|
||||
//IR_robotImp(const string &path);
|
||||
virtual ~IR_robotImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*IR_robotImp::IR_robotImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void IR_robotImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void IR_robotImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
vector<string> fileNames;
|
||||
getDirList(path, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
Ptr<IR_robotObj> curr(new IR_robotObj);
|
||||
curr->name = *it;
|
||||
|
||||
string pathScene(path + curr->name + "/");
|
||||
vector<string> sceneNames;
|
||||
getDirList(pathScene, sceneNames);
|
||||
int currImageNum = 0;
|
||||
for (vector<string>::iterator itScene=sceneNames.begin(); itScene!=sceneNames.end(); ++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.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<IR_robot> IR_robot::create()
|
||||
{
|
||||
return Ptr<IR_robotImp>(new IR_robotImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/is_bsds.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class IS_bsdsImp CV_FINAL : public IS_bsds
|
||||
{
|
||||
public:
|
||||
IS_bsdsImp() {}
|
||||
//IS_bsdsImp(const string &path);
|
||||
virtual ~IS_bsdsImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_);
|
||||
};
|
||||
|
||||
void IS_bsdsImp::loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_)
|
||||
{
|
||||
ifstream infile(fileName.c_str());
|
||||
string imageName;
|
||||
while (infile >> imageName)
|
||||
{
|
||||
Ptr<IS_bsdsObj> curr(new IS_bsdsObj);
|
||||
curr->name = imageName;
|
||||
dataset_.push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/*IS_bsdsImp::IS_bsdsImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void IS_bsdsImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void IS_bsdsImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string trainName(path + "iids_train.txt");
|
||||
string testName(path + "iids_test.txt");
|
||||
|
||||
// loading train
|
||||
loadDatasetPart(trainName, train.back());
|
||||
|
||||
// loading test
|
||||
loadDatasetPart(testName, test.back());
|
||||
}
|
||||
|
||||
Ptr<IS_bsds> IS_bsds::create()
|
||||
{
|
||||
return Ptr<IS_bsdsImp>(new IS_bsdsImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/is_weizmann.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class IS_weizmannImp CV_FINAL : public IS_weizmann
|
||||
{
|
||||
public:
|
||||
IS_weizmannImp() {}
|
||||
//IS_weizmannImp(const string &path);
|
||||
virtual ~IS_weizmannImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*IS_weizmannImp::IS_weizmannImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void IS_weizmannImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void IS_weizmannImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
vector<string> fileNames;
|
||||
getDirList(path, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &imageName = *it;
|
||||
if (imageName.find('.') == string::npos) // only folders, discard .mat
|
||||
{
|
||||
Ptr<IS_weizmannObj> curr(new IS_weizmannObj);
|
||||
curr->imageName = imageName;
|
||||
curr->srcBw = imageName + "/src_bw/" + imageName + ".png";
|
||||
curr->srcColor = imageName + "/src_color/" + imageName + ".png";
|
||||
|
||||
curr->humanSeg = imageName + "human_seg/";
|
||||
|
||||
train.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<IS_weizmann> IS_weizmann::create()
|
||||
{
|
||||
return Ptr<IS_weizmannImp>(new IS_weizmannImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/msm_epfl.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class MSM_epflImp CV_FINAL : public MSM_epfl
|
||||
{
|
||||
public:
|
||||
MSM_epflImp() {}
|
||||
//MSM_epflImp(const string &path);
|
||||
virtual ~MSM_epflImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*MSM_epflImp::MSM_epflImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void MSM_epflImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void MSM_epflImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string pathBounding(path + "bounding/");
|
||||
string pathCamera(path + "camera/");
|
||||
string pathP(path + "P/");
|
||||
string pathPng(path + "png/");
|
||||
|
||||
vector<string> fileNames;
|
||||
getDirList(pathPng, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
Ptr<MSM_epflObj> curr(new MSM_epflObj);
|
||||
curr->imageName = *it;
|
||||
|
||||
// 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.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<MSM_epfl> MSM_epfl::create()
|
||||
{
|
||||
return Ptr<MSM_epflImp>(new MSM_epflImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/msm_middlebury.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class MSM_middleburyImp CV_FINAL : public MSM_middlebury
|
||||
{
|
||||
public:
|
||||
MSM_middleburyImp() {}
|
||||
//MSM_middleburyImp(const string &path);
|
||||
virtual ~MSM_middleburyImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*MSM_middleburyImp::MSM_middleburyImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void MSM_middleburyImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void MSM_middleburyImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string name(path.substr(0, path.length()-1));
|
||||
size_t start = name.rfind('/');
|
||||
name = name.substr(start+1, name.length()-start);
|
||||
|
||||
string angName(path + name + "_ang.txt");
|
||||
string parName(path + name + "_par.txt");
|
||||
|
||||
ifstream infile(parName.c_str());
|
||||
string imageName;
|
||||
infile >> imageName; // skip header
|
||||
while (infile >> imageName)
|
||||
{
|
||||
Ptr<MSM_middleburyObj> curr(new MSM_middleburyObj);
|
||||
curr->imageName = imageName;
|
||||
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
for (int j=0; j<3; ++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);
|
||||
}
|
||||
}
|
||||
for (int i=0; i<3; ++i)
|
||||
{
|
||||
infile >> curr->t[i];
|
||||
}
|
||||
|
||||
train.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<MSM_middlebury> MSM_middlebury::create()
|
||||
{
|
||||
return Ptr<MSM_middleburyImp>(new MSM_middleburyImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/or_imagenet.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class OR_imagenetImp CV_FINAL : public OR_imagenet
|
||||
{
|
||||
public:
|
||||
OR_imagenetImp() {}
|
||||
//OR_imagenetImp(const string &path);
|
||||
virtual ~OR_imagenetImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void numberToString(int number, string &out);
|
||||
};
|
||||
|
||||
/*OR_imagenetImp::OR_imagenetImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void OR_imagenetImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void OR_imagenetImp::numberToString(int number, string &out)
|
||||
{
|
||||
char numberStr[9];
|
||||
sprintf(numberStr, "%u", number);
|
||||
for (unsigned int i=0; i<8-strlen(numberStr); ++i)
|
||||
{
|
||||
out += "0";
|
||||
}
|
||||
out += numberStr;
|
||||
}
|
||||
|
||||
void OR_imagenetImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
map<string, int> labels;
|
||||
ifstream infile((path + "labels.txt").c_str());
|
||||
string line;
|
||||
while (getline(infile, line))
|
||||
{
|
||||
vector<string> elems;
|
||||
split(line, elems, ',');
|
||||
string syn = elems[0];
|
||||
int number = atoi(elems[1].c_str());
|
||||
|
||||
labels.insert(make_pair(syn, number));
|
||||
}
|
||||
|
||||
string pathTrain(path + "train/");
|
||||
vector<string> fileNames;
|
||||
getDirList(pathTrain, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string pathSyn((*it) + "/");
|
||||
vector<string> fileNamesSyn;
|
||||
getDirList((pathTrain + pathSyn), fileNamesSyn);
|
||||
for (vector<string>::iterator itSyn=fileNamesSyn.begin(); itSyn!=fileNamesSyn.end(); ++itSyn)
|
||||
{
|
||||
Ptr<OR_imagenetObj> curr(new OR_imagenetObj);
|
||||
curr->image = "train/" + pathSyn + *itSyn;
|
||||
curr->id = labels[*it];
|
||||
|
||||
train.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
ifstream infileVal((path + "ILSVRC2010_validation_ground_truth.txt").c_str());
|
||||
while (getline(infileVal, line))
|
||||
{
|
||||
Ptr<OR_imagenetObj> curr(new OR_imagenetObj);
|
||||
curr->id = atoi(line.c_str());
|
||||
numberToString((int)validation.back().size()+1, curr->image);
|
||||
curr->image = "val/ILSVRC2010_val_" + curr->image + ".JPEG";
|
||||
|
||||
validation.back().push_back(curr);
|
||||
}
|
||||
|
||||
vector<int> testGT;
|
||||
ifstream infileTest((path + "ILSVRC2010_test_ground_truth.txt").c_str());
|
||||
while (getline(infileTest, line))
|
||||
{
|
||||
testGT.push_back(atoi(line.c_str()));
|
||||
}
|
||||
if (testGT.size()==0) // have no test labels, set them to 1000 - unknown
|
||||
{
|
||||
for (int i=0; i<150000; ++i)
|
||||
{
|
||||
testGT.push_back(1000); // unknown
|
||||
}
|
||||
}
|
||||
|
||||
for (vector<int>::iterator it=testGT.begin(); it!=testGT.end(); ++it)
|
||||
{
|
||||
Ptr<OR_imagenetObj> curr(new OR_imagenetObj);
|
||||
curr->id = *it;
|
||||
numberToString((int)test.back().size()+1, curr->image);
|
||||
curr->image = "test/ILSVRC2010_test_" + curr->image + ".JPEG";
|
||||
|
||||
test.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<OR_imagenet> OR_imagenet::create()
|
||||
{
|
||||
return Ptr<OR_imagenetImp>(new OR_imagenetImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/or_mnist.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class OR_mnistImp CV_FINAL : public OR_mnist
|
||||
{
|
||||
public:
|
||||
OR_mnistImp() {}
|
||||
//OR_mnistImp(const string &path);
|
||||
virtual ~OR_mnistImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void loadDatasetPart(const string &imagesFile, const string &labelsFile, unsigned int num, vector< Ptr<Object> > &dataset_);
|
||||
};
|
||||
|
||||
/*OR_mnistImp::OR_mnistImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void OR_mnistImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void OR_mnistImp::loadDatasetPart(const string &imagesFile, const string &labelsFile, unsigned int num, vector< Ptr<Object> > &dataset_)
|
||||
{
|
||||
FILE *f = fopen(imagesFile.c_str(), "rb");
|
||||
fseek(f, 16, SEEK_CUR);
|
||||
unsigned int imageSize = 28*28;
|
||||
char *images = new char[num*imageSize];
|
||||
size_t res = fread(images, 1, num*imageSize, f);
|
||||
fclose(f);
|
||||
if (num*imageSize != res)
|
||||
{
|
||||
delete[] images;
|
||||
return;
|
||||
}
|
||||
f = fopen(labelsFile.c_str(), "rb");
|
||||
fseek(f, 8, SEEK_CUR);
|
||||
char *labels = new char[num];
|
||||
res = fread(labels, 1, num, f);
|
||||
fclose(f);
|
||||
if (num != res)
|
||||
{
|
||||
delete[] images;
|
||||
delete[] labels;
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i<num; ++i)
|
||||
{
|
||||
Ptr<OR_mnistObj> curr(new OR_mnistObj);
|
||||
curr->label = labels[i];
|
||||
|
||||
curr->image = Mat(28, 28, CV_8U);
|
||||
unsigned int imageIdx = i*imageSize;
|
||||
for (int j=0; j<curr->image.rows; ++j)
|
||||
{
|
||||
char *im = curr->image.ptr<char>(j);
|
||||
for (int k=0; k<curr->image.cols; ++k)
|
||||
{
|
||||
im[k] = images[imageIdx + j*28 + k];
|
||||
}
|
||||
}
|
||||
|
||||
dataset_.push_back(curr);
|
||||
}
|
||||
delete[] images;
|
||||
delete[] labels;
|
||||
}
|
||||
|
||||
void OR_mnistImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string trainImagesFile(path + "train-images-idx3-ubyte");
|
||||
string trainLabelsFile(path + "train-labels-idx1-ubyte");
|
||||
loadDatasetPart(trainImagesFile, trainLabelsFile, 60000, train.back());
|
||||
|
||||
string testImagesFile(path + "t10k-images-idx3-ubyte");
|
||||
string testLabelsFile(path + "t10k-labels-idx1-ubyte");
|
||||
loadDatasetPart(testImagesFile, testLabelsFile, 10000, test.back());
|
||||
}
|
||||
|
||||
Ptr<OR_mnist> OR_mnist::create()
|
||||
{
|
||||
return Ptr<OR_mnistImp>(new OR_mnistImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/or_pascal.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
#if defined(__GNUC__) && __GNUC__ >= 5
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsuggest-override"
|
||||
#endif
|
||||
#include "tinyxml2/tinyxml2.h"
|
||||
#if defined(__GNUC__) && __GNUC__ >= 5
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
#include <fstream>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
using namespace cv::tinyxml2;
|
||||
|
||||
class OR_pascalImp CV_FINAL : public OR_pascal
|
||||
{
|
||||
public:
|
||||
OR_pascalImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path, const string &nameImageSet, vector< Ptr<Object> > &imageSet);
|
||||
Ptr<Object> parseAnnotation(const string &path, const string &id);
|
||||
const char* parseNodeText(XMLElement* node, const string &nodeName, const string &defaultValue);
|
||||
};
|
||||
|
||||
|
||||
void OR_pascalImp::load(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
loadDataset(path, "train", train.back());
|
||||
loadDataset(path, "test", test.back());
|
||||
loadDataset(path, "val", validation.back());
|
||||
}
|
||||
|
||||
void OR_pascalImp::loadDataset(const string &path, const string &nameImageSet, vector< Ptr<Object> > &imageSet)
|
||||
{
|
||||
string pathImageSets(path + "ImageSets/Main/");
|
||||
string imageList = pathImageSets + nameImageSet + ".txt";
|
||||
|
||||
ifstream in(imageList.c_str());
|
||||
string error_message = format("Image list not exists!\n%s", imageList.c_str());
|
||||
|
||||
if (!in.is_open())
|
||||
CV_Error(Error::StsBadArg, error_message);
|
||||
|
||||
string id = "";
|
||||
|
||||
while( getline(in, id) )
|
||||
{
|
||||
if( strcmp(nameImageSet.c_str(), "test") == 0 ) // test set ground truth is not available
|
||||
{
|
||||
Ptr<OR_pascalObj> annotation(new OR_pascalObj);
|
||||
annotation->filename = path + "JPEGImages/" + id + ".jpg";
|
||||
imageSet.push_back(annotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
imageSet.push_back(parseAnnotation(path, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* OR_pascalImp::parseNodeText(XMLElement* node, const string &nodeName, const string &defaultValue)
|
||||
{
|
||||
XMLElement* child = node->FirstChildElement(nodeName.c_str());
|
||||
if ( child == 0 )
|
||||
return defaultValue.c_str();
|
||||
|
||||
const char* e = child->GetText();
|
||||
if( e == 0 )
|
||||
return defaultValue.c_str();
|
||||
|
||||
return e ;
|
||||
}
|
||||
|
||||
Ptr<Object> OR_pascalImp::parseAnnotation(const string &path, const string &id)
|
||||
{
|
||||
string pathAnnotations(path + "Annotations/");
|
||||
string pathImages(path + "JPEGImages/");
|
||||
Ptr<OR_pascalObj> annotation(new OR_pascalObj);
|
||||
|
||||
XMLDocument doc;
|
||||
string xml_file = pathAnnotations + id + ".xml";
|
||||
|
||||
XMLError error_code = doc.LoadFile(xml_file.c_str());
|
||||
string error_message = format("Parsing XML failed. Error code = %d. \nFile = %s", error_code, xml_file.c_str());
|
||||
switch (error_code)
|
||||
{
|
||||
case XML_SUCCESS:
|
||||
break;
|
||||
case XML_ERROR_FILE_NOT_FOUND:
|
||||
error_message = "XML file not found! " + error_message;
|
||||
CV_Error(Error::StsParseError, error_message);
|
||||
default:
|
||||
CV_Error(Error::StsParseError, error_message);
|
||||
break;
|
||||
}
|
||||
|
||||
// <annotation/>
|
||||
XMLElement *xml_ann = doc.RootElement();
|
||||
|
||||
// <filename/>
|
||||
string img_name = xml_ann->FirstChildElement("filename")->GetText();
|
||||
annotation->filename = pathImages + img_name;
|
||||
|
||||
// <size/>
|
||||
XMLElement *sz = xml_ann->FirstChildElement("size");
|
||||
int width = atoi(sz->FirstChildElement("width")->GetText());
|
||||
int height = atoi(sz->FirstChildElement("height")->GetText());
|
||||
int depth = atoi(sz->FirstChildElement("depth")->GetText());
|
||||
annotation->width = width;
|
||||
annotation->height = height;
|
||||
annotation->depth = depth;
|
||||
|
||||
// <object/>
|
||||
vector<PascalObj> objects;
|
||||
XMLElement *xml_obj = xml_ann->FirstChildElement("object");
|
||||
|
||||
while (xml_obj)
|
||||
{
|
||||
PascalObj pascal_obj;
|
||||
pascal_obj.name = xml_obj->FirstChildElement("name")->GetText();
|
||||
pascal_obj.pose = parseNodeText(xml_obj, "pose", "Unspecified");
|
||||
pascal_obj.truncated = atoi(parseNodeText(xml_obj, "truncated", "0")) > 0;
|
||||
pascal_obj.difficult = atoi(parseNodeText(xml_obj, "difficult", "0")) > 0;
|
||||
pascal_obj.occluded = atoi(parseNodeText(xml_obj, "occluded", "0")) > 0;
|
||||
|
||||
// <bndbox/>
|
||||
XMLElement *xml_bndbox = xml_obj->FirstChildElement("bndbox");
|
||||
pascal_obj.xmin = atoi(xml_bndbox->FirstChildElement("xmin")->GetText());
|
||||
pascal_obj.ymin = atoi(xml_bndbox->FirstChildElement("ymin")->GetText());
|
||||
pascal_obj.xmax = atoi(xml_bndbox->FirstChildElement("xmax")->GetText());
|
||||
pascal_obj.ymax = atoi(xml_bndbox->FirstChildElement("ymax")->GetText());
|
||||
|
||||
// <part/>
|
||||
vector<PascalPart> parts;
|
||||
XMLElement *xml_part = xml_obj->FirstChildElement("part");
|
||||
|
||||
while (xml_part)
|
||||
{
|
||||
PascalPart pascal_part;
|
||||
pascal_part.name = xml_part->FirstChildElement("name")->GetText();
|
||||
|
||||
xml_bndbox = xml_part->FirstChildElement("bndbox");
|
||||
pascal_part.xmin = atoi(xml_bndbox->FirstChildElement("xmin")->GetText());
|
||||
pascal_part.ymin = atoi(xml_bndbox->FirstChildElement("ymin")->GetText());
|
||||
pascal_part.xmax = atoi(xml_bndbox->FirstChildElement("xmax")->GetText());
|
||||
pascal_part.ymax = atoi(xml_bndbox->FirstChildElement("ymax")->GetText());
|
||||
parts.push_back(pascal_part);
|
||||
|
||||
xml_part = xml_part->NextSiblingElement("part");
|
||||
}
|
||||
|
||||
pascal_obj.parts = parts;
|
||||
objects.push_back(pascal_obj);
|
||||
|
||||
xml_obj = xml_obj->NextSiblingElement("object");
|
||||
}
|
||||
|
||||
annotation->objects = objects;
|
||||
|
||||
return annotation;
|
||||
}
|
||||
|
||||
Ptr<OR_pascal> OR_pascal::create()
|
||||
{
|
||||
return Ptr<OR_pascalImp>(new OR_pascalImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/or_sun.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class OR_sunImp CV_FINAL : public OR_sun
|
||||
{
|
||||
public:
|
||||
OR_sunImp() {}
|
||||
//OR_sunImp(const string &path);
|
||||
virtual ~OR_sunImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void loadDatasetPart(const string &path, vector< Ptr<Object> > &dataset_);
|
||||
|
||||
map<string, int> pathLabel;
|
||||
};
|
||||
|
||||
/*OR_sunImp::OR_sunImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void OR_sunImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void OR_sunImp::loadDatasetPart(const string &path, vector< Ptr<Object> > &dataset_)
|
||||
{
|
||||
string line;
|
||||
ifstream infile(path.c_str());
|
||||
while (getline(infile, line))
|
||||
{
|
||||
Ptr<OR_sunObj> curr(new OR_sunObj);
|
||||
curr->label = 397;
|
||||
curr->name = line;
|
||||
|
||||
size_t pos = curr->name.rfind('/');
|
||||
if (pos != string::npos)
|
||||
{
|
||||
string labelStr(curr->name.substr(0, pos+1));
|
||||
map<string, int>::iterator it = pathLabel.find(labelStr);
|
||||
if (it != pathLabel.end())
|
||||
{
|
||||
curr->label = (*it).second;
|
||||
} else
|
||||
{
|
||||
curr->label = (int)pathLabel.size();
|
||||
pathLabel.insert(make_pair(labelStr, curr->label));
|
||||
paths.push_back(labelStr);
|
||||
}
|
||||
curr->name = curr->name.substr(pos+1);
|
||||
}
|
||||
|
||||
dataset_.push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
void OR_sunImp::loadDataset(const string &path)
|
||||
{
|
||||
/*string classNameFile(path + "ClassName.txt");
|
||||
ifstream infile(classNameFile.c_str());
|
||||
string line;
|
||||
while (getline(infile, line))
|
||||
{
|
||||
Ptr<OR_sunObj> curr(new OR_sunObj);
|
||||
curr->name = line;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
train.back().push_back(curr);
|
||||
}*/
|
||||
|
||||
for (unsigned int i=1; i<=10; ++i)
|
||||
{
|
||||
char tmp[3];
|
||||
sprintf(tmp, "%u", i);
|
||||
string numStr;
|
||||
if (i<10)
|
||||
{
|
||||
numStr = string("0") + string(tmp);
|
||||
} else
|
||||
{
|
||||
numStr = tmp;
|
||||
}
|
||||
string trainFile(path + "Partitions/Training_" + numStr + ".txt");
|
||||
string testFile(path + "Partitions/Testing_" + numStr + ".txt");
|
||||
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
loadDatasetPart(trainFile, train.back());
|
||||
loadDatasetPart(testFile, test.back());
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<OR_sun> OR_sun::create()
|
||||
{
|
||||
return Ptr<OR_sunImp>(new OR_sunImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/pd_caltech.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class PD_caltechImp CV_FINAL : public PD_caltech
|
||||
{
|
||||
public:
|
||||
PD_caltechImp() {}
|
||||
//PD_caltechImp(const string &path);
|
||||
virtual ~PD_caltechImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*PD_caltechImp::PD_caltechImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void PD_caltechImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void PD_caltechImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
createDirectory((path + "../images/"));
|
||||
|
||||
vector<string> objectNames;
|
||||
getDirList(path, objectNames);
|
||||
for (vector<string>::iterator it=objectNames.begin(); it!=objectNames.end(); ++it)
|
||||
{
|
||||
Ptr<PD_caltechObj> curr(new PD_caltechObj);
|
||||
curr->name = *it;
|
||||
|
||||
string objectPath(path + "../images/" + curr->name + "/");
|
||||
createDirectory(objectPath);
|
||||
|
||||
string seqImagesPath(path + curr->name + "/");
|
||||
vector<string> seqNames;
|
||||
getDirList(seqImagesPath, seqNames);
|
||||
for (vector<string>::iterator itSeq=seqNames.begin(); itSeq!=seqNames.end(); ++itSeq)
|
||||
{
|
||||
string &seqName = *itSeq;
|
||||
|
||||
createDirectory((objectPath + seqName));
|
||||
|
||||
FILE *f = fopen((seqImagesPath + seqName).c_str(), "rb");
|
||||
|
||||
#define SKIP 28+8+512
|
||||
fseek(f, SKIP, SEEK_CUR);
|
||||
|
||||
unsigned int header[9];
|
||||
size_t res = fread(header, 9, 4, f);
|
||||
double fps;
|
||||
res = fread(&fps, 1, 8, f);
|
||||
fseek(f, 432, SEEK_CUR);
|
||||
|
||||
/*printf("width %u\n", header[0]);
|
||||
printf("height %u\n", header[1]);
|
||||
printf("imageBitDepth %u\n", header[2]);
|
||||
printf("imageBitDepthReal %u\n", header[3]);
|
||||
printf("imageSizeBytes %u\n", header[4]);
|
||||
printf("imageFormat %u\n", header[5]);
|
||||
printf("numFrames %u\n", numFrames);
|
||||
printf("fps %f\n", fps);
|
||||
printf("trueImageSize %u\n", header[8]);*/
|
||||
unsigned int numFrames = header[6];
|
||||
|
||||
string ext;
|
||||
switch (header[5])
|
||||
{
|
||||
case 100:
|
||||
case 200:
|
||||
ext = "raw";
|
||||
break;
|
||||
case 101:
|
||||
ext = "brgb8";
|
||||
break;
|
||||
case 102:
|
||||
case 201:
|
||||
ext = "jpg";
|
||||
break;
|
||||
case 103:
|
||||
ext = "jbrgb";
|
||||
break;
|
||||
case 001:
|
||||
case 002:
|
||||
ext = "png";
|
||||
break;
|
||||
}
|
||||
|
||||
for (unsigned int i=0; i<numFrames; ++i)
|
||||
{
|
||||
unsigned int size;
|
||||
res = fread(&size, 1, 4, f);
|
||||
|
||||
char imgName[20];
|
||||
sprintf(imgName, "/%u.%s", i, ext.c_str());
|
||||
curr->imageNames.push_back(imgName);
|
||||
|
||||
// comment fseek and uncomment next block to unpack all frames
|
||||
fseek(f, size, SEEK_CUR);
|
||||
/*char *img = new char[size];
|
||||
fread(img, size, 1, f);
|
||||
string imgPath(objectPath + seqName + imgName);
|
||||
FILE *fImg = fopen(imgPath.c_str(), "wb");
|
||||
fwrite(img, size, 1, fImg);
|
||||
fclose(fImg);
|
||||
delete[] img;*/
|
||||
|
||||
fseek(f, 12, SEEK_CUR);
|
||||
}
|
||||
|
||||
if (0 != res) // should fix unused variable warning
|
||||
{
|
||||
res = 0;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
train.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<PD_caltech> PD_caltech::create()
|
||||
{
|
||||
return Ptr<PD_caltechImp>(new PD_caltechImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2015, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/pd_inria.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class PD_inriaImp CV_FINAL : public PD_inria
|
||||
{
|
||||
public:
|
||||
PD_inriaImp() {}
|
||||
|
||||
virtual ~PD_inriaImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path, const string nameImageSet, vector< Ptr<Object> > &imageSet);
|
||||
void readTextLines(const string filename, vector< string > &lines);
|
||||
void parseAnnotation(const string filename, Ptr< PD_inriaObj > &object);
|
||||
};
|
||||
|
||||
void PD_inriaImp::load(const string &path)
|
||||
{
|
||||
// Training set
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
loadDataset(path, "Train", train.back());
|
||||
|
||||
// Testing set
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
loadDataset(path, "Test", test.back());
|
||||
|
||||
// There is no validation set
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
}
|
||||
|
||||
void PD_inriaImp::readTextLines(const string filename, vector< string > &lines)
|
||||
{
|
||||
ifstream in(filename.c_str());
|
||||
string error_message = "";
|
||||
|
||||
if (!in.is_open())
|
||||
{
|
||||
error_message = format("Unable to open file: \n%s\n", filename.c_str());
|
||||
CV_Error(Error::StsBadArg, error_message);
|
||||
}
|
||||
|
||||
string currline = "";
|
||||
|
||||
while (getline(in, currline))
|
||||
lines.push_back(currline);
|
||||
}
|
||||
|
||||
void PD_inriaImp::parseAnnotation(const string filename, Ptr< PD_inriaObj > &object)
|
||||
{
|
||||
string error_message = "";
|
||||
|
||||
ifstream in(filename.c_str());
|
||||
|
||||
if (!in.is_open())
|
||||
{
|
||||
error_message = format("Unable to open file: \n%s\n", filename.c_str());
|
||||
CV_Error(Error::StsBadArg, error_message);
|
||||
}
|
||||
|
||||
string imageSizeHeader = "Image size (X x Y x C) : ";
|
||||
string imageSizeFmt = imageSizeHeader + "%d x %d x %d";
|
||||
string objWithGTHeader = "Objects with ground truth : ";
|
||||
string objWithGTFmt = objWithGTHeader + "%d { \"PASperson\" }";
|
||||
string boundBoxHeader = "Bounding box for object ";
|
||||
string boundBoxFmt = boundBoxHeader + "%*d \"PASperson\" (Xmin, Ymin) - (Xmax, Ymax) : (%d, %d) - (%d, %d)";
|
||||
|
||||
string line = "";
|
||||
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int depth = 0;
|
||||
int xmin, ymin, xmax, ymax;
|
||||
|
||||
int numObjects = 0;
|
||||
|
||||
while (getline(in, line))
|
||||
{
|
||||
if (line[0] == '#' || !line[0])
|
||||
continue;
|
||||
|
||||
if (strstr(line.c_str(), imageSizeHeader.c_str()))
|
||||
{
|
||||
sscanf(line.c_str(), imageSizeFmt.c_str(), &width, &height, &depth);
|
||||
object->width = width;
|
||||
object->height = height;
|
||||
object->depth = depth;
|
||||
}
|
||||
else if (strstr(line.c_str(), objWithGTHeader.c_str()))
|
||||
{
|
||||
sscanf(line.c_str(), objWithGTFmt.c_str(), &numObjects);
|
||||
|
||||
if (numObjects <= 0)
|
||||
break;
|
||||
}
|
||||
else if (strstr(line.c_str(), boundBoxHeader.c_str()))
|
||||
{
|
||||
sscanf(line.c_str(), boundBoxFmt.c_str(), &xmin, &ymin, &xmax, &ymax);
|
||||
Rect bndbox;
|
||||
bndbox.x = xmin;
|
||||
bndbox.y = ymin;
|
||||
bndbox.width = xmax - xmin;
|
||||
bndbox.height = ymax - ymin;
|
||||
(object->bndboxes).push_back(bndbox);
|
||||
}
|
||||
}
|
||||
|
||||
CV_Assert((object->bndboxes).size() == (unsigned int)numObjects);
|
||||
}
|
||||
|
||||
void PD_inriaImp::loadDataset(const string &path, const string nameImageSet, vector< Ptr<Object> > &imageSet)
|
||||
{
|
||||
string listAnn = path + nameImageSet + "/annotations.lst";
|
||||
string listPos = path + nameImageSet + "/pos.lst";
|
||||
string listNeg = path + nameImageSet + "/neg.lst";
|
||||
|
||||
vector< string > fsAnn;
|
||||
vector< string > fsPos;
|
||||
vector< string > fsNeg;
|
||||
|
||||
// read file names
|
||||
readTextLines(listAnn, fsAnn);
|
||||
readTextLines(listPos, fsPos);
|
||||
readTextLines(listNeg, fsNeg);
|
||||
|
||||
CV_Assert(fsAnn.size() == fsPos.size());
|
||||
|
||||
for (unsigned int i = 0; i < fsPos.size(); i++)
|
||||
{
|
||||
Ptr<PD_inriaObj> curr(new PD_inriaObj);
|
||||
parseAnnotation(path + fsAnn[i], curr);
|
||||
curr->filename = path + fsPos[i];
|
||||
curr->sType = POS;
|
||||
|
||||
imageSet.push_back(curr);
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < fsNeg.size(); i++)
|
||||
{
|
||||
Ptr<PD_inriaObj> curr(new PD_inriaObj);
|
||||
curr->filename = path + fsNeg[i];
|
||||
curr->sType = NEG;
|
||||
|
||||
imageSet.push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<PD_inria> PD_inria::create()
|
||||
{
|
||||
return Ptr<PD_inriaImp>(new PD_inriaImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/slam_kitti.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SLAM_kittiImp CV_FINAL : public SLAM_kitti
|
||||
{
|
||||
public:
|
||||
SLAM_kittiImp() {}
|
||||
//SLAM_kittiImp(const string &path);
|
||||
virtual ~SLAM_kittiImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*SLAM_kittiImp::SLAM_kittiImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void SLAM_kittiImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void SLAM_kittiImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string pathSequence(path + "sequences/");
|
||||
vector<string> fileNames;
|
||||
getDirList(pathSequence, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
Ptr<SLAM_kittiObj> curr(new SLAM_kittiObj);
|
||||
curr->name = *it;
|
||||
|
||||
string currPath(pathSequence + curr->name);
|
||||
|
||||
// loading velodyne
|
||||
string pathVelodyne(currPath + "/velodyne/");
|
||||
vector<string> velodyneNames;
|
||||
getDirList(pathVelodyne, velodyneNames);
|
||||
for (vector<string>::iterator itV=velodyneNames.begin(); itV!=velodyneNames.end(); ++itV)
|
||||
{
|
||||
curr->velodyne.push_back(*itV);
|
||||
}
|
||||
|
||||
// loading gray & color images
|
||||
for (unsigned int i=0; i<=3; ++i)
|
||||
{
|
||||
char tmp[2];
|
||||
sprintf(tmp, "%u", i);
|
||||
string pathImage(currPath + "/image_" + tmp + "/");
|
||||
vector<string> imageNames;
|
||||
getDirList(pathImage, imageNames);
|
||||
for (vector<string>::iterator itImage=imageNames.begin(); itImage!=imageNames.end(); ++itImage)
|
||||
{
|
||||
curr->images[i].push_back(*itImage);
|
||||
}
|
||||
}
|
||||
|
||||
// loading times
|
||||
ifstream infile((currPath + "/times.txt").c_str());
|
||||
string line;
|
||||
while (getline(infile, line))
|
||||
{
|
||||
curr->times.push_back(atof(line.c_str()));
|
||||
}
|
||||
|
||||
// loading calibration
|
||||
ifstream infile2((currPath + "/calib.txt").c_str());
|
||||
for (unsigned int i=0; i<4; ++i)
|
||||
{
|
||||
getline(infile2, line);
|
||||
vector<string> elems;
|
||||
split(line, elems, ' ');
|
||||
vector<string>::iterator itE=elems.begin();
|
||||
for (++itE; itE!=elems.end(); ++itE)
|
||||
{
|
||||
curr->p[i].push_back(atof((*itE).c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
// loading poses
|
||||
ifstream infile3((path + "poses/" + curr->name + ".txt").c_str());
|
||||
while (getline(infile3, line))
|
||||
{
|
||||
pose p;
|
||||
|
||||
unsigned int i=0;
|
||||
vector<string> elems;
|
||||
split(line, elems, ' ');
|
||||
for (vector<string>::iterator itE=elems.begin(); itE!=elems.end(); ++itE, ++i)
|
||||
{
|
||||
if (i>11)
|
||||
{
|
||||
break;
|
||||
}
|
||||
p.elem[i] = atof((*itE).c_str());
|
||||
}
|
||||
|
||||
curr->posesArray.push_back(p);
|
||||
}
|
||||
|
||||
train.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<SLAM_kitti> SLAM_kitti::create()
|
||||
{
|
||||
return Ptr<SLAM_kittiImp>(new SLAM_kittiImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/slam_tumindoor.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SLAM_tumindoorImp CV_FINAL : public SLAM_tumindoor
|
||||
{
|
||||
public:
|
||||
SLAM_tumindoorImp() {}
|
||||
//SLAM_tumindoorImp(const string &path);
|
||||
virtual ~SLAM_tumindoorImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*SLAM_tumindoorImp::SLAM_tumindoorImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void SLAM_tumindoorImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void SLAM_tumindoorImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string infoPath(path + "info/");
|
||||
|
||||
// get info map name, .csv should be only one such file in folder
|
||||
string csvName;
|
||||
vector<string> infoNames;
|
||||
getDirList(infoPath, infoNames);
|
||||
for (vector<string>::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))
|
||||
{
|
||||
vector<string> elems;
|
||||
split(line, elems, ';');
|
||||
|
||||
Ptr<SLAM_tumindoorObj> curr(new SLAM_tumindoorObj);
|
||||
|
||||
curr->name = elems[0];
|
||||
if (curr->name.substr(0, strlen("dslr_left")) == "dslr_left")
|
||||
{
|
||||
curr->type = LEFT;
|
||||
} else
|
||||
if (curr->name.substr(0, strlen("dslr_right")) == "dslr_right")
|
||||
{
|
||||
curr->type = RIGHT;
|
||||
} else
|
||||
{
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
train.back().push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<SLAM_tumindoor> SLAM_tumindoor::create()
|
||||
{
|
||||
return Ptr<SLAM_tumindoorImp>(new SLAM_tumindoorImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#include "opencv2/datasets/sr_bsds.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SR_bsdsImp CV_FINAL : public SR_bsds
|
||||
{
|
||||
public:
|
||||
SR_bsdsImp() {}
|
||||
//SR_bsdsImp(const string &path);
|
||||
virtual ~SR_bsdsImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_);
|
||||
};
|
||||
|
||||
void SR_bsdsImp::loadDatasetPart(const string &fileName, vector< Ptr<Object> > &dataset_)
|
||||
{
|
||||
ifstream infile(fileName.c_str());
|
||||
string imageName;
|
||||
while (infile >> imageName)
|
||||
{
|
||||
Ptr<SR_bsdsObj> curr(new SR_bsdsObj);
|
||||
curr->imageName = imageName;
|
||||
dataset_.push_back(curr);
|
||||
}
|
||||
}
|
||||
|
||||
/*SR_bsdsImp::SR_bsdsImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void SR_bsdsImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void SR_bsdsImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string trainName(path + "iids_train.txt");
|
||||
string testName(path + "iids_test.txt");
|
||||
|
||||
// loading train
|
||||
loadDatasetPart(trainName, train.back());
|
||||
|
||||
// loading test
|
||||
loadDatasetPart(testName, test.back());
|
||||
}
|
||||
|
||||
Ptr<SR_bsds> SR_bsds::create()
|
||||
{
|
||||
return Ptr<SR_bsdsImp>(new SR_bsdsImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#include "opencv2/datasets/sr_div2k.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SR_div2kImp CV_FINAL : public SR_div2k
|
||||
{
|
||||
public:
|
||||
SR_div2kImp() {}
|
||||
//SR_div2kImp(const string &path);
|
||||
virtual ~SR_div2kImp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*SR_div2kImp::SR_div2kImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void SR_div2kImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void SR_div2kImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
vector<string> fileNames;
|
||||
getDirList(path, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &imageName = *it;
|
||||
Ptr<SR_div2kObj> curr(new SR_div2kObj);
|
||||
curr->imageName = imageName;
|
||||
train.back().push_back(curr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<SR_div2k> SR_div2k::create()
|
||||
{
|
||||
return Ptr<SR_div2kImp>(new SR_div2kImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#include "opencv2/datasets/sr_general100.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class SR_general100Imp CV_FINAL : public SR_general100
|
||||
{
|
||||
public:
|
||||
SR_general100Imp() {}
|
||||
//SR_general100Imp(const string &path);
|
||||
virtual ~SR_general100Imp() {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
};
|
||||
|
||||
/*SR_general100Imp::SR_general100Imp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void SR_general100Imp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void SR_general100Imp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
vector<string> fileNames;
|
||||
getDirList(path, fileNames);
|
||||
for (vector<string>::iterator it=fileNames.begin(); it!=fileNames.end(); ++it)
|
||||
{
|
||||
string &imageName = *it;
|
||||
Ptr<SR_general100Obj> curr(new SR_general100Obj);
|
||||
curr->imageName = imageName;
|
||||
train.back().push_back(curr);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Ptr<SR_general100> SR_general100::create()
|
||||
{
|
||||
return Ptr<SR_general100Imp>(new SR_general100Imp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,223 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/tr_chars.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class TR_charsImp CV_FINAL : public TR_chars
|
||||
{
|
||||
public:
|
||||
TR_charsImp() {}
|
||||
//TR_charsImp(const string &path, int number = 0);
|
||||
virtual ~TR_charsImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDatasetSplit(const string &path, int number);
|
||||
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void parseLine(const string &line, vector<int> &currSet, int number);
|
||||
|
||||
inline void convert(vector<int> &from, vector< Ptr<Object> > &to, vector<int> &allLabels, vector<string> &allNames);
|
||||
|
||||
inline void parseSet(const string &line, const string &pattern, bool &flag, vector<int> &set, int number);
|
||||
};
|
||||
|
||||
void TR_charsImp::parseLine(const string &line, vector<int> &currSet, int number)
|
||||
{
|
||||
vector<string> elems;
|
||||
split(line, elems, ' ');
|
||||
if (number >= (int)elems.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int ind = atoi(elems[number].c_str());
|
||||
if (ind > 0)
|
||||
{
|
||||
currSet.push_back(ind-1);
|
||||
}
|
||||
}
|
||||
|
||||
inline void TR_charsImp::convert(vector<int> &from, vector< Ptr<Object> > &to, vector<int> &allLabels, vector<string> &allNames)
|
||||
{
|
||||
for (vector<int>::iterator it=from.begin(); it!=from.end(); ++it)
|
||||
{
|
||||
if (*it>=(int)allNames.size() || *it>=(int)allLabels.size())
|
||||
{
|
||||
printf("incorrect index: %u\n", *it);
|
||||
continue;
|
||||
}
|
||||
|
||||
Ptr<TR_charsObj> 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<int> &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);
|
||||
}*/
|
||||
|
||||
void TR_charsImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void TR_charsImp::loadDataset(const string &path)
|
||||
{
|
||||
int number = 0;
|
||||
do
|
||||
{
|
||||
loadDatasetSplit(path, number);
|
||||
number++;
|
||||
} while (train.back().size()>0);
|
||||
|
||||
train.pop_back(); // remove last empty split
|
||||
test.pop_back(); // remove last empty split
|
||||
validation.pop_back(); // remove last empty split
|
||||
}
|
||||
|
||||
void TR_charsImp::loadDatasetSplit(const string &path, int number)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
vector<int> allLabels, trainSet, testSet, validationSet;
|
||||
vector<string> allNames;
|
||||
|
||||
ifstream infile((path + "list_English_Img.m").c_str());
|
||||
string line;
|
||||
bool labels = false, names = false, isTrain = false, isTest = false, isValidation = false;
|
||||
while (getline(infile, line))
|
||||
{
|
||||
size_t pos = line.find("];");
|
||||
if (string::npos != pos)
|
||||
{
|
||||
labels = false;
|
||||
names = false;
|
||||
isTrain = false;
|
||||
isTest = false;
|
||||
isValidation = false;
|
||||
}
|
||||
|
||||
string slabels("list.ALLlabels = [");
|
||||
pos = line.find(slabels);
|
||||
if (string::npos != pos)
|
||||
{
|
||||
labels = true;
|
||||
string s(line.substr(pos+slabels.length()));
|
||||
allLabels.push_back(atoi(s.c_str()));
|
||||
} else
|
||||
if (labels)
|
||||
{
|
||||
allLabels.push_back(atoi(line.c_str()));
|
||||
}
|
||||
|
||||
string snames("list.ALLnames = [");
|
||||
pos = line.find(snames);
|
||||
if (string::npos != pos)
|
||||
{
|
||||
names = true;
|
||||
size_t start = pos+snames.length();
|
||||
string s(line.substr(start+1, line.length()-start-2));
|
||||
allNames.push_back(s);
|
||||
} else
|
||||
if (names)
|
||||
{
|
||||
string s(line.substr(1, line.length()-2));
|
||||
allNames.push_back(s);
|
||||
}
|
||||
|
||||
string trainStr("list.TRNind = [");
|
||||
parseSet(line, trainStr, isTrain, trainSet, 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.TXNind = ["*/
|
||||
}
|
||||
|
||||
convert(trainSet, train.back(), allLabels, allNames);
|
||||
convert(testSet, test.back(), allLabels, allNames);
|
||||
convert(validationSet, validation.back(), allLabels, allNames);
|
||||
}
|
||||
|
||||
Ptr<TR_chars> TR_chars::create()
|
||||
{
|
||||
return Ptr<TR_charsImp>(new TR_charsImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/tr_icdar.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
class TR_icdarImp CV_FINAL : public TR_icdar
|
||||
{
|
||||
public:
|
||||
TR_icdarImp() {}
|
||||
//TR_icdarImp(const string &path);
|
||||
virtual ~TR_icdarImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void objParseFiles(const string &path, int img_id, vector<Ptr <Object> > &out);
|
||||
};
|
||||
|
||||
void TR_icdarImp::objParseFiles(const string &path, int img_id, vector<Ptr <Object> > &out)
|
||||
{
|
||||
Ptr<TR_icdarObj> curr(new TR_icdarObj);
|
||||
|
||||
stringstream fileName;
|
||||
fileName << "img_" << img_id << ".jpg";
|
||||
curr->fileName = fileName.str();
|
||||
|
||||
stringstream gtFileName;
|
||||
gtFileName << path << "/gt_img_" << img_id << ".txt";
|
||||
ifstream infile(gtFileName.str().c_str());
|
||||
if (!infile.is_open()) CV_Error(Error::StsBadArg, gtFileName.str().c_str());
|
||||
string line;
|
||||
while (getline(infile, line))
|
||||
{
|
||||
//Ignore EOL characters
|
||||
line.erase(remove(line.begin(), line.end(), '\n'), line.end());
|
||||
line.erase(remove(line.begin(), line.end(), '\r'), line.end());
|
||||
//Ignore byte-order marks (BOM first utf character in W$ files)
|
||||
if ( (line[0] == (char)0xEFu) && (line[1] == (char)0xBBu) && (line[2] == (char)0xBFu) )
|
||||
line.erase (line.begin(),line.begin()+3);
|
||||
vector<string> fields;
|
||||
split(line, fields, ',');
|
||||
word w;
|
||||
w.value = fields[8];
|
||||
w.x = atoi(fields[0].c_str());
|
||||
w.y = atoi(fields[1].c_str());
|
||||
w.width = atoi(fields[2].c_str()) - atoi(fields[0].c_str());
|
||||
w.height = atoi(fields[7].c_str()) - atoi(fields[1].c_str());
|
||||
curr->words.push_back(w);
|
||||
}
|
||||
infile.close();
|
||||
|
||||
stringstream lex100FileName;
|
||||
lex100FileName << path << "/voc_img_" << img_id << ".txt";
|
||||
infile.open(lex100FileName.str().c_str());
|
||||
if (!infile.is_open()) CV_Error(Error::StsBadArg, lex100FileName.str().c_str());
|
||||
while (getline(infile, line))
|
||||
{
|
||||
//Ignore EOL characters
|
||||
line.erase(remove(line.begin(), line.end(), '\n'), line.end());
|
||||
line.erase(remove(line.begin(), line.end(), '\r'), line.end());
|
||||
//Ignore byte-order marks (BOM first utf character in W$ files)
|
||||
if ( (line[0] == (char)0xEFu) && (line[1] == (char)0xBBu) && (line[2] == (char)0xBFu) )
|
||||
line.erase (line.begin(),line.begin()+3);
|
||||
curr->lex100.push_back(line);
|
||||
}
|
||||
infile.close();
|
||||
|
||||
stringstream lexFullFileName;
|
||||
if (path.substr(path.size()-5,4) == string("test"))
|
||||
lexFullFileName << path << "ch2_test_vocabulary.txt";
|
||||
else
|
||||
lexFullFileName << path << "ch2_training_vocabulary.txt";
|
||||
infile.open(lexFullFileName.str().c_str());
|
||||
if (!infile.is_open()) CV_Error(Error::StsBadArg, lexFullFileName.str().c_str());
|
||||
while (getline(infile, line))
|
||||
{
|
||||
//Ignore EOL characters
|
||||
line.erase(remove(line.begin(), line.end(), '\n'), line.end());
|
||||
line.erase(remove(line.begin(), line.end(), '\r'), line.end());
|
||||
//Ignore byte-order marks (BOM first utf character in W$ files)
|
||||
if ( (line[0] == (char)0xEFu) && (line[1] == (char)0xBBu) && (line[2] == (char)0xBFu) )
|
||||
line.erase (line.begin(),line.begin()+3);
|
||||
curr->lexFull.push_back(line);
|
||||
}
|
||||
infile.close();
|
||||
|
||||
out.push_back(curr);
|
||||
}
|
||||
|
||||
/*TR_icdarImp::TR_icdarImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void TR_icdarImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void TR_icdarImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string train_path(path + "/train/");
|
||||
string test_path (path + "/test/");
|
||||
|
||||
// loading 229 train images descriptions
|
||||
for (int i=1; i<230; i++)
|
||||
objParseFiles(train_path, i, train.back());
|
||||
|
||||
// loading 233 test images descriptions
|
||||
for (int i=1; i<234; i++)
|
||||
objParseFiles(test_path, i, test.back());
|
||||
}
|
||||
|
||||
Ptr<TR_icdar> TR_icdar::create()
|
||||
{
|
||||
return Ptr<TR_icdarImp>(new TR_icdarImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/tr_svt.hpp"
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 5
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wsuggest-override"
|
||||
#endif
|
||||
#include "tinyxml2/tinyxml2.h"
|
||||
#if defined(__GNUC__) && __GNUC__ >= 5
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
using namespace cv::tinyxml2;
|
||||
|
||||
class TR_svtImp CV_FINAL : public TR_svt
|
||||
{
|
||||
public:
|
||||
TR_svtImp() {}
|
||||
//TR_svtImp(const string &path);
|
||||
virtual ~TR_svtImp() CV_OVERRIDE {}
|
||||
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
private:
|
||||
void loadDataset(const string &path);
|
||||
|
||||
void xmlParse(const string &set, vector< Ptr<Object> > &out);
|
||||
};
|
||||
|
||||
void TR_svtImp::xmlParse(const string &set, vector< Ptr<Object> > &out)
|
||||
{
|
||||
XMLDocument doc;
|
||||
doc.LoadFile(set.c_str());
|
||||
XMLElement *root_ = doc.RootElement();
|
||||
string rootElem(root_->Name());
|
||||
if (rootElem == "tagset")
|
||||
{
|
||||
string strImage("image");
|
||||
XMLElement *child = root_->FirstChildElement(strImage.c_str());
|
||||
while (child)
|
||||
{
|
||||
string imageName = child->FirstChildElement("imageName")->GetText();
|
||||
string lex = child->FirstChildElement("lex")->GetText();
|
||||
|
||||
Ptr<TR_svtObj> curr(new TR_svtObj);
|
||||
curr->fileName = imageName;
|
||||
split(lex, curr->lex, ',');
|
||||
|
||||
XMLElement *childTaggeds = child->FirstChildElement("taggedRectangles");
|
||||
if (childTaggeds)
|
||||
{
|
||||
string strTagged("taggedRectangle");
|
||||
XMLElement *childTagged = childTaggeds->FirstChildElement(strTagged.c_str());
|
||||
while (childTagged)
|
||||
{
|
||||
tag t;
|
||||
t.value = childTagged->FirstChildElement("tag")->GetText();
|
||||
t.height = atoi(childTagged->Attribute("height"));
|
||||
t.width = atoi(childTagged->Attribute("width"));
|
||||
t.x = atoi(childTagged->Attribute("x"));
|
||||
t.y = atoi(childTagged->Attribute("y"));
|
||||
curr->tags.push_back(t);
|
||||
|
||||
childTagged = childTagged->NextSiblingElement(strTagged.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
out.push_back(curr);
|
||||
|
||||
child = child->NextSiblingElement(strImage.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*TR_svtImp::TR_svtImp(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}*/
|
||||
|
||||
void TR_svtImp::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void TR_svtImp::loadDataset(const string &path)
|
||||
{
|
||||
train.push_back(vector< Ptr<Object> >());
|
||||
test.push_back(vector< Ptr<Object> >());
|
||||
validation.push_back(vector< Ptr<Object> >());
|
||||
|
||||
string trainXml(path + "train.xml");
|
||||
string testXml(path + "test.xml");
|
||||
|
||||
// loading train images description
|
||||
xmlParse(trainXml, train.back());
|
||||
|
||||
// loading test images description
|
||||
xmlParse(testXml, test.back());
|
||||
}
|
||||
|
||||
Ptr<TR_svt> TR_svt::create()
|
||||
{
|
||||
return Ptr<TR_svtImp>(new TR_svtImp);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,382 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/track_alov.hpp"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <opencv2/core.hpp>
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
class TRACK_alovImpl CV_FINAL : public TRACK_alov
|
||||
{
|
||||
public:
|
||||
//Constructor
|
||||
TRACK_alovImpl()
|
||||
{
|
||||
activeDatasetID = 1;
|
||||
frameCounter = 0;
|
||||
}
|
||||
//Destructor
|
||||
virtual ~TRACK_alovImpl() CV_OVERRIDE {}
|
||||
|
||||
//Load Dataset
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
virtual void loadAnnotatedOnly(const std::string &path) CV_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual int getDatasetsNum() CV_OVERRIDE;
|
||||
|
||||
virtual int getDatasetLength(int id) CV_OVERRIDE;
|
||||
|
||||
virtual bool initDataset(int id) CV_OVERRIDE;
|
||||
|
||||
virtual bool getNextFrame(Mat &frame) CV_OVERRIDE;
|
||||
virtual bool getFrame(Mat &frame, int datasetID, int frameID) CV_OVERRIDE;
|
||||
|
||||
virtual vector <Point2f> getNextGT() CV_OVERRIDE;
|
||||
virtual vector <Point2f> getGT(int datasetID, int frameID) CV_OVERRIDE;
|
||||
|
||||
void loadDataset(const string &path);
|
||||
void loadDatasetAnnotatedOnly(const string &path);
|
||||
|
||||
string fullFramePath(string rootPath, int sectionID, int videoID, int frameID);
|
||||
string fullAnnoPath(string rootPath, int sectionID, int videoID);
|
||||
};
|
||||
|
||||
|
||||
void TRACK_alovImpl::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
void TRACK_alovImpl::loadAnnotatedOnly(const string &path)
|
||||
{
|
||||
loadDatasetAnnotatedOnly(path);
|
||||
}
|
||||
|
||||
string TRACK_alovImpl::fullFramePath(string rootPath, int sectionID, int videoID, int frameID)
|
||||
{
|
||||
string out;
|
||||
char videoNum[9];
|
||||
sprintf(videoNum, "%u", videoID+1);
|
||||
char frameNum[9];
|
||||
sprintf(frameNum, "%u", frameID);
|
||||
out = rootPath + "/imagedata++/" + sectionNames[sectionID] + "/" + sectionNames[sectionID] + "_video";
|
||||
|
||||
for (unsigned int i = 0; i < 5 - strlen(videoNum); ++i)
|
||||
{
|
||||
out += "0";
|
||||
}
|
||||
|
||||
out += videoNum;
|
||||
out += "/";
|
||||
|
||||
for (unsigned int i = 0; i < 8 - strlen(frameNum); ++i)
|
||||
{
|
||||
out += "0";
|
||||
}
|
||||
|
||||
out += frameNum;
|
||||
out += ".jpg";
|
||||
return out;
|
||||
}
|
||||
|
||||
string TRACK_alovImpl::fullAnnoPath(string rootPath, int sectionID, int videoID)
|
||||
{
|
||||
string out;
|
||||
char videoNum[9];
|
||||
sprintf(videoNum, "%u", videoID+1);
|
||||
out = rootPath + "/alov300++_rectangleAnnotation_full/" + sectionNames[sectionID] + "/" + sectionNames[sectionID] + "_video";
|
||||
|
||||
for (unsigned int i = 0; i < 5 - strlen(videoNum); ++i)
|
||||
{
|
||||
out += "0";
|
||||
}
|
||||
|
||||
out += videoNum;
|
||||
out += ".ann";
|
||||
return out;
|
||||
}
|
||||
|
||||
inline bool fileExists(const std::string& name)
|
||||
{
|
||||
struct stat buffer;
|
||||
return (stat(name.c_str(), &buffer) == 0);
|
||||
}
|
||||
|
||||
void TRACK_alovImpl::loadDataset(const string &rootPath)
|
||||
{
|
||||
vector <int> datasetsLengths;
|
||||
|
||||
printf("ALOV300++ Dataset Initialization...\n");
|
||||
|
||||
//Load frames
|
||||
//Loop for all sections of ALOV300++ (14 sections)
|
||||
for (int i = 0; i < 14; i++)
|
||||
{
|
||||
//Loop for all videos in section
|
||||
for (int k = 0; k < sectionSizes[i]; k++)
|
||||
{
|
||||
vector <Ptr<TRACK_alovObj> > objects;
|
||||
|
||||
//Make a list of datasets lengths
|
||||
int currFrameID = 0;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
currFrameID++;
|
||||
string fullPath = fullFramePath(rootPath, i, k, currFrameID);
|
||||
if (!fileExists(fullPath))
|
||||
break;
|
||||
|
||||
//Make ALOV300++ Object
|
||||
Ptr<TRACK_alovObj> currObj(new TRACK_alovObj);
|
||||
currObj->imagePath = fullPath;
|
||||
currObj->id = currFrameID;
|
||||
|
||||
currObj->gtbb.push_back(Point2d(0, 0));
|
||||
currObj->gtbb.push_back(Point2d(0, 0));
|
||||
currObj->gtbb.push_back(Point2d(0, 0));
|
||||
currObj->gtbb.push_back(Point2d(0, 0));
|
||||
|
||||
//Add object to storage
|
||||
objects.push_back(currObj);
|
||||
|
||||
}
|
||||
|
||||
datasetsLengths.push_back(currFrameID - 1);
|
||||
data.push_back(objects);
|
||||
}
|
||||
}
|
||||
|
||||
//Load annotations
|
||||
//Loop for all sections of ALOV300++ (14 sections)
|
||||
int currDatasetID = 0;
|
||||
for (int i = 0; i < 14; i++)
|
||||
{
|
||||
//Loop for all videos in section
|
||||
for (int k = 0; k < sectionSizes[i]; k++)
|
||||
{
|
||||
currDatasetID++;
|
||||
|
||||
//Open dataset's ground truth (annotation) file
|
||||
string annoPath = fullAnnoPath(rootPath, i, k);
|
||||
ifstream annoList(annoPath.c_str());
|
||||
if (!annoList.is_open())
|
||||
{
|
||||
printf("Error: Can't open annotation file *.ANN!!!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
//Ground Truth data
|
||||
int n = 0;
|
||||
double x1 = 0, y1 = 0,
|
||||
x2 = 0, y2 = 0,
|
||||
x3 = 0, y3 = 0,
|
||||
x4 = 0, y4 = 0;
|
||||
|
||||
do
|
||||
{
|
||||
//Make ALOV300++ Object
|
||||
string tmp;
|
||||
|
||||
getline(annoList, tmp);
|
||||
std::istringstream in(tmp);
|
||||
in >> n >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
|
||||
|
||||
Ptr<TRACK_alovObj> currObj = data[currDatasetID-1][n-1];
|
||||
|
||||
currObj->gtbb.clear();
|
||||
currObj->gtbb.push_back(Point2d(x1, y1));
|
||||
currObj->gtbb.push_back(Point2d(x2, y2));
|
||||
currObj->gtbb.push_back(Point2d(x3, y3));
|
||||
currObj->gtbb.push_back(Point2d(x4, y4));
|
||||
|
||||
} while (annoList.good());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void TRACK_alovImpl::loadDatasetAnnotatedOnly(const string &rootPath)
|
||||
{
|
||||
vector <int> datasetsLengths;
|
||||
|
||||
printf("ALOV300++ Annotated Dataset Initialization...\n");
|
||||
|
||||
//Loop for all sections of ALOV300++ (14 sections)
|
||||
for (int i = 0; i < 14; i++)
|
||||
{
|
||||
//Loop for all videos in section
|
||||
for (int k = 0; k < sectionSizes[i]; k++)
|
||||
{
|
||||
vector <Ptr<TRACK_alovObj> > objects;
|
||||
|
||||
//Open dataset's ground truth (annotation) file
|
||||
string annoPath = fullAnnoPath(rootPath, i, k);
|
||||
ifstream annoList(annoPath.c_str());
|
||||
if (!annoList.is_open())
|
||||
{
|
||||
printf("Error: Can't open annotation file *.ANN!!!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
int framesNum = 0;
|
||||
|
||||
do
|
||||
{
|
||||
//Make ALOV300++ Object
|
||||
Ptr<TRACK_alovObj> currObj(new TRACK_alovObj);
|
||||
string tmp;
|
||||
framesNum++;
|
||||
|
||||
//Ground Truth data
|
||||
int n = 0;
|
||||
double x1 = 0, y1 = 0,
|
||||
x2 = 0, y2 = 0,
|
||||
x3 = 0, y3 = 0,
|
||||
x4 = 0, y4 = 0;
|
||||
|
||||
getline(annoList, tmp);
|
||||
std::istringstream in(tmp);
|
||||
in >> n >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
|
||||
|
||||
currObj->gtbb.push_back(Point2d(x1, y1));
|
||||
currObj->gtbb.push_back(Point2d(x2, y2));
|
||||
currObj->gtbb.push_back(Point2d(x3, y3));
|
||||
currObj->gtbb.push_back(Point2d(x4, y4));
|
||||
|
||||
string fullPath = fullFramePath(rootPath, i, k, n);
|
||||
if (!fileExists(fullPath))
|
||||
break;
|
||||
|
||||
currObj->imagePath = fullPath;
|
||||
currObj->id = n;
|
||||
|
||||
//Add object to storage
|
||||
objects.push_back(currObj);
|
||||
|
||||
} while (annoList.good());
|
||||
|
||||
datasetsLengths.push_back(framesNum-1);
|
||||
data.push_back(objects);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int TRACK_alovImpl::getDatasetsNum()
|
||||
{
|
||||
return (int)(data.size());
|
||||
}
|
||||
|
||||
int TRACK_alovImpl::getDatasetLength(int id)
|
||||
{
|
||||
if (id > 0 && id <= (int)data.size())
|
||||
return (int)(data[id - 1].size());
|
||||
else
|
||||
{
|
||||
printf("Dataset ID is out of range...\nAllowed IDs are: 1~%d\n", (int)data.size());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool TRACK_alovImpl::initDataset(int id)
|
||||
{
|
||||
if (id > 0 && id <= (int)data.size())
|
||||
{
|
||||
activeDatasetID = id;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Dataset ID is out of range...\nAllowed IDs are: 1~%d\n", (int)data.size());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool TRACK_alovImpl::getNextFrame(Mat &frame)
|
||||
{
|
||||
if (frameCounter >= (int)data[activeDatasetID - 1].size())
|
||||
return false;
|
||||
string imgPath = data[activeDatasetID - 1][frameCounter]->imagePath;
|
||||
frame = imread(imgPath);
|
||||
frameCounter++;
|
||||
return !frame.empty();
|
||||
}
|
||||
|
||||
bool TRACK_alovImpl::getFrame(Mat &frame, int datasetID, int frameID)
|
||||
{
|
||||
if (frameID > (int)data[datasetID-1].size())
|
||||
return false;
|
||||
string imgPath = data[datasetID-1][frameID-1]->imagePath;
|
||||
frame = imread(imgPath);
|
||||
return !frame.empty();
|
||||
}
|
||||
|
||||
Ptr<TRACK_alov> TRACK_alov::create()
|
||||
{
|
||||
return Ptr<TRACK_alovImpl>(new TRACK_alovImpl);
|
||||
}
|
||||
|
||||
vector <Point2f> TRACK_alovImpl::getNextGT()
|
||||
{
|
||||
Ptr <TRACK_alovObj> currObj = data[activeDatasetID - 1][frameCounter - 1];
|
||||
return currObj->gtbb;
|
||||
}
|
||||
|
||||
vector <Point2f> TRACK_alovImpl::getGT(int datasetID, int frameID)
|
||||
{
|
||||
Ptr <TRACK_alovObj> currObj = data[datasetID - 1][frameID - 1];
|
||||
return currObj->gtbb;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/track_vot.hpp"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <opencv2/core.hpp>
|
||||
#include "opencv2/imgcodecs.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
class TRACK_votImpl CV_FINAL : public TRACK_vot
|
||||
{
|
||||
public:
|
||||
//Constructor
|
||||
TRACK_votImpl()
|
||||
{
|
||||
activeDatasetID = 1;
|
||||
frameCounter = 0;
|
||||
}
|
||||
//Destructor
|
||||
virtual ~TRACK_votImpl() CV_OVERRIDE {}
|
||||
|
||||
//Load Dataset
|
||||
virtual void load(const string &path) CV_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual int getDatasetsNum() CV_OVERRIDE;
|
||||
|
||||
virtual int getDatasetLength(int id) CV_OVERRIDE;
|
||||
|
||||
virtual bool initDataset(int id) CV_OVERRIDE;
|
||||
|
||||
virtual bool getNextFrame(Mat &frame) CV_OVERRIDE;
|
||||
|
||||
virtual vector <Point2d> getGT() CV_OVERRIDE;
|
||||
|
||||
void loadDataset(const string &path);
|
||||
|
||||
string numberToString(int number);
|
||||
};
|
||||
|
||||
void TRACK_votImpl::load(const string &path)
|
||||
{
|
||||
loadDataset(path);
|
||||
}
|
||||
|
||||
string TRACK_votImpl::numberToString(int number)
|
||||
{
|
||||
string out;
|
||||
char numberStr[20];
|
||||
sprintf(numberStr, "%u", number);
|
||||
for (unsigned int i = 0; i < 8 - strlen(numberStr); ++i)
|
||||
{
|
||||
out += "0";
|
||||
}
|
||||
out += numberStr;
|
||||
return out;
|
||||
}
|
||||
|
||||
inline bool fileExists(const std::string& name)
|
||||
{
|
||||
struct stat buffer;
|
||||
return (stat(name.c_str(), &buffer) == 0);
|
||||
}
|
||||
|
||||
void TRACK_votImpl::loadDataset(const string &rootPath)
|
||||
{
|
||||
string nameListPath = rootPath + "/list.txt";
|
||||
ifstream namesList(nameListPath.c_str());
|
||||
vector <int> datasetsLengths;
|
||||
string datasetName;
|
||||
|
||||
if (namesList.is_open())
|
||||
{
|
||||
int currDatasetID = 0;
|
||||
|
||||
//All datasets/folders loop
|
||||
while (getline(namesList, datasetName))
|
||||
{
|
||||
currDatasetID++;
|
||||
vector <Ptr<TRACK_votObj> > objects;
|
||||
|
||||
//All frames/images loop
|
||||
Ptr<TRACK_votObj> currDataset(new TRACK_votObj);
|
||||
|
||||
//Open dataset's ground truth file
|
||||
string gtListPath = rootPath + "/" + datasetName + "/groundtruth.txt";
|
||||
ifstream gtList(gtListPath.c_str());
|
||||
if (!gtList.is_open())
|
||||
printf("Error to open groundtruth.txt!!!");
|
||||
|
||||
//Make a list of datasets lengths
|
||||
int currFrameID = 0;
|
||||
if (currDatasetID == 0)
|
||||
printf("VOT Dataset Initialization...\n");
|
||||
bool trFLG = true;
|
||||
do
|
||||
{
|
||||
currFrameID++;
|
||||
string fullPath = rootPath + "/" + datasetName + "/" + numberToString(currFrameID) + ".jpg";
|
||||
if (!fileExists(fullPath))
|
||||
break;
|
||||
|
||||
//Make VOT Object
|
||||
Ptr<TRACK_votObj> currObj(new TRACK_votObj);
|
||||
currObj->imagePath = fullPath;
|
||||
currObj->id = currFrameID;
|
||||
|
||||
//Get Ground Truth data
|
||||
double x1 = 0, y1 = 0,
|
||||
x2 = 0, y2 = 0,
|
||||
x3 = 0, y3 = 0,
|
||||
x4 = 0, y4 = 0;
|
||||
string tmp;
|
||||
getline(gtList, tmp);
|
||||
sscanf(tmp.c_str(), "%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4);
|
||||
currObj->gtbb.push_back(Point2d(x1, y1));
|
||||
currObj->gtbb.push_back(Point2d(x2, y2));
|
||||
currObj->gtbb.push_back(Point2d(x3, y3));
|
||||
currObj->gtbb.push_back(Point2d(x4, y4));
|
||||
|
||||
//Add object to storage
|
||||
objects.push_back(currObj);
|
||||
|
||||
} while (trFLG);
|
||||
|
||||
datasetsLengths.push_back(currFrameID - 1);
|
||||
data.push_back(objects);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Couldn't find a *list.txt* in VOT Dataset folder!!!");
|
||||
}
|
||||
|
||||
namesList.close();
|
||||
return;
|
||||
}
|
||||
|
||||
int TRACK_votImpl::getDatasetsNum()
|
||||
{
|
||||
return (int)(data.size());
|
||||
}
|
||||
|
||||
int TRACK_votImpl::getDatasetLength(int id)
|
||||
{
|
||||
if (id > 0 && id <= (int)data.size())
|
||||
return (int)(data[id - 1].size());
|
||||
else
|
||||
{
|
||||
printf("Dataset ID is out of range...\nAllowed IDs are: 1~%d\n", (int)data.size());
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool TRACK_votImpl::initDataset(int id)
|
||||
{
|
||||
if (id > 0 && id <= (int)data.size())
|
||||
{
|
||||
activeDatasetID = id;
|
||||
frameCounter = 0;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Dataset ID is out of range...\nAllowed IDs are: 1~%d\n", (int)data.size());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool TRACK_votImpl::getNextFrame(Mat &frame)
|
||||
{
|
||||
if (frameCounter >= (int)data[activeDatasetID - 1].size())
|
||||
return false;
|
||||
string imgPath = data[activeDatasetID - 1][frameCounter]->imagePath;
|
||||
frame = imread(imgPath);
|
||||
frameCounter++;
|
||||
return !frame.empty();
|
||||
}
|
||||
|
||||
Ptr<TRACK_vot> TRACK_vot::create()
|
||||
{
|
||||
return Ptr<TRACK_votImpl>(new TRACK_votImpl);
|
||||
}
|
||||
|
||||
vector <Point2d> TRACK_votImpl::getGT()
|
||||
{
|
||||
Ptr <TRACK_votObj> currObj = data[activeDatasetID - 1][frameCounter - 1];
|
||||
return currObj->gtbb;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/util.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#else
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace datasets
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
void split(const string &s, vector<string> &elems, char delim)
|
||||
{
|
||||
stringstream ss(s);
|
||||
string item;
|
||||
while (getline(ss, item, delim))
|
||||
{
|
||||
elems.push_back(item);
|
||||
}
|
||||
}
|
||||
|
||||
void createDirectory(const string &path)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
mkdir(path.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
#else
|
||||
mkdir(path.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
void getDirList(const string &dirName, vector<string> &fileNames)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
struct dirent **namelist;
|
||||
int n = scandir(dirName.c_str(), &namelist, NULL, alphasort);
|
||||
for (int i=0; i<n; ++i)
|
||||
{
|
||||
string fileName(namelist[i]->d_name);
|
||||
if ('.' != fileName[0])
|
||||
{
|
||||
fileNames.push_back(fileName);
|
||||
}
|
||||
free(namelist[i]);
|
||||
}
|
||||
free(namelist);
|
||||
#else // for WIN32
|
||||
struct _finddata_t file;
|
||||
string filter(dirName);
|
||||
filter += "\\*.*";
|
||||
intptr_t hFile = _findfirst(filter.c_str(), &file);
|
||||
if (hFile==-1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
do
|
||||
{
|
||||
string fileName(file.name);
|
||||
if ('.' != fileName[0])
|
||||
{
|
||||
fileNames.push_back(fileName);
|
||||
}
|
||||
} while (_findnext(hFile, &file)==0);
|
||||
_findclose(hFile);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user